Improve resume parser field mapping and markdown JSON extraction
This commit is contained in:
@@ -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] : [])
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user