mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2026-03-22 07:29:35 +08:00
feat: update minRelScore and add searchLanguageCode support
This commit is contained in:
@@ -388,8 +388,9 @@ export async function getResponse(question?: string,
|
|||||||
badHostnames: string[] = [],
|
badHostnames: string[] = [],
|
||||||
onlyHostnames: string[] = [],
|
onlyHostnames: string[] = [],
|
||||||
maxRef: number = 10,
|
maxRef: number = 10,
|
||||||
minRelScore: number = 0.75,
|
minRelScore: number = 0.85,
|
||||||
languageCode: string | undefined = undefined,
|
languageCode: string | undefined = undefined,
|
||||||
|
searchLanguageCode?: string,
|
||||||
searchProvider?: string
|
searchProvider?: string
|
||||||
): Promise<{ result: StepAction; context: TrackerContext; visitedURLs: string[], readURLs: string[], allURLs: string[] }> {
|
): Promise<{ result: StepAction; context: TrackerContext; visitedURLs: string[], readURLs: string[], allURLs: string[] }> {
|
||||||
|
|
||||||
@@ -420,6 +421,9 @@ export async function getResponse(question?: string,
|
|||||||
|
|
||||||
const SchemaGen = new Schemas();
|
const SchemaGen = new Schemas();
|
||||||
await SchemaGen.setLanguage(languageCode || question)
|
await SchemaGen.setLanguage(languageCode || question)
|
||||||
|
if (searchLanguageCode) {
|
||||||
|
SchemaGen.searchLanguageCode = searchLanguageCode;
|
||||||
|
}
|
||||||
const context: TrackerContext = {
|
const context: TrackerContext = {
|
||||||
tokenTracker: existingContext?.tokenTracker || new TokenTracker(tokenBudget),
|
tokenTracker: existingContext?.tokenTracker || new TokenTracker(tokenBudget),
|
||||||
actionTracker: existingContext?.actionTracker || new ActionTracker()
|
actionTracker: existingContext?.actionTracker || new ActionTracker()
|
||||||
|
|||||||
@@ -582,6 +582,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
|||||||
body.max_annotations,
|
body.max_annotations,
|
||||||
body.min_annotation_relevance,
|
body.min_annotation_relevance,
|
||||||
body.language_code,
|
body.language_code,
|
||||||
|
body.search_language_code,
|
||||||
body.search_provider
|
body.search_provider
|
||||||
)
|
)
|
||||||
let finalAnswer = (finalStep as AnswerAction).mdAnswer;
|
let finalAnswer = (finalStep as AnswerAction).mdAnswer;
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ export interface ChatCompletionRequest {
|
|||||||
max_annotations?: number;
|
max_annotations?: number;
|
||||||
min_annotation_relevance?: number;
|
min_annotation_relevance?: number;
|
||||||
language_code?: string;
|
language_code?: string;
|
||||||
|
search_language_code?: string;
|
||||||
search_provider?: string;
|
search_provider?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ const languageISO6391Map: Record<string, string> = {
|
|||||||
export class Schemas {
|
export class Schemas {
|
||||||
public languageStyle: string = 'formal English';
|
public languageStyle: string = 'formal English';
|
||||||
public languageCode: string = 'en';
|
public languageCode: string = 'en';
|
||||||
|
public searchLanguageCode: string | undefined = undefined;
|
||||||
|
|
||||||
|
|
||||||
async setLanguage(query: string) {
|
async setLanguage(query: string) {
|
||||||
@@ -162,7 +163,7 @@ export class Schemas {
|
|||||||
z.object({
|
z.object({
|
||||||
tbs: z.enum(['qdr:h', 'qdr:d', 'qdr:w', 'qdr:m', 'qdr:y']).describe('time-based search filter, must use this field if the search request asks for latest info. qdr:h for past hour, qdr:d for past 24 hours, qdr:w for past week, qdr:m for past month, qdr:y for past year. Choose exactly one.'),
|
tbs: z.enum(['qdr:h', 'qdr:d', 'qdr:w', 'qdr:m', 'qdr:y']).describe('time-based search filter, must use this field if the search request asks for latest info. qdr:h for past hour, qdr:d for past 24 hours, qdr:w for past week, qdr:m for past month, qdr:y for past year. Choose exactly one.'),
|
||||||
location: z.string().describe('defines from where you want the search to originate. It is recommended to specify location at the city level in order to simulate a real user’s search.').optional(),
|
location: z.string().describe('defines from where you want the search to originate. It is recommended to specify location at the city level in order to simulate a real user’s search.').optional(),
|
||||||
q: z.string().describe('keyword-based search query, 2-3 words preferred, total length < 30 characters').max(50),
|
q: z.string().describe(`keyword-based search query, 2-3 words preferred, total length < 30 characters. ${this.searchLanguageCode ? `Must in ${this.searchLanguageCode}` : ''}`).max(50),
|
||||||
}))
|
}))
|
||||||
.max(MAX_QUERIES_PER_STEP)
|
.max(MAX_QUERIES_PER_STEP)
|
||||||
.describe(`'Array of search keywords queries, orthogonal to each other. Maximum ${MAX_QUERIES_PER_STEP} queries allowed.'`)
|
.describe(`'Array of search keywords queries, orthogonal to each other. Maximum ${MAX_QUERIES_PER_STEP} queries allowed.'`)
|
||||||
|
|||||||
Reference in New Issue
Block a user