fix(chatgpt): normalize Responses string input

This commit is contained in:
Chase Cai 2026-08-25 16:54:18 +08:00
parent 31a67561ab
commit d34697d7d0

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: