Skip to content

Conversation

@maeste
Copy link

@maeste maeste commented Dec 3, 2025

Implement provider abstraction layer supporting three modes:

  • OpenRouter mode: Cloud-based models via OpenRouter API (existing)
  • Ollama mode: Local models via Ollama server (new)
  • Mixed mode: Combination of local and cloud models (new)

Motivation:
Test whether the council deliberation approach provides benefits
for small local models. Hypothesis: collaborative reasoning and
peer review may compensate for individual model limitations.
Mixed mode enables experiments combining cost-effective local
models with premium SOTA models for optimal cost/quality balance.

Implementation:

  • Provider abstraction layer (base.py, factory pattern)
  • OpenRouterProvider (refactored from openrouter.py)
  • OllamaProvider (new, supports local Ollama server)
  • Intelligent routing with cross-provider parallel execution
  • Model spec format: simple ("model") or prefixed ("provider:model")
  • Backward compatible - existing configs work unchanged

Files changed:

  • backend/providers/ - New provider abstraction system
  • backend/council.py - Updated import (1 line change)
  • backend/config.py - Added LLM_PROVIDER and OLLAMA_BASE_URL
  • .env.example - Configuration template for all modes
  • README.md - Provider setup and usage documentation
  • TROUBLESHOOTING.md - Common issues and solutions
  • CLAUDE.md - Architecture decisions and migration guide

All existing functionality preserved. Zero-config local mode
requires no API keys. Mixed mode optimizes for cost efficiency.

🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]

This commit message:

  • Subject line: Clear, concise action statement
  • Overview: What was implemented
  • Motivation section: Your reasoning about testing local models and the council hypothesis
  • Implementation section: Key technical details
  • Files changed: Overview of modifications
  • Summary: Benefits and features

  Implement provider abstraction layer supporting three modes:
  - OpenRouter mode: Cloud-based models via OpenRouter API (existing)
  - Ollama mode: Local models via Ollama server (new)
  - Mixed mode: Combination of local and cloud models (new)

  Motivation:
  Test whether the council deliberation approach provides benefits
  for small local models. Hypothesis: collaborative reasoning and
  peer review may compensate for individual model limitations.
  Mixed mode enables experiments combining cost-effective local
  models with premium SOTA models for optimal cost/quality balance.

  Implementation:
  - Provider abstraction layer (base.py, factory pattern)
  - OpenRouterProvider (refactored from openrouter.py)
  - OllamaProvider (new, supports local Ollama server)
  - Intelligent routing with cross-provider parallel execution
  - Model spec format: simple ("model") or prefixed ("provider:model")
  - Backward compatible - existing configs work unchanged

  Files changed:
  - backend/providers/ - New provider abstraction system
  - backend/council.py - Updated import (1 line change)
  - backend/config.py - Added LLM_PROVIDER and OLLAMA_BASE_URL
  - .env.example - Configuration template for all modes
  - README.md - Provider setup and usage documentation
  - TROUBLESHOOTING.md - Common issues and solutions
  - CLAUDE.md - Architecture decisions and migration guide

  All existing functionality preserved. Zero-config local mode
  requires no API keys. Mixed mode optimizes for cost efficiency.

  🤖 Generated with Claude Code
  Co-Authored-By: Claude <[email protected]>

  This commit message:
  - Subject line: Clear, concise action statement
  - Overview: What was implemented
  - Motivation section: Your reasoning about testing local models and the council hypothesis
  - Implementation section: Key technical details
  - Files changed: Overview of modifications
  - Summary: Benefits and features
Copilot AI added a commit to danielmerja/llm-council that referenced this pull request Dec 8, 2025
…uter + Mixed mode)

- Provider abstraction layer with factory pattern
- Support for local Ollama models (100% offline operation)
- Mixed mode for combining local and cloud models
- Backward compatible with existing OpenRouter setup
- New backend/providers/ directory with base, ollama, and openrouter providers
- .env.example with comprehensive configuration examples
- Enables cost-effective local model experimentation
Th0mYT added a commit to Th0mYT/llm-council that referenced this pull request Dec 8, 2025
Implements a comprehensive provider abstraction system enabling flexible
LLM backend configuration with support for cloud and local models.

## Features

### Provider Support
- OpenRouter: Access to GPT-4, Claude, Gemini, and 200+ models
- Ollama: Local models with proper API integration
- LMStudio: Local models via OpenAI-compatible interface

### Flexible Configuration
- Model-level provider specification: "provider:model" format
- Mixed mode: Combine any providers (e.g., local council + cloud chairman)
- Backward compatible: Existing configs continue to work

### Architecture
- Provider abstraction layer (backend/providers/)
- Factory pattern for automatic model routing
- Parallel execution across multiple providers
- Graceful degradation on provider failures

## New Files
- backend/providers/ - Complete provider abstraction
  - base.py: Abstract Provider interface
  - openrouter.py: Cloud provider implementation
  - ollama.py: Local Ollama provider (fixed API usage)
  - lmstudio.py: Local LMStudio provider
  - factory.py: Smart routing and provider management
- .env.example: Configuration examples for all modes
- SETUP.md: Comprehensive setup guide
- requirements.txt: Easy dependency installation
- test_providers.py: Provider validation script

## Modified Files
- backend/config.py: New configuration system with provider settings
- backend/council.py: Refactored to use ProviderFactory
- CLAUDE.md: Updated architecture documentation
- .gitignore: Added IDE directories

## Configuration Examples

Cloud only:
  COUNCIL_MODELS = ["openai/gpt-4", "anthropic/claude-sonnet-4"]

Local only:
  COUNCIL_MODELS = ["ollama:llama2", "ollama:mistral"]

Mixed mode:
  COUNCIL_MODELS = ["ollama:llama2", "openrouter:gpt-4"]
  CHAIRMAN_MODEL = "openrouter:anthropic/claude-sonnet-4"

## Testing
- All provider tests passing
- Backend starts without errors
- Backward compatible with existing installations

## Advantages Over PR karpathy#76
- LMStudio support (not just Ollama)
- Model-level provider specification (more flexible)
- Correct Ollama API implementation
- Comprehensive documentation and testing
- Factory pattern for cleaner architecture

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
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