From 21a7e5f3b5e1e68ac7591aed3cd28fdae9d319ba Mon Sep 17 00:00:00 2001 From: Storme-bit Date: Tue, 21 Apr 2026 01:07:31 -0700 Subject: [PATCH] extraction error logging --- .../src/services/summarization.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/orchestration-service/src/services/summarization.js b/packages/orchestration-service/src/services/summarization.js index 7ae3b28..c584d63 100644 --- a/packages/orchestration-service/src/services/summarization.js +++ b/packages/orchestration-service/src/services/summarization.js @@ -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 }, }), });