|
| 1 | +import fs from 'node:fs'; |
| 2 | +for (const line of fs.readFileSync('.env', 'utf-8').split('\n')) { |
| 3 | + const m = line.match(/^([A-Z0-9_]+)=(.*)$/); |
| 4 | + if (m) process.env[m[1]] = m[2]; |
| 5 | +} |
| 6 | +import { createOpenRouter } from '@openrouter/ai-sdk-provider'; |
| 7 | +import { generateText, tool } from 'ai'; |
| 8 | +import { z } from 'zod'; |
| 9 | +import { PROFESSIONAL_SUMMARY_GENERATOR_MESSAGE } from './src/lib/prompts'; |
| 10 | + |
| 11 | +const aiClient = createOpenRouter({ apiKey: process.env.OPENROUTER_API_KEY, baseURL: 'https://openrouter.ai/api/v1' })('deepseek/deepseek-v3.2:nitro'); |
| 12 | + |
| 13 | +async function run(label: string, work_experience: any[]) { |
| 14 | + const profile = { |
| 15 | + work_experience, |
| 16 | + skills: [{ category: 'Languages', skills: ['TypeScript', 'React', 'Node.js'] }], |
| 17 | + projects: [], |
| 18 | + certifications: [], |
| 19 | + }; |
| 20 | + |
| 21 | + const job = { |
| 22 | + position_title: 'Software Engineer', |
| 23 | + company_name: 'Beta Inc', |
| 24 | + description: 'Looking for a software engineer to join our team.', |
| 25 | + keywords: ['TypeScript', 'React'], |
| 26 | + }; |
| 27 | + |
| 28 | + const profileBlob = JSON.stringify(profile, null, 2); |
| 29 | + const jobBlob = `Position: ${job.position_title}\nCompany: ${job.company_name}\nKeywords: ${job.keywords.join(', ')}\nDescription:\n${job.description}`; |
| 30 | + |
| 31 | + const { text } = await generateText({ |
| 32 | + model: aiClient, |
| 33 | + system: PROFESSIONAL_SUMMARY_GENERATOR_MESSAGE.content as string, |
| 34 | + prompt: `CANDIDATE PROFILE (source of truth — only reference skills/experience present here): |
| 35 | +${profileBlob} |
| 36 | +
|
| 37 | +TARGET JOB: |
| 38 | +${jobBlob} |
| 39 | +
|
| 40 | +Call getCurrentDate first, then compute the candidate's real years of experience and the seniority-adjusted opener title per your instructions. Write the professional summary paragraph now. 3-4 sentences, 60-90 words, plain text only.`, |
| 41 | + tools: { |
| 42 | + getCurrentDate: tool({ |
| 43 | + description: |
| 44 | + 'Returns today\'s real-world date. Call this before computing years of experience or resolving "Present" in work_experience date ranges, since your training data may be outdated.', |
| 45 | + parameters: z.object({}), |
| 46 | + execute: async () => new Date().toISOString().split('T')[0], |
| 47 | + }), |
| 48 | + }, |
| 49 | + maxSteps: 3, |
| 50 | + }); |
| 51 | + |
| 52 | + console.log(`\n=== ${label} ===`); |
| 53 | + console.log('SUMMARY:', text.trim()); |
| 54 | +} |
| 55 | + |
| 56 | +async function main() { |
| 57 | + await run('Real resume (expect 5+ years)', [ |
| 58 | + { company: 'Acuity Health', position: 'Software Engineer II', location: 'Spring Hill, TN', date: 'Jul 2024 - Present', description: ['Led development of admin portal'], technologies: ['Next.js', 'React'] }, |
| 59 | + { company: 'George Mason University', position: 'Software Engineer', location: 'Fairfax, VA', date: 'Feb 2024 - Dec 2024', description: ['Built geospatial workflow tool'], technologies: ['React', 'D3.js'] }, |
| 60 | + { company: 'Phenom', position: 'Software Development Engineer', location: 'Hyderabad, India', date: 'Sep 2020 - Dec 2022', description: ['Built no-code form builder'], technologies: ['React', 'TypeScript'] }, |
| 61 | + { company: 'Carelon Global Solutions', position: 'Associate Software Engineer', location: 'Hyderabad, India', date: 'Jun 2020 - Aug 2020', description: ['Built LMS'], technologies: ['Angular'] }, |
| 62 | + ]); |
| 63 | + |
| 64 | + await run('Overlap only, no gap (expect 3+ years, not 6+)', [ |
| 65 | + { company: 'A', position: 'Engineer', location: 'X', date: 'Jan 2023 - Present', description: ['x'], technologies: [] }, |
| 66 | + { company: 'B', position: 'Consultant', location: 'X', date: 'Jun 2023 - Dec 2024', description: ['x'], technologies: [] }, |
| 67 | + ]); |
| 68 | + |
| 69 | + await run('Gap only, no overlap (expect 4+ years, not 5+)', [ |
| 70 | + { company: 'A', position: 'Engineer', location: 'X', date: 'Jan 2020 - Dec 2021', description: ['x'], technologies: [] }, |
| 71 | + { company: 'B', position: 'Engineer', location: 'X', date: 'Jan 2023 - Dec 2024', description: ['x'], technologies: [] }, |
| 72 | + ]); |
| 73 | +} |
| 74 | + |
| 75 | +main().catch((e) => { console.error(e); process.exit(1); }); |
0 commit comments