Skip to content

feat(llm): add configurable web search engines (Tavily, SearXNG)#9342

Draft
Kureii wants to merge 2 commits intoTriliumNext:mainfrom
Kureii:feat/llm-web-search-engines
Draft

feat(llm): add configurable web search engines (Tavily, SearXNG)#9342
Kureii wants to merge 2 commits intoTriliumNext:mainfrom
Kureii:feat/llm-web-search-engines

Conversation

@Kureii
Copy link
Copy Markdown
Contributor

@Kureii Kureii commented Apr 8, 2026

Summary

Add Tavily and SearXNG as alternative web search engines alongside the default provider-built-in search. Includes a configurable timeout for all search requests.

Changes

  • Tavily: AI-optimized search API with API key authentication
  • SearXNG: Self-hosted metasearch engine, no API key required
  • Engine selection in base_provider.ts with fallback to provider default
  • AbortSignal.timeout() applied to search fetch calls
  • Settings UI with conditional fields per engine type
  • New options: llmWebSearchEngine, llmTavilyApiKey, llmSearxngUrl, llmSearchTimeout

Files (7 files, +241/-1)

  • apps/server/src/services/llm/web_search_tools.ts - New: Tavily & SearXNG implementations
  • apps/server/src/services/llm/providers/base_provider.ts - Engine routing + timeout
  • apps/server/src/services/options_init.ts - Option defaults
  • apps/server/src/routes/api/options.ts - Options whitelist
  • packages/commons/src/lib/options_interface.ts - Option type definitions
  • apps/client/src/widgets/type_widgets/options/llm.tsx - WebSearchSettings component
  • apps/client/src/translations/en/translation.json - Translation keys

Add Tavily and SearXNG as alternative web search engines alongside
the default provider-built-in search. This enables web search for
providers that lack built-in search (e.g. Ollama).

- New web_search_tools.ts with Tavily API and SearXNG implementations
- Settings UI for engine selection, API keys, instance URL
- Configurable search timeout (default 15s, max 120s)
- Fallback to provider default when custom engine lacks credentials
- Options: llmWebSearchEngine, llmTavilyApiKey, llmSearxngUrl,
  llmSearchTimeout
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 8, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for custom web search engines (Tavily and SearXNG) for the LLM agent, allowing users to choose alternatives to the provider's built-in search. The changes include new UI settings, server-side configuration options, and the implementation of search tools using the ai package. Feedback was provided to refactor the search engine selection logic in BaseProvider to reduce code duplication when falling back to the default search tool.

Comment thread apps/server/src/services/llm/providers/base_provider.ts
Use customToolAdded flag instead of calling this.addWebSearchTool()
in three separate places.
Copy link
Copy Markdown
Contributor

@eliandoran eliandoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested it yet, only checked out the settings page.

However, we need to make a pretty big structural change, having one option per search engine is not scalable:

  • We already have the LLM provider system, which already supports API keys and thanks to the Ollama integation also a base URL.
  • Just create a new type of providers, search engines.
  • Don't break backward compatibility with old providers that might not have a type set.
  • This will also allow the user to create multiple instances of the same search engine, for example.
  • Make sure the UX is still easy to use.

@eliandoran eliandoran marked this pull request as draft April 11, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants