Skip to content

feat: Multi-provider LLM support (Ollama, OpenAI, Claude, Gemini)#23

Open
euvhmac wants to merge 5 commits into
sooryathejas:mainfrom
euvhmac:feature/multi-provider-llm
Open

feat: Multi-provider LLM support (Ollama, OpenAI, Claude, Gemini)#23
euvhmac wants to merge 5 commits into
sooryathejas:mainfrom
euvhmac:feature/multi-provider-llm

Conversation

@euvhmac
Copy link
Copy Markdown

@euvhmac euvhmac commented Apr 17, 2026

What

Adds support for multiple LLM providers beyond Ollama — users can now run METATRON with OpenAI (GPT), Anthropic (Claude), Google (Gemini), or keep using Ollama locally. Provider switching is available both at startup and mid-session via a new Settings menu.

Why

Ollama is great for local/offline use, but not everyone has the hardware to run large models. Cloud providers give users access to stronger models with zero setup. This also opens the door for comparing analysis quality across different LLMs.

How

New files

File Purpose
config.py Centralized configuration loaded from .env via python-dotenv. Defines active provider/model, API keys, DB credentials, and provider catalog.
providers.py Provider abstraction layer. BaseProvider ABC with send(messages) and ping() methods. Concrete implementations: OllamaProvider, AnthropicProvider, OpenAIProvider, GoogleProvider. Factory function get_provider().
.env.example Template with all configuration variables and safe defaults.

Modified files

File Change
llm.py ask_ollama()ask_llm() using the provider abstraction. summarize_tool_output() updated to use active provider. Preserves all upstream features (evidence gating, _clean(), summarizer, parser).
metatron.py New Settings menu (view providers, switch active, test connection). Provider selection prompt before each scan. Banner shows active provider/model dynamically. Cross-platform terminal clear.
db.py Uses config.py for DB credentials instead of hardcoded values.
export.py Uses config.py for DB credentials instead of hardcoded values.
requirements.txt Added python-dotenv, anthropic, openai, google-genai.
.gitignore Added .env to prevent accidental API key leaks.

Architecture

User → metatron.py → llm.py → providers.py → [Ollama | OpenAI | Claude | Gemini]

config.py (.env)

All providers implement the same BaseProvider interface, so llm.py is completely provider-agnostic. The system prompt, evidence gating rules, tool pipeline, and report generation work identically regardless of which provider is active.

Backward Compatibility

  • Ollama remains the default — zero config change needed for existing users
  • No database schema changes
  • No changes to the tool pipeline or scan logic
  • .env file is optional; defaults match current behavior
  • Cloud SDKs are optional runtime dependencies (only imported when the provider is selected)

Setup (for cloud providers)

cp .env.example .env
# Edit .env and add your API key(s):
# ANTHROPIC_API_KEY=sk-ant-...
# OPENAI_API_KEY=sk-...
# GOOGLE_API_KEY=AIza...

euvhmac added 5 commits April 17, 2026 08:46
- config.py: single source of truth for all settings (LLM, DB, providers)
- .env.example: template for environment configuration
- Replaces scattered hardcoded values across modules
- Supports Ollama (local), Anthropic, OpenAI, and Google providers
- providers.py: BaseProvider ABC with send()/ping() interface
- OllamaProvider: local LLM via /api/chat (messages-based)
- AnthropicProvider: Claude API via official SDK
- OpenAIProvider: GPT models via official SDK
- GoogleProvider: Gemini via google-genai SDK
- Factory pattern with get_provider() and list_providers()
- All providers use unified messages-based interface
- Replace ask_ollama() with ask_llm() using provider abstraction
- Update summarize_tool_output() to use active provider instead of direct Ollama call
- Add provider_name/model overrides to analyse_target() and run_tool_calls()
- Preserve all existing features: summarizer, evidence gating, _clean parser
- Remove hardcoded Ollama URL, model name, and timeout constants
- All parameters now loaded from config.py
- New Settings menu (option 3): view providers, switch active, test connection
- Per-scan provider override: choose provider before each scan
- Banner shows active provider/model dynamically
- Cross-platform clear screen (cls on Windows, clear on Linux)
… deps

- db.py: import DB settings from config.py instead of hardcoding
- export.py: import DB settings from config.py instead of hardcoding
- requirements.txt: add python-dotenv, anthropic, openai, google-genai
- .gitignore: add .env to prevent accidental API key leaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant