From d12bc09b8befcdae65aa15ff26bd54c058bfe53c Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Thu, 30 Jan 2025 21:36:50 +0800 Subject: [PATCH] chore: first commit --- src/agent.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/agent.ts b/src/agent.ts index 394d340..32dafec 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -354,6 +354,25 @@ async function getResponse(question: string, tokenBudget: number = 1000000) { const evaluation = await evaluateAnswer(currentQuestion, action.answer); if (currentQuestion === question) { + if (badAttempts >= 3) { + // EXIT POINT OF THE PROGRAM!!!! + diaryContext.push(` +At step ${step} and ${badAttempts} attempts, you took **answer** action and found an answer, not a perfect one but good enough to answer the original question: + +Original question: +${currentQuestion} + +Your answer: +${action.answer} + +The evaluator thinks your answer is good because: +${evaluation.reasoning} + +Your journey ends here. +`); + await storeContext(prompt, [allContext, allKeywords, allQuestions, allKnowledge], totalStep); + return action; + } if (evaluation.is_valid_answer) { if (action.references.length > 0 || Object.keys(allURLs).length === 0) { // EXIT POINT OF THE PROGRAM!!!!