fix(provider): accept canonical and alias provider names consistently

This commit is contained in:
Xubin Ren
2026-03-24 03:03:59 +00:00
parent d454386f32
commit 14763a6ad1
3 changed files with 39 additions and 5 deletions
+6 -3
View File
@@ -165,12 +165,15 @@ class Config(BaseSettings):
self, model: str | None = None
) -> tuple["ProviderConfig | None", str | None]:
"""Match provider config and its registry name. Returns (config, spec_name)."""
from nanobot.providers.registry import PROVIDERS
from nanobot.providers.registry import PROVIDERS, find_by_name
forced = self.agents.defaults.provider
if forced != "auto":
p = getattr(self.providers, forced, None)
return (p, forced) if p else (None, None)
spec = find_by_name(forced)
if spec:
p = getattr(self.providers, spec.name, None)
return (p, spec.name) if p else (None, None)
return None, None
model_lower = (model or self.agents.defaults.model).lower()
model_normalized = model_lower.replace("-", "_")