mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
Merge pull request #24363 from HeMuling/fix-24356-chatgpt-responses-allowlist-clean
[#24356] Preserve text and parallel_tool_calls in ChatGPT responses allowlist
This commit is contained in:
commit
9da2f40760
2 changed files with 63 additions and 4 deletions
|
|
@ -96,9 +96,11 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
"stream",
|
||||
"store",
|
||||
"include",
|
||||
"parallel_tool_calls",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"reasoning",
|
||||
"text",
|
||||
"previous_response_id",
|
||||
"truncation",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,10 +103,58 @@ class TestChatGPTResponsesAPITransformation:
|
|||
|
||||
assert request["stream"] is True
|
||||
assert "reasoning.encrypted_content" in request["include"]
|
||||
assert request["instructions"].startswith(
|
||||
"You are Codex, based on GPT-5."
|
||||
assert request["instructions"].startswith("You are Codex, based on GPT-5.")
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"text_value",
|
||||
[
|
||||
{
|
||||
"format": {
|
||||
"type": "json_schema",
|
||||
"name": "answer_schema",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {"answer": {"type": "string"}},
|
||||
"required": ["answer"],
|
||||
"additionalProperties": False,
|
||||
},
|
||||
"strict": True,
|
||||
}
|
||||
},
|
||||
{"format": {"type": "json_object"}},
|
||||
{"format": {"type": "text"}},
|
||||
],
|
||||
ids=["json_schema", "json_object", "text"],
|
||||
)
|
||||
def test_chatgpt_preserves_text_param(self, text_value):
|
||||
config = ChatGPTResponsesAPIConfig()
|
||||
request = config.transform_responses_api_request(
|
||||
model="chatgpt/gpt-5.2-codex",
|
||||
input="hi",
|
||||
response_api_optional_request_params={"text": text_value},
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert request["text"] == text_value
|
||||
assert request["stream"] is True
|
||||
assert "reasoning.encrypted_content" in request["include"]
|
||||
assert request["instructions"].startswith("You are Codex, based on GPT-5.")
|
||||
|
||||
def test_chatgpt_preserves_parallel_tool_calls(self):
|
||||
config = ChatGPTResponsesAPIConfig()
|
||||
request = config.transform_responses_api_request(
|
||||
model="chatgpt/gpt-5.2-codex",
|
||||
input="hi",
|
||||
response_api_optional_request_params={"parallel_tool_calls": False},
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert request["parallel_tool_calls"] is False
|
||||
assert request["stream"] is True
|
||||
assert "reasoning.encrypted_content" in request["include"]
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model_name",
|
||||
[
|
||||
|
|
@ -124,14 +172,18 @@ class TestChatGPTResponsesAPITransformation:
|
|||
"user": "user_123",
|
||||
"temperature": 0.2,
|
||||
"top_p": 0.9,
|
||||
"context_management": [{"type": "compaction", "compact_threshold": 200000}],
|
||||
"context_management": [
|
||||
{"type": "compaction", "compact_threshold": 200000}
|
||||
],
|
||||
"metadata": {"foo": "bar"},
|
||||
"max_output_tokens": 123,
|
||||
"stream_options": {"include_usage": True},
|
||||
# supported and should be preserved
|
||||
"truncation": "auto",
|
||||
"previous_response_id": "resp_123",
|
||||
"parallel_tool_calls": False,
|
||||
"reasoning": {"effort": "medium"},
|
||||
"text": {"format": {"type": "json_object"}},
|
||||
"tools": [{"type": "function", "function": {"name": "hello"}}],
|
||||
"tool_choice": {"type": "function", "function": {"name": "hello"}},
|
||||
},
|
||||
|
|
@ -149,9 +201,14 @@ class TestChatGPTResponsesAPITransformation:
|
|||
|
||||
assert request["truncation"] == "auto"
|
||||
assert request["previous_response_id"] == "resp_123"
|
||||
assert request["parallel_tool_calls"] is False
|
||||
assert request["reasoning"] == {"effort": "medium"}
|
||||
assert request["text"] == {"format": {"type": "json_object"}}
|
||||
assert request["tools"] == [{"type": "function", "function": {"name": "hello"}}]
|
||||
assert request["tool_choice"] == {"type": "function", "function": {"name": "hello"}}
|
||||
assert request["tool_choice"] == {
|
||||
"type": "function",
|
||||
"function": {"name": "hello"},
|
||||
}
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("model_name", "response_model"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue