Fix auto mode when only OpenRouter is configured
The get_available_models method in ModelProviderRegistry was only checking for providers with SUPPORTED_MODELS attribute, which OpenRouter doesn't have. This caused auto mode to fail with "No models available" error when only OpenRouter API key was configured. Added special handling for OpenRouter provider to check its _registry for available models, ensuring auto mode works correctly with OpenRouter. Added comprehensive tests to verify: - Auto mode works with only OpenRouter configured - Model restrictions are respected - Graceful handling when no providers are available - No crashes when OpenRouter lacks _registry attribute
This commit is contained in:
@@ -183,6 +183,16 @@ class ModelProviderRegistry:
|
||||
continue
|
||||
|
||||
models[model_name] = provider_type
|
||||
elif provider_type == ProviderType.OPENROUTER:
|
||||
# OpenRouter uses a registry system instead of SUPPORTED_MODELS
|
||||
if hasattr(provider, "_registry") and provider._registry:
|
||||
for model_name in provider._registry.list_models():
|
||||
# Check restrictions if enabled
|
||||
if restriction_service and not restriction_service.is_allowed(provider_type, model_name):
|
||||
logging.debug(f"Model {model_name} filtered by restrictions")
|
||||
continue
|
||||
|
||||
models[model_name] = provider_type
|
||||
|
||||
return models
|
||||
|
||||
|
||||
Reference in New Issue
Block a user