mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(chatgpt): normalize Responses string input
This commit is contained in:
parent
31a67561ab
commit
d34697d7d0
1 changed files with 13 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue