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));
function buildSummaryPrompt(episodes, existingSummary = null) {
const MAX_CHARS = 3000; // truncate input to keep Phi3 focused
const MAX_CHARS = 3000;
let context = episodes
.map(ep => `User: ${ep.user_message}\nAssistant: ${ep.ai_response}`)
.join('\n\n');
// Truncate from the start if too long — keep the most recent exchanges
if (context.length > MAX_CHARS) {
context = context.slice(-MAX_CHARS);
}
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:
${existingSummary}
New exchanges:
${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:
${context}`;
return [
'<|user|>',
'<|im_start|>user', // ChatML for qwen2.5
instruction,
'<|end|>',
'<|assistant|>',
'<|im_end|>',
'<|im_start|>assistant',
].join('\n');
}
@@ -52,7 +55,7 @@ async function generateSummary(episodes, existingSummary = null) {
stream: false,
options: {
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
},
}),
});