This commit is contained in:
Chase Cai 2026-08-26 21:03:17 -04:00 committed by GitHub
commit 2e16942f69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View file

@ -38,6 +38,18 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
def custom_llm_provider(self) -> LlmProviders:
return LlmProviders.CHATGPT
@staticmethod
def _normalize_string_input(request: dict) -> None:
"""Convert Responses API string shorthand to ChatGPT's message-list form."""
request_input = request.get("input")
if isinstance(request_input, str):
request["input"] = [
{
"role": "user",
"content": [{"type": "input_text", "text": request_input}],
}
]
def validate_environment(
self,
headers: dict,
@ -73,6 +85,7 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
litellm_params,
headers,
)
self._normalize_string_input(request)
base_instructions: Final = get_chatgpt_default_instructions()
existing_instructions: Final = request.get("instructions")
if existing_instructions:

View file

@ -101,9 +101,38 @@ class TestChatGPTResponsesAPITransformation:
)
assert request["stream"] is True
assert request["input"] == [
{
"role": "user",
"content": [{"type": "input_text", "text": "hi"}],
}
]
assert "reasoning.encrypted_content" in request["include"]
assert request["instructions"].startswith("You are Codex, based on GPT-5.")
def test_chatgpt_normalizes_string_input_with_tools(self):
config = ChatGPTResponsesAPIConfig()
tools = [{"type": "function", "name": "echo", "parameters": {}}]
request = config.transform_responses_api_request(
model="chatgpt/gpt-5.3-codex",
input="Call echo with ping.",
response_api_optional_request_params={
"tools": tools,
"tool_choice": "required",
},
litellm_params=GenericLiteLLMParams(),
headers={},
)
assert request["input"] == [
{
"role": "user",
"content": [{"type": "input_text", "text": "Call echo with ping."}],
}
]
assert request["tools"] == tools
assert request["tool_choice"] == "required"
@pytest.mark.parametrize(
"model_name",
[