mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
feat: add num urls
This commit is contained in:
parent
c9a51bb403
commit
f742478d15
@ -238,7 +238,8 @@ export async function getResponse(question?: string,
|
|||||||
tokenBudget: number = 1_000_000,
|
tokenBudget: number = 1_000_000,
|
||||||
maxBadAttempts: number = 3,
|
maxBadAttempts: number = 3,
|
||||||
existingContext?: Partial<TrackerContext>,
|
existingContext?: Partial<TrackerContext>,
|
||||||
messages?: Array<CoreMessage>
|
messages?: Array<CoreMessage>,
|
||||||
|
numReturnedURLs: number = 100
|
||||||
): Promise<{ result: StepAction; context: TrackerContext; visitedURLs: string[], readURLs: string[], allURLs: string[] }> {
|
): Promise<{ result: StepAction; context: TrackerContext; visitedURLs: string[], readURLs: string[], allURLs: string[] }> {
|
||||||
|
|
||||||
let step = 0;
|
let step = 0;
|
||||||
@ -845,7 +846,7 @@ But unfortunately, you failed to solve the issue. You need to think out of the b
|
|||||||
}, totalStep);
|
}, totalStep);
|
||||||
|
|
||||||
// max return 300 urls
|
// max return 300 urls
|
||||||
const returnedURLs = weightedURLs.slice(0, 50).map(r => r.url);
|
const returnedURLs = weightedURLs.slice(0, numReturnedURLs).map(r => r.url);
|
||||||
return {
|
return {
|
||||||
result: thisStep,
|
result: thisStep,
|
||||||
context,
|
context,
|
||||||
|
|||||||
@ -548,7 +548,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
|||||||
visitedURLs,
|
visitedURLs,
|
||||||
readURLs,
|
readURLs,
|
||||||
allURLs
|
allURLs
|
||||||
} = await getResponse(undefined, tokenBudget, maxBadAttempts, context, body.messages)
|
} = await getResponse(undefined, tokenBudget, maxBadAttempts, context, body.messages, body.numReturnedURLs)
|
||||||
let finalAnswer = (finalStep as AnswerAction).mdAnswer;
|
let finalAnswer = (finalStep as AnswerAction).mdAnswer;
|
||||||
|
|
||||||
const annotations = (finalStep as AnswerAction).references?.map(ref => ({
|
const annotations = (finalStep as AnswerAction).references?.map(ref => ({
|
||||||
|
|||||||
@ -215,6 +215,7 @@ export interface ChatCompletionRequest {
|
|||||||
max_attempts?: number;
|
max_attempts?: number;
|
||||||
|
|
||||||
response_format?: ResponseFormat;
|
response_format?: ResponseFormat;
|
||||||
|
numReturnedURLs?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface URLAnnotation {
|
export interface URLAnnotation {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user