feat: added advanced search and topic support for Tavily
This commit is contained in:
@ -70,6 +70,7 @@
|
||||
supportsCustomApiBase: true,
|
||||
},
|
||||
])
|
||||
const tavilySearchTopicOptions = ['general', 'news', 'finance']
|
||||
const selectedAiProvider = computed(() =>
|
||||
aiProviderOptions.value.find((o) => o.value === config.value.ai.provider),
|
||||
)
|
||||
@ -323,6 +324,27 @@
|
||||
:step="1"
|
||||
/>
|
||||
</UFormField>
|
||||
|
||||
<!-- Tavily-specific settings -->
|
||||
<template v-if="config.webSearch.provider === 'tavily'">
|
||||
<UFormField
|
||||
:label="$t('settings.webSearch.providers.tavily.advancedSearch')"
|
||||
:help="$t('settings.webSearch.providers.tavily.advancedSearchHelp')"
|
||||
>
|
||||
<USwitch v-model="config.webSearch.tavilyAdvancedSearch" />
|
||||
</UFormField>
|
||||
<UFormField
|
||||
:label="$t('settings.webSearch.providers.tavily.searchTopic')"
|
||||
:help="$t('settings.webSearch.providers.tavily.searchTopicHelp')"
|
||||
>
|
||||
<USelect
|
||||
v-model="config.webSearch.tavilySearchTopic"
|
||||
class="w-30"
|
||||
:items="tavilySearchTopicOptions"
|
||||
placeholder="general"
|
||||
/>
|
||||
</UFormField>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
|
@ -47,7 +47,11 @@ export const useWebSearch = (): WebSearchFunction => {
|
||||
apiKey: config.webSearch.apiKey,
|
||||
})
|
||||
return async (q: string, o: WebSearchOptions) => {
|
||||
const results = await tvly.search(q, o)
|
||||
const results = await tvly.search(q, {
|
||||
...o,
|
||||
searchDepth: config.webSearch.tavilyAdvancedSearch ? 'advanced' : 'basic',
|
||||
topic: config.webSearch.tavilySearchTopic,
|
||||
})
|
||||
return results.results
|
||||
.filter((x) => !!x?.content && !!x.url)
|
||||
.map((r) => ({
|
||||
|
@ -37,7 +37,11 @@
|
||||
"queryLanguageHelp": "The language of the search query. Useful if you want to get search results in a different language.\nWhen writing conclusions, the AI model will still use the language same as the web UI.",
|
||||
"providers": {
|
||||
"tavily": {
|
||||
"help": "Similar to Firecrawl, but provides 1000 free credits / month. Get one API key at {0}."
|
||||
"help": "Similar to Firecrawl, but provides 1000 free credits / month. Get one API key at {0}.",
|
||||
"advancedSearch": "Advanced Search",
|
||||
"advancedSearchHelp": "Get higher quality search results. Costs 1 extra credit each time.",
|
||||
"searchTopic": "Search Topic",
|
||||
"searchTopicHelp": "Optimize the search for the selected topic with tailored and curated information. Defaults to 'general'."
|
||||
},
|
||||
"firecrawl": {
|
||||
"help": "Get one API key at {0} if you are using the official service."
|
||||
|
@ -40,7 +40,11 @@
|
||||
"help": "如果你使用的是官方服务,请在 {0} 获取 API key。"
|
||||
},
|
||||
"tavily": {
|
||||
"help": "和 Firecrawl 类似,不过提供了每月 1000 次免费搜索。在 {0} 获取一个 API key。"
|
||||
"help": "和 Firecrawl 类似,不过提供了每月 1000 次免费搜索。在 {0} 获取一个 API key。",
|
||||
"advancedSearchHelp": "获得更高质量的搜索结果。每次多消耗一个搜索点数 (credit)。",
|
||||
"searchTopic": "搜索领域",
|
||||
"advancedSearch": "高质量搜索",
|
||||
"searchTopicHelp": "搜索特定领域的信息,获得更精确的结果。默认为“通用” (general)。"
|
||||
}
|
||||
},
|
||||
"concurrencyLimit": "并发数",
|
||||
|
@ -26,6 +26,10 @@ export interface ConfigWebSearch {
|
||||
searchLanguage?: Locale
|
||||
/** Limit the number of concurrent tasks globally */
|
||||
concurrencyLimit?: number
|
||||
/** Tavily: use advanced search to retrieve higher quality results */
|
||||
tavilyAdvancedSearch?: boolean
|
||||
/** Tavily: search topic. Defaults to `general` */
|
||||
tavilySearchTopic?: 'general' | 'news' | 'finance'
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
|
Reference in New Issue
Block a user