Skip to content

feature: add domainMapping in config, to allow for localModels#5

Merged
Davincible merged 5 commits intoDavincible:masterfrom
mihaisavezi:feat/handle-local-models
Aug 16, 2025
Merged

feature: add domainMapping in config, to allow for localModels#5
Davincible merged 5 commits intoDavincible:masterfrom
mihaisavezi:feat/handle-local-models

Conversation

@mihaisavezi
Copy link
Copy Markdown
Contributor

No description provided.

@mihaisavezi
Copy link
Copy Markdown
Contributor Author

fixes #4

🗺️ Add Configuration-Based Domain Mappings Feature
Problem Solved
Issue: Local model servers (localhost, 127.0.0.1) couldn't be used because of hardcoded domain mappings in the provider registry

Error: API Error: 400 provider not found: no provider implementation for domain: localhost

Root Cause: The registry only supported predefined domains (api.openai.com, openrouter.ai, etc.)

Solution Implemented

  1. Configuration Structure Enhancement
    Added DomainMappings map[string]string field to Config struct

Supports YAML configuration format:

# Route local LM Studio to use OpenAI transformations
domain_mappings:
  localhost: openai

providers:
  - name: local-lmstudio
    url: "http://localhost:1234/v1/chat/completions"
    api_key: "not-needed"

router:
  default: "local-lmstudio,qwen/qwen3-coder-30b"
  1. Provider Registry Updates
    Enhanced Registry struct with dynamic domain mapping support

Added SetDomainMappings() method to accept config-based mappings

Modified GetByDomain() to check config mappings first, then fall back to hardcoded mappings

Priority System: Configuration mappings override hardcoded ones

  1. Server Integration
    Updated server initialization to pass domain mappings from config to registry

Automatic configuration loading and application on startup

  1. Command Line Interface Enhancements
    cco config show:

Now displays Domain Mappings section

Shows configured domain → provider mappings

cco config validate:

Validates that mapped providers exist (both configured and built-in)

Provides detailed error messages for invalid mappings

cco config generate:

Includes domain mappings in example configuration

Provides local model setup examples

  1. Testing Infrastructure
    Added comprehensive unit tests for YAML parsing

Registry integration tests for domain mapping functionality

Configuration command tests

Fixed test expectations to account for new local-lmstudio provider

# Route local LM Studio to use OpenAI transformations
domain_mappings:
  localhost: openai

providers:
  - name: local-lmstudio
    url: "http://localhost:1234/v1/chat/completions"
    api_key: "not-needed"

router:
  default: "local-lmstudio,qwen/qwen3-coder-30b"

@Davincible
Copy link
Copy Markdown
Owner

Thanks for the contributions!

@Davincible Davincible merged commit 467a189 into Davincible:master Aug 16, 2025
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.

2 participants