mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
feat: update minRelScore and add searchLanguageCode support
This commit is contained in:
parent
ae2e7c7fc6
commit
2307c2ff44
@ -388,8 +388,9 @@ export async function getResponse(question?: string,
|
||||
badHostnames: string[] = [],
|
||||
onlyHostnames: string[] = [],
|
||||
maxRef: number = 10,
|
||||
minRelScore: number = 0.75,
|
||||
minRelScore: number = 0.85,
|
||||
languageCode: string | undefined = undefined,
|
||||
searchLanguageCode?: string,
|
||||
searchProvider?: 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();
|
||||
await SchemaGen.setLanguage(languageCode || question)
|
||||
if (searchLanguageCode) {
|
||||
SchemaGen.searchLanguageCode = searchLanguageCode;
|
||||
}
|
||||
const context: TrackerContext = {
|
||||
tokenTracker: existingContext?.tokenTracker || new TokenTracker(tokenBudget),
|
||||
actionTracker: existingContext?.actionTracker || new ActionTracker()
|
||||
|
||||
@ -582,6 +582,7 @@ app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
|
||||
body.max_annotations,
|
||||
body.min_annotation_relevance,
|
||||
body.language_code,
|
||||
body.search_language_code,
|
||||
body.search_provider
|
||||
)
|
||||
let finalAnswer = (finalStep as AnswerAction).mdAnswer;
|
||||
|
||||
@ -260,6 +260,7 @@ export interface ChatCompletionRequest {
|
||||
max_annotations?: number;
|
||||
min_annotation_relevance?: number;
|
||||
language_code?: string;
|
||||
search_language_code?: string;
|
||||
search_provider?: string;
|
||||
}
|
||||
|
||||
|
||||
@ -96,6 +96,7 @@ const languageISO6391Map: Record<string, string> = {
|
||||
export class Schemas {
|
||||
public languageStyle: string = 'formal English';
|
||||
public languageCode: string = 'en';
|
||||
public searchLanguageCode: string | undefined = undefined;
|
||||
|
||||
|
||||
async setLanguage(query: string) {
|
||||
@ -162,7 +163,7 @@ export class Schemas {
|
||||
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.'),
|
||||
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)
|
||||
.describe(`'Array of search keywords queries, orthogonal to each other. Maximum ${MAX_QUERIES_PER_STEP} queries allowed.'`)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user