Improve resume parser field mapping and markdown JSON extraction

This commit is contained in:
2026-07-22 17:22:22 -04:00
parent fb45cb52d7
commit 437e811293
3 changed files with 45 additions and 5 deletions
+10 -4
View File
@@ -309,18 +309,24 @@ Extract the following fields accurately:
}
}
}
},
required: ["fullName", "skills", "experience"]
}
};
const { text, providerUsed } = await generateTextWithLLMFallback(prompt, schema, llmConfig);
const parsedProfile = JSON.parse(text || "{}");
// Extract JSON cleanly in case markdown wrapping was returned
const cleanJsonText = text.replace(/```json/gi, '').replace(/```/g, '').trim();
const parsedProfile = JSON.parse(cleanJsonText || "{}");
// Ensure IDs on experience items
if (Array.isArray(parsedProfile.experience)) {
parsedProfile.experience = parsedProfile.experience.map((exp: any, index: number) => ({
...exp,
id: exp.id || `exp_parsed_${Date.now()}_${index}`
id: exp.id || `exp_parsed_${Date.now()}_${index}`,
title: exp.title || exp.role || exp.position || "Position",
company: exp.company || exp.organization || "Company",
period: exp.period || exp.dates || exp.duration || "",
bullets: Array.isArray(exp.bullets) ? exp.bullets : (exp.description ? [exp.description] : [])
}));
}