fix: preserve dynamic custom provider semantics
maintainer edit: treat arbitrary custom provider names as direct OpenAI-compatible providers, validate their api_type consistently, and avoid Pydantic instance-field warnings in fallback routing.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
|
||||
from nanobot.config.schema import Config
|
||||
@@ -47,6 +49,35 @@ def test_provider_api_type_is_openai_only() -> None:
|
||||
}
|
||||
})
|
||||
|
||||
with pytest.raises(ValueError, match="only supported"):
|
||||
Config.model_validate({
|
||||
"providers": {
|
||||
"my-company-api": {
|
||||
"apiBase": "https://example.test/v1",
|
||||
"apiType": "responses",
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
def test_custom_provider_fallback_uses_model_extra_without_pydantic_warnings() -> None:
|
||||
config = Config.model_validate({
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": "unmatched-model",
|
||||
}
|
||||
},
|
||||
"providers": {
|
||||
"my-company-api": {
|
||||
"apiBase": "https://example.test/v1",
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("error")
|
||||
assert config.get_provider_name() == "my-company-api"
|
||||
|
||||
|
||||
def test_legacy_defaults_config_without_presets_still_resolves() -> None:
|
||||
config = Config.model_validate({
|
||||
|
||||
Reference in New Issue
Block a user