feat: add api args

This commit is contained in:
Han Xiao 2025-03-14 16:08:11 +08:00
parent f5d6bf75f5
commit ad2aa7f6e6
3 changed files with 5 additions and 3 deletions

View File

@ -329,7 +329,8 @@ export async function getResponse(question?: string,
maxBadAttempts: number = 3,
existingContext?: Partial<TrackerContext>,
messages?: Array<CoreMessage>,
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;

View File

@ -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 => ({

View File

@ -216,6 +216,7 @@ export interface ChatCompletionRequest {
response_format?: ResponseFormat;
numReturnedURLs?: number;
noDirectAnswer?: boolean;
}
export interface URLAnnotation {