fix(deep-research): searchLanguage is missing when recursively calling deepResearch

This commit is contained in:
AnotiaWang
2025-02-18 12:57:56 +08:00
parent eada822366
commit f593546864

View File

@ -92,21 +92,23 @@ export function generateSearchQueries({
const schema = z.object({ const schema = z.object({
queries: z queries: z
.array( .array(
z.object({ z
query: z.string().describe('The SERP query'), .object({
query: z.string().describe('The SERP query.'),
researchGoal: z researchGoal: z
.string() .string()
.describe( .describe(
'First talk about the goal of the research that this query is meant to accomplish, then go deeper into how to advance the research once the results are found, mention additional research directions. Be as specific as possible, especially for additional research directions.', 'First talk about the goal of the research that this query is meant to accomplish, then go deeper into how to advance the research once the results are found, mention additional research directions. Be as specific as possible, especially for additional research directions.',
), ),
}), })
.required({ query: true, researchGoal: true }),
) )
.describe(`List of SERP queries, max of ${numQueries}`), .describe(`List of SERP queries, max of ${numQueries}`),
}) })
const jsonSchema = JSON.stringify(zodToJsonSchema(schema)) const jsonSchema = JSON.stringify(zodToJsonSchema(schema))
let lp = languagePrompt(language) let lp = languagePrompt(language)
if (searchLanguage !== language) { if (searchLanguage && searchLanguage !== language) {
lp += ` Use ${searchLanguage} for the SERP queries.` lp += ` Use ${searchLanguage} for the SERP queries.`
} }
const prompt = [ const prompt = [
@ -443,6 +445,7 @@ export async function deepResearch({
currentDepth: nextDepth, currentDepth: nextDepth,
nodeId: childNodeId(nodeId, i), nodeId: childNodeId(nodeId, i),
languageCode, languageCode,
searchLanguage,
}) })
return r return r
} catch (error) { } catch (error) {