c9d00ca52aa769548cbbd55255606bdfc6f8bb3b
Ollama AI Answers Plugin for SearXNG
Single file install
Does not block result loading time
Based on ai-answers-searxng by cra88y
A SearXNG plugin that generates local AI overviews powered by Ollama, using search results as RAG context.
Features:
- token-by-token UI streaming
- clickable inline citations
- interactive mode to continue summary, ask follow ups, copy, or regenerate
- simple response mode with no extras
- internally called low-latency RAG for follow ups (bypasses http loopback)
- native network integration via
searx.network(respects proxy/SSL settings) - stateless conversation persistence/sharability via URL
Installation
Place ai_answers.py into the searx/plugins directory of your instance (or mount it in a container) and enable it in settings.yml:
plugins:
searx.plugins.ai_answers.SXNGPlugin:
active: true
Configuration
Configure via environment variables:
Required
LLM_URL: Ollama chat completions endpoint. Default:http://ollama:11434/v1/chat/completionsLLM_MODEL: Model name as listed in Ollama. Default:llama3.2
Optional
LLM_SYSTEM_PROMPT: Overrides the system prompt. Default:You are a direct, citation-accurate search synthesis engine.LLM_MAX_TOKENS: Default200.LLM_TEMPERATURE: Default0.2.LLM_CONTEXT_DEEP_COUNT: Results used as context with full snippets. Default5.LLM_CONTEXT_SHALLOW_COUNT: Results with headlines only (additional breadth). Default15.LLM_TABS: Tab whitelist, comma delimited. Defaultgeneral,science,it,news.LLM_INTERACTIVE: UI mode. Defaulttrue(interactive: copy, regenerate, follow up). Set tofalsefor simple response only.LLM_QUESTION_MARK_REQUIRED: Only trigger AI answers when the query contains?. Defaultfalse.
How It Works
- User performs initial search
- Results return server side
post_searchplugin hook fires- Token-optimized context extracted from results
- UI/logic shell injected into the standard results answer object
- Client-side script calls custom endpoint with a signed token
- Ollama response renders token by token in the UI
Example
Docker Compose
environment:
- LLM_URL=http://ollama:11434/v1/chat/completions
- LLM_MODEL=llama3.2
Environment variables
LLM_URL=http://ollama:11434/v1/chat/completions
LLM_MODEL=llama3.2
Development
pip install flask flask-babel
python tests/demo.py # UI demo at localhost:5000
Description
A SearXNG plugin that generates local AI overviews powered by Ollama, using search results as RAG context.
Languages
Python
100%