extraction error logging

This commit is contained in:
Storme-bit
2026-04-21 01:07:31 -07:00
parent c81a1cb20e
commit 21a7e5f3b5

View File

@@ -9,34 +9,37 @@ const MAX_SUMMARY_TOKENS = parseInt(getEnv('SUMMARY_MAX_TOKENS', SUMMARIES.MAX_S
const MIN_EPISODES_SINCE = parseInt(getEnv('SUMMARY_MIN_EPISODES', SUMMARIES.MIN_EPISODES_SINCE)); const MIN_EPISODES_SINCE = parseInt(getEnv('SUMMARY_MIN_EPISODES', SUMMARIES.MIN_EPISODES_SINCE));
function buildSummaryPrompt(episodes, existingSummary = null) { function buildSummaryPrompt(episodes, existingSummary = null) {
const MAX_CHARS = 3000; // truncate input to keep Phi3 focused const MAX_CHARS = 3000;
let context = episodes let context = episodes
.map(ep => `User: ${ep.user_message}\nAssistant: ${ep.ai_response}`) .map(ep => `User: ${ep.user_message}\nAssistant: ${ep.ai_response}`)
.join('\n\n'); .join('\n\n');
// Truncate from the start if too long — keep the most recent exchanges
if (context.length > MAX_CHARS) { if (context.length > MAX_CHARS) {
context = context.slice(-MAX_CHARS); context = context.slice(-MAX_CHARS);
} }
const instruction = existingSummary const instruction = existingSummary
? `Update the summary below to include the new exchanges. Write 3-5 sentences in third person. Output only the updated summary text, nothing else. ? `Update the summary below to incorporate the new exchanges.
Write 3-5 sentences in third person. Do not quote directly — paraphrase only.
Do not include greetings, sign-offs, or filler. Output only the updated summary text.
Previous summary: Previous summary:
${existingSummary} ${existingSummary}
New exchanges: New exchanges:
${context}` ${context}`
: `Summarize the conversation below in 3-5 sentences. Write in third person. Output only the summary text, nothing else. : `Summarize the conversation below in 3-5 sentences.
Write in third person. Do not quote directly — paraphrase only.
Do not include greetings, sign-offs, or filler. Output only the summary text.
Conversation: Conversation:
${context}`; ${context}`;
return [ return [
'<|user|>', '<|im_start|>user', // ChatML for qwen2.5
instruction, instruction,
'<|end|>', '<|im_end|>',
'<|assistant|>', '<|im_start|>assistant',
].join('\n'); ].join('\n');
} }
@@ -52,7 +55,7 @@ async function generateSummary(episodes, existingSummary = null) {
stream: false, stream: false,
options: { options: {
temperature: 0.2, // slightly higher than entities — summaries benefit from some fluency temperature: 0.2, // slightly higher than entities — summaries benefit from some fluency
num_predict: 200, // generous but bounded — keeps summaries from running long num_predict: 500, // generous but bounded — keeps summaries from running long
}, },
}), }),
}); });