mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
fix the global allContext issue
This commit is contained in:
parent
2e8079b613
commit
f62bb348d4
@ -192,6 +192,8 @@ export const jinaAiMiddleware = (req: Request, res: Response, next: NextFunction
|
|||||||
}
|
}
|
||||||
).catch((err: any) => {
|
).catch((err: any) => {
|
||||||
logger.warn(`Failed to save promptContext`, { err: marshalErrorLike(err) });
|
logger.warn(`Failed to save promptContext`, { err: marshalErrorLike(err) });
|
||||||
|
}).finally(() => {
|
||||||
|
ctx.promptContext = undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,10 +213,6 @@ export const jinaAiMiddleware = (req: Request, res: Response, next: NextFunction
|
|||||||
if (err.stack) {
|
if (err.stack) {
|
||||||
logger.error(err.stack);
|
logger.error(err.stack);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
if (ctx.promptContext) {
|
|
||||||
ctx.promptContext = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
11
src/agent.ts
11
src/agent.ts
@ -239,12 +239,6 @@ ${actionSections.join('\n\n')}
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const allContext: StepAction[] = []; // all steps in the current session, including those leads to wrong results
|
|
||||||
|
|
||||||
function updateContext(step: any) {
|
|
||||||
allContext.push(step)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateReferences(thisStep: AnswerAction, allURLs: Record<string, SearchSnippet>) {
|
async function updateReferences(thisStep: AnswerAction, allURLs: Record<string, SearchSnippet>) {
|
||||||
thisStep.references = thisStep.references
|
thisStep.references = thisStep.references
|
||||||
?.filter(ref => ref?.url)
|
?.filter(ref => ref?.url)
|
||||||
@ -399,6 +393,11 @@ export async function getResponse(question?: string,
|
|||||||
|
|
||||||
let step = 0;
|
let step = 0;
|
||||||
let totalStep = 0;
|
let totalStep = 0;
|
||||||
|
const allContext: StepAction[] = []; // all steps in the current session, including those leads to wrong results
|
||||||
|
|
||||||
|
const updateContext = function(step: any) {
|
||||||
|
allContext.push(step);
|
||||||
|
}
|
||||||
|
|
||||||
question = question?.trim() as string;
|
question = question?.trim() as string;
|
||||||
// remove incoming system messages to avoid override
|
// remove incoming system messages to avoid override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user