mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
fix: streaming
This commit is contained in:
parent
de2bc3771b
commit
c2931c6e2a
@ -11,7 +11,7 @@
|
||||
"defaults": {
|
||||
"search_provider": "jina",
|
||||
"llm_provider": "gemini",
|
||||
"step_sleep": 1000
|
||||
"step_sleep": 0
|
||||
},
|
||||
"providers": {
|
||||
"gemini": {
|
||||
|
||||
@ -312,7 +312,6 @@ export async function getResponse(question: string, tokenBudget: number = 1_000_
|
||||
await sleep(STEP_SLEEP);
|
||||
step++;
|
||||
totalStep++;
|
||||
context.actionTracker.trackAction({totalStep, thisStep, gaps, badAttempts});
|
||||
const budgetPercentage = (context.tokenTracker.getTotalUsage() / tokenBudget * 100).toFixed(2);
|
||||
console.log(`Step ${totalStep} / Budget used ${budgetPercentage}%`);
|
||||
console.log('Gaps:', gaps);
|
||||
@ -355,13 +354,15 @@ export async function getResponse(question: string, tokenBudget: number = 1_000_
|
||||
object = result.object;
|
||||
totalTokens = result.totalTokens;
|
||||
}
|
||||
context.tokenTracker.trackUsage('agent', totalTokens);
|
||||
thisStep = object as StepAction;
|
||||
// print allowed and chose action
|
||||
const actionsStr = [allowSearch, allowRead, allowAnswer, allowReflect].map((a, i) => a ? ['search', 'read', 'answer', 'reflect'][i] : null).filter(a => a).join(', ');
|
||||
console.log(`${thisStep.action} <- [${actionsStr}]`);
|
||||
console.log(thisStep)
|
||||
|
||||
context.actionTracker.trackAction({totalStep, thisStep, gaps, badAttempts});
|
||||
context.tokenTracker.trackUsage('agent', totalTokens);
|
||||
|
||||
// reset allowAnswer to true
|
||||
allowAnswer = true;
|
||||
allowReflect = true;
|
||||
|
||||
@ -114,7 +114,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
||||
system_fingerprint: 'fp_' + requestId,
|
||||
choices: [{
|
||||
index: 0,
|
||||
delta: { content: `${action.thisStep.think}` },
|
||||
delta: { content: `${action.thisStep.think}\n` },
|
||||
logprobs: null,
|
||||
finish_reason: null
|
||||
}]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user