You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/core/src/services/summarizer.ts
+43-2Lines changed: 43 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,14 +11,34 @@ import { StreamEventType } from '../core/geminiChat.js';
11
11
import{debugLogger}from'../utils/debugLogger.js';
12
12
import*asfsfrom'node:fs/promises';
13
13
14
-
constSUMMARIZER_SYSTEM_PROMPT=`You are a text summarizer. Your sole purpose is to receive text and provide a concise, factual summary of it. Do not add any commentary or analysis. Focus on the key information presented in the text.`;
14
+
constSUMMARIZER_SYSTEM_PROMPT=`## Role
15
+
You are an expert Tool Call Output Summarizer.
16
+
17
+
## Task Definition
18
+
Your task is to summarize a given tool call output. The summary must specifically highlight how the tool call output contributes to or addresses the user's overall objective.
19
+
20
+
## Instruction
21
+
When generating the summary, focus solely on the information within the \`toolcall\` that directly addresses or fulfills aspects of the \`objective\`. **The summary must be as exhaustive as possible, capturing every relevant detail from the tool call, and must be presented as a bulleted list.** Do not include extraneous details or interpret the tool call beyond its direct relevance to the objective.
22
+
23
+
## Response Format Constraints
24
+
The response **must be a bulleted list** containing **up to 20 points** (maximum). Each bullet point should be concise. DO NOT include any explicit explanations, reasoning, or thinking process outside of the bullet points. Your output must ONLY be the bulleted summary.`;
25
+
26
+
constSUMMARIZER_USER_PROMPT=`## Input
27
+
User's Objective: {{objective}}
28
+
Tool Call Output: {{toolcall}}
29
+
30
+
## Output Reminder
31
+
Take a deep breath, read the instructions again, read the inputs again. Each instruction is crucial and must be executed with utmost care and attention to detail.
32
+
33
+
Summary:`;
15
34
16
35
exportclassSummarizationService{
17
36
constructor(){}
18
37
19
38
asyncsummarize(
20
39
tollResponseParts: GeminiPart[],
21
40
modelConfig: OllamaModelConfig|ModelConfig,
41
+
objective: string,
22
42
): Promise<string|null>{
23
43
debugLogger.log(
24
44
`[SummarizationService] Starting summarization using model: ${modelConfig.model}`,
@@ -34,13 +54,34 @@ export class SummarizationService {
34
54
}
35
55
}
36
56
57
+
try{
58
+
awaitfs.writeFile(
59
+
'summarize_tool_prompt.txt',
60
+
JSON.stringify(userParts,null,2),
61
+
);
62
+
debugLogger.log(
63
+
'[DEBUG] Summarized tool output saved to summarize_tool_prompt.txt',
64
+
);
65
+
}catch(error){
66
+
debugLogger.error(
67
+
'[DEBUG] Failed to save summarized tool output to summarize_tool_prompt.txt:',
0 commit comments