mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 07:12:18 +10:00
refactor(ai): collapse parser prompts to template; replace makeEmptyItem with structuredClone
- Replace pdf-parser-system.md + docx-parser-system.md with a single parser-system.md template; prompts.ts substitutes 6 placeholders per source type. Produced strings are byte-identical to the former files. - Remove makeEmptyItem recursive walker (all SECTION_ITEM_SHAPES leaves are already zero-valued) and call structuredClone(shape) instead. Claude-Session: https://claude.ai/code/session_012Bnvt1MghwHj4qQRxuQUGa
This commit is contained in:
@@ -4,11 +4,46 @@ const readPrompt = (filename: string) => {
|
||||
return readFileSync(new URL(`./prompts/${filename}`, import.meta.url), "utf-8");
|
||||
};
|
||||
|
||||
// ponytail: single template with per-source substitutions; produced text is identical per source type
|
||||
const parserTemplate = readPrompt("parser-system.md");
|
||||
|
||||
type ParserVars = {
|
||||
FORMAT_HEADER: string;
|
||||
FORMAT_NOUN: string;
|
||||
ALLOWED_INPUT: string;
|
||||
URL_CLAUSE: string;
|
||||
EXTRA_RULES: string;
|
||||
FALLBACK_CLAUSE: string;
|
||||
};
|
||||
|
||||
function makeParserPrompt(vars: ParserVars): string {
|
||||
return Object.entries(vars).reduce((acc, [k, v]) => acc.replaceAll(`{{${k}}}`, v), parserTemplate);
|
||||
}
|
||||
|
||||
const pdfParserSystemPrompt = makeParserPrompt({
|
||||
FORMAT_HEADER: "PDF files",
|
||||
FORMAT_NOUN: "PDF",
|
||||
ALLOWED_INPUT:
|
||||
"- Use only the visible content from the attached PDF document.\n- Ignore OCR noise, watermarks, repeated headers/footers, and broken line wraps.",
|
||||
URL_CLAUSE: "full URLs that are explicitly present",
|
||||
EXTRA_RULES: "",
|
||||
FALLBACK_CLAUSE: "PDF is low quality or partially unreadable",
|
||||
});
|
||||
|
||||
const docxParserSystemPrompt = makeParserPrompt({
|
||||
FORMAT_HEADER: "Microsoft Word files (DOC/DOCX)",
|
||||
FORMAT_NOUN: "document",
|
||||
ALLOWED_INPUT:
|
||||
"- Use only visible, intended content from the attached document.\n- Ignore hidden text, comments, track changes, revision history, document metadata, and layout artifacts.",
|
||||
URL_CLAUSE: "URLs explicitly visible in document content",
|
||||
EXTRA_RULES:
|
||||
"- Lists and tables: extract visible text faithfully; preserve relationships in section fields.\n- Headers/footers: include only if they contain real resume data.\n",
|
||||
FALLBACK_CLAUSE: "document is malformed or partially unreadable",
|
||||
});
|
||||
|
||||
const analyzeResumeSystemPrompt = readPrompt("analyze-resume-system.md");
|
||||
const chatSystemPromptTemplate = readPrompt("chat-system.md");
|
||||
const docxParserSystemPrompt = readPrompt("docx-parser-system.md");
|
||||
const docxParserUserPrompt = readPrompt("docx-parser-user.md");
|
||||
const pdfParserSystemPrompt = readPrompt("pdf-parser-system.md");
|
||||
const pdfParserUserPrompt = readPrompt("pdf-parser-user.md");
|
||||
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user