From de2bc3771bb30ca083e9a43fa7ac574f7450b6d2 Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Sun, 9 Feb 2025 15:09:48 +0800 Subject: [PATCH] fix: streaming --- src/agent.ts | 1 + src/server.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/agent.ts b/src/agent.ts index e9ba197..86f70ed 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -210,6 +210,7 @@ ${allKeywords.join('\n')} if (allowAnswer) { actionSections.push(` +- If is a simple greeting, chit-chat, or general knowledge, provide the answer directly. - Provide final response only when 100% certain - Responses must be definitive (no ambiguity, uncertainty, or disclaimers)${allowReflect ? '\n- If doubts remain, use instead' : ''} diff --git a/src/server.ts b/src/server.ts index 9898123..2eabb61 100644 --- a/src/server.ts +++ b/src/server.ts @@ -105,7 +105,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => { context.tokenTracker.trackUsage('evaluator', chunkTokens, TOKEN_CATEGORIES.REASONING); // Only send chunk if there's content to send - if (action.think) { + if (action.thisStep.think) { const chunk: ChatCompletionChunk = { id: requestId, object: 'chat.completion.chunk', @@ -114,7 +114,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => { system_fingerprint: 'fp_' + requestId, choices: [{ index: 0, - delta: { content: `${action.think}` }, + delta: { content: `${action.thisStep.think}` }, logprobs: null, finish_reason: null }] @@ -175,7 +175,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => { system_fingerprint: 'fp_' + requestId, choices: [{ index: 0, - delta: { content: '' }, + delta: { content: '\n\n' }, logprobs: null, finish_reason: null }]