mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-20 16:42:25 +00:00
fix(config): accept modelPresets root alias
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
bcc4b97183
commit
1d14c2ba40
@ -274,7 +274,10 @@ class Config(BaseSettings):
|
|||||||
api: ApiConfig = Field(default_factory=ApiConfig)
|
api: ApiConfig = Field(default_factory=ApiConfig)
|
||||||
gateway: GatewayConfig = Field(default_factory=GatewayConfig)
|
gateway: GatewayConfig = Field(default_factory=GatewayConfig)
|
||||||
tools: ToolsConfig = Field(default_factory=ToolsConfig)
|
tools: ToolsConfig = Field(default_factory=ToolsConfig)
|
||||||
model_presets: dict[str, ModelPresetConfig] = Field(default_factory=dict)
|
model_presets: dict[str, ModelPresetConfig] = Field(
|
||||||
|
default_factory=dict,
|
||||||
|
validation_alias=AliasChoices("modelPresets", "model_presets"),
|
||||||
|
)
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
def _validate_model_preset(self) -> "Config":
|
def _validate_model_preset(self) -> "Config":
|
||||||
|
|||||||
@ -39,6 +39,20 @@ def test_resolve_preset_returns_active_preset() -> None:
|
|||||||
assert resolved.reasoning_effort == "low"
|
assert resolved.reasoning_effort == "low"
|
||||||
|
|
||||||
|
|
||||||
|
def test_model_presets_accepts_camel_case_root_key() -> None:
|
||||||
|
config = Config.model_validate({
|
||||||
|
"modelPresets": {
|
||||||
|
"fast": {
|
||||||
|
"model": "openai/gpt-4.1",
|
||||||
|
"provider": "openai",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
assert config.model_presets["fast"].model == "openai/gpt-4.1"
|
||||||
|
assert config.model_presets["fast"].provider == "openai"
|
||||||
|
|
||||||
|
|
||||||
def test_resolve_preset_can_target_named_preset_without_activating() -> None:
|
def test_resolve_preset_can_target_named_preset_without_activating() -> None:
|
||||||
config = Config.model_validate({
|
config = Config.model_validate({
|
||||||
"model_presets": {
|
"model_presets": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user