mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
fixing azure bad request error strategies
This commit is contained in:
parent
11f9b47710
commit
d64ea0ee30
2 changed files with 6 additions and 5 deletions
|
|
@ -132,14 +132,15 @@ class AzureOpenAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
new_tools.append(tool)
|
||||
response_api_optional_request_params["tools"] = new_tools
|
||||
|
||||
# Azure Responses API expects context_management as an object with "edits" key,
|
||||
# Azure Responses API expects context_management as an object with "strategies" key,
|
||||
# but OpenAI/litellm uses array format [{"type": "compaction", "compact_threshold": N}].
|
||||
# See: "Invalid type for 'context_management': expected an object, but got an array instead."
|
||||
# See: "Missing required parameter: 'context_management.strategies'."
|
||||
if "context_management" in response_api_optional_request_params:
|
||||
cm = response_api_optional_request_params["context_management"]
|
||||
if isinstance(cm, list):
|
||||
response_api_optional_request_params["context_management"] = {
|
||||
"edits": cm
|
||||
"strategies": cm
|
||||
}
|
||||
|
||||
return super().transform_responses_api_request(
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ class TestAzureResponsesAPIConfig:
|
|||
def test_azure_responses_api_context_management_array_to_object(self):
|
||||
"""Test that context_management array is converted to object format for Azure.
|
||||
|
||||
Azure Responses API expects context_management as an object with 'edits' key,
|
||||
Azure Responses API expects context_management as an object with 'strategies' key,
|
||||
but litellm/OpenAI uses array format [{"type": "compaction", "compact_threshold": N}].
|
||||
"""
|
||||
from litellm.types.router import GenericLiteLLMParams
|
||||
|
|
@ -517,14 +517,14 @@ class TestAzureResponsesAPIConfig:
|
|||
|
||||
assert "context_management" in result
|
||||
assert result["context_management"] == {
|
||||
"edits": [{"type": "compaction", "compact_threshold": 200000}]
|
||||
"strategies": [{"type": "compaction", "compact_threshold": 200000}]
|
||||
}
|
||||
|
||||
def test_azure_responses_api_context_management_already_object(self):
|
||||
"""Test that context_management already in object format is passed through."""
|
||||
from litellm.types.router import GenericLiteLLMParams
|
||||
|
||||
context_management = {"edits": [{"type": "compaction", "compact_threshold": 200000}]}
|
||||
context_management = {"strategies": [{"type": "compaction", "compact_threshold": 200000}]}
|
||||
response_api_params = {"context_management": context_management}
|
||||
litellm_params = GenericLiteLLMParams()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue