mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
feat: add api args
This commit is contained in:
parent
f5d6bf75f5
commit
ad2aa7f6e6
@ -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;
|
||||
|
||||
@ -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 => ({
|
||||
|
||||
@ -216,6 +216,7 @@ export interface ChatCompletionRequest {
|
||||
|
||||
response_format?: ResponseFormat;
|
||||
numReturnedURLs?: number;
|
||||
noDirectAnswer?: boolean;
|
||||
}
|
||||
|
||||
export interface URLAnnotation {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user