fix(deep-research): apply search language correctly

This commit is contained in:
AnotiaWang
2025-02-25 16:12:47 +08:00
parent f58bced86e
commit 4b86257a1d
3 changed files with 10 additions and 3 deletions

View File

@ -40,6 +40,7 @@
const toast = useToast() const toast = useToast()
const { t, locale } = useI18n() const { t, locale } = useI18n()
const { config } = useConfigStore()
const isLargeScreen = useMediaQuery('(min-width: 768px)') const isLargeScreen = useMediaQuery('(min-width: 768px)')
const flowRef = ref<InstanceType<typeof Flow>>() const flowRef = ref<InstanceType<typeof Flow>>()
@ -278,6 +279,7 @@
breadth, breadth,
maxDepth: form.value.depth, maxDepth: form.value.depth,
languageCode: locale.value, languageCode: locale.value,
searchLanguageCode: config.webSearch.searchLanguage,
learnings: existingLearnings, learnings: existingLearnings,
visitedUrls: existingVisitedUrls, visitedUrls: existingVisitedUrls,
onProgress: handleResearchProgress, onProgress: handleResearchProgress,

View File

@ -103,7 +103,6 @@
} }
function reset() { function reset() {
console.warn('reset')
layoutGraph() layoutGraph()
hasUserInteraction = false hasUserInteraction = false
} }

View File

@ -218,6 +218,7 @@ export async function deepResearch({
breadth, breadth,
maxDepth, maxDepth,
languageCode, languageCode,
searchLanguageCode,
learnings = [], learnings = [],
visitedUrls = [], visitedUrls = [],
onProgress, onProgress,
@ -228,8 +229,10 @@ export async function deepResearch({
query: string query: string
breadth: number breadth: number
maxDepth: number maxDepth: number
/** Language code for SERP queries and web searches */ /** The language of generated response */
languageCode: Locale languageCode: Locale
/** The language of SERP query */
searchLanguageCode?: Locale
/** Accumulated learnings from all nodes visited so far */ /** Accumulated learnings from all nodes visited so far */
learnings?: string[] learnings?: string[]
/** Accumulated visited URLs from all nodes visited so far */ /** Accumulated visited URLs from all nodes visited so far */
@ -243,6 +246,9 @@ export async function deepResearch({
}): Promise<ResearchResult> { }): Promise<ResearchResult> {
const { t } = useNuxtApp().$i18n const { t } = useNuxtApp().$i18n
const language = t('language', {}, { locale: languageCode }) const language = t('language', {}, { locale: languageCode })
const searchLanguage = searchLanguageCode
? t('language', {}, { locale: searchLanguageCode })
: undefined
const globalLimit = usePLimit() const globalLimit = usePLimit()
try { try {
@ -266,7 +272,7 @@ export async function deepResearch({
learnings, learnings,
numQueries: breadth, numQueries: breadth,
language, language,
searchLanguage: language, searchLanguage,
}) })
for await (const chunk of parseStreamingJson( for await (const chunk of parseStreamingJson(