fix: coalesce None thinking_style to empty string in provider creation
ProviderConfig.thinking_style defaults to None (Optional field), but create_dynamic_spec expects a string. Coalesce None to "" at all call sites (factory.py, settings_api.py) and fix the test assertion to expect None from the config default.
This commit is contained in:
@@ -54,7 +54,7 @@ def _make_provider_core(
|
||||
if provider_name and not spec and p:
|
||||
if not p.api_base:
|
||||
raise ValueError(f"Provider '{provider_name}' requires api_base in config.")
|
||||
spec = create_dynamic_spec(provider_name, thinking_style=p.thinking_style if p else "")
|
||||
spec = create_dynamic_spec(provider_name, thinking_style=(p.thinking_style or "") if p else "")
|
||||
if spec and spec.is_transcription_only:
|
||||
raise ValueError(f"Provider '{provider_name}' only supports transcription.")
|
||||
backend = spec.backend if spec else "openai_compat"
|
||||
|
||||
@@ -359,7 +359,7 @@ def _resolve_settings_provider(
|
||||
normalized = provider_name.replace("-", "_")
|
||||
for extra_name, provider_config in _dynamic_provider_items(config):
|
||||
if provider_name == extra_name or normalized == extra_name.replace("-", "_"):
|
||||
return create_dynamic_spec(extra_name, thinking_style=provider_config.thinking_style), extra_name, provider_config
|
||||
return create_dynamic_spec(extra_name, thinking_style=(provider_config.thinking_style or "")), extra_name, provider_config
|
||||
return None
|
||||
|
||||
|
||||
@@ -739,7 +739,7 @@ def settings_payload(
|
||||
providers.append(
|
||||
_provider_settings_row(
|
||||
provider_key,
|
||||
create_dynamic_spec(provider_key, thinking_style=provider_config.thinking_style),
|
||||
create_dynamic_spec(provider_key, thinking_style=(provider_config.thinking_style or "")),
|
||||
provider_config,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ class TestCustomProviderThinkingStyle:
|
||||
|
||||
def test_default_thinking_style_is_empty(self) -> None:
|
||||
cfg = ProviderConfig()
|
||||
assert cfg.thinking_style == ""
|
||||
assert cfg.thinking_style is None
|
||||
|
||||
def test_create_dynamic_spec_default(self) -> None:
|
||||
spec = create_dynamic_spec("custom")
|
||||
|
||||
Reference in New Issue
Block a user