fix(responses): add models to TypedDict and fix test state corruption

- Add 'models' field to ResponsesAPIOptionalRequestParams TypedDict so
  the Perplexity fallback chain param is not silently filtered out by
  get_requested_response_api_optional_param(). Verified with curl that
  Perplexity's models param works (tries models in order until one
  succeeds).
- Fix test_python_class_takes_priority_over_json: save and restore the
  original JSONProviderRegistry entry instead of deleting it, preventing
  state corruption for subsequent tests.
This commit is contained in:
Chesars 2026-03-10 19:19:07 -03:00
parent 23e4f00eb3
commit e223b29d31
2 changed files with 7 additions and 1 deletions

View file

@ -1155,6 +1155,8 @@ class ResponsesAPIOptionalRequestParams(TypedDict, total=False):
] # Number of partial images to generate (1-3) for streaming image generation
context_management: Optional[List[ContextManagementEntry]]
"""Context management configuration. E.g. [{\"type\": \"compaction\", \"compact_threshold\": 200000}] for server-side compaction (minimum 1000)."""
models: Optional[List[str]]
"""Model fallback chain (e.g. Perplexity). Models are tried in order until one succeeds."""
class ResponsesAPIRequestParams(ResponsesAPIOptionalRequestParams, total=False):

View file

@ -325,6 +325,7 @@ class TestProviderConfigManagerResponsesAPI:
"supported_endpoints": ["/v1/responses"],
},
)
original = JSONProviderRegistry._providers.get("perplexity")
JSONProviderRegistry._providers["perplexity"] = test_config
try:
config = ProviderConfigManager.get_provider_responses_api_config(
@ -334,4 +335,7 @@ class TestProviderConfigManagerResponsesAPI:
# Should be the Python class, not the JSON-generated one
assert isinstance(config, PerplexityResponsesConfig)
finally:
del JSONProviderRegistry._providers["perplexity"]
if original is not None:
JSONProviderRegistry._providers["perplexity"] = original
else:
del JSONProviderRegistry._providers["perplexity"]