feat: added advanced search and topic support for Tavily

This commit is contained in:
AnotiaWang
2025-02-20 14:53:42 +08:00
parent 599515e52e
commit 0ad5316249
5 changed files with 41 additions and 3 deletions

View File

@ -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) => ({