mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
Merge pull request #21209 from jayy-77/fix/21193-chatgpt-codex-unsupported-params
Fix/21193 chatgpt codex unsupported params
This commit is contained in:
commit
3347fabe6b
2 changed files with 55 additions and 5 deletions
|
|
@ -73,10 +73,6 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
litellm_params,
|
||||
headers,
|
||||
)
|
||||
request.pop("max_output_tokens", None)
|
||||
request.pop("max_tokens", None)
|
||||
request.pop("max_completion_tokens", None)
|
||||
request.pop("metadata", None)
|
||||
base_instructions = get_chatgpt_default_instructions()
|
||||
existing_instructions = request.get("instructions")
|
||||
if existing_instructions:
|
||||
|
|
@ -92,7 +88,22 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
if "reasoning.encrypted_content" not in include:
|
||||
include.append("reasoning.encrypted_content")
|
||||
request["include"] = include
|
||||
return request
|
||||
|
||||
allowed_keys = {
|
||||
"model",
|
||||
"input",
|
||||
"instructions",
|
||||
"stream",
|
||||
"store",
|
||||
"include",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"reasoning",
|
||||
"previous_response_id",
|
||||
"truncation",
|
||||
}
|
||||
|
||||
return {k: v for k, v in request.items() if k in allowed_keys}
|
||||
|
||||
def transform_response_api_response(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -88,6 +88,45 @@ class TestChatGPTResponsesAPITransformation:
|
|||
"You are Codex, based on GPT-5."
|
||||
)
|
||||
|
||||
def test_chatgpt_drops_unsupported_responses_params(self):
|
||||
config = ChatGPTResponsesAPIConfig()
|
||||
request = config.transform_responses_api_request(
|
||||
model="chatgpt/gpt-5.2-codex",
|
||||
input="hi",
|
||||
response_api_optional_request_params={
|
||||
# unsupported by ChatGPT Codex
|
||||
"user": "user_123",
|
||||
"temperature": 0.2,
|
||||
"top_p": 0.9,
|
||||
"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",
|
||||
"reasoning": {"effort": "medium"},
|
||||
"tools": [{"type": "function", "function": {"name": "hello"}}],
|
||||
"tool_choice": {"type": "function", "function": {"name": "hello"}},
|
||||
},
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert "user" not in request
|
||||
assert "temperature" not in request
|
||||
assert "top_p" not in request
|
||||
assert "context_management" not in request
|
||||
assert "metadata" not in request
|
||||
assert "max_output_tokens" not in request
|
||||
assert "stream_options" not in request
|
||||
|
||||
assert request["truncation"] == "auto"
|
||||
assert request["previous_response_id"] == "resp_123"
|
||||
assert request["reasoning"] == {"effort": "medium"}
|
||||
assert request["tools"] == [{"type": "function", "function": {"name": "hello"}}]
|
||||
assert request["tool_choice"] == {"type": "function", "function": {"name": "hello"}}
|
||||
|
||||
def test_chatgpt_non_stream_sse_response_parsing(self):
|
||||
config = ChatGPTResponsesAPIConfig()
|
||||
response_payload = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue