diff --git a/src/agent.ts b/src/agent.ts index ac167c2..6dc4fd3 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -329,7 +329,8 @@ export async function getResponse(question?: string, maxBadAttempts: number = 3, existingContext?: Partial, messages?: Array, - numReturnedURLs: number = 100 + numReturnedURLs: number = 100, + noDirectAnswer: boolean = false, ): Promise<{ result: StepAction; context: TrackerContext; visitedURLs: string[], readURLs: string[], allURLs: string[] }> { let step = 0; @@ -495,7 +496,7 @@ export async function getResponse(question?: string, console.log('Updated references:', thisStep.references) - if (totalStep === 1 && thisStep.references.length === 0) { + if (totalStep === 1 && thisStep.references.length === 0 && !noDirectAnswer) { // LLM is so confident and answer immediately, skip all evaluations // however, if it does give any reference, it must be evaluated, case study: "How to configure a timeout when loading a huggingface dataset with python?" thisStep.isFinal = true; diff --git a/src/app.ts b/src/app.ts index ffcceee..7076b32 100644 --- a/src/app.ts +++ b/src/app.ts @@ -548,7 +548,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => { visitedURLs, readURLs, allURLs - } = await getResponse(undefined, tokenBudget, maxBadAttempts, context, body.messages, body.numReturnedURLs) + } = await getResponse(undefined, tokenBudget, maxBadAttempts, context, body.messages, body.numReturnedURLs, body.noDirectAnswer) let finalAnswer = (finalStep as AnswerAction).mdAnswer; const annotations = (finalStep as AnswerAction).references?.map(ref => ({ diff --git a/src/types.ts b/src/types.ts index d66cde8..66ad104 100644 --- a/src/types.ts +++ b/src/types.ts @@ -216,6 +216,7 @@ export interface ChatCompletionRequest { response_format?: ResponseFormat; numReturnedURLs?: number; + noDirectAnswer?: boolean; } export interface URLAnnotation {