mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-13 03:59:12 +00:00
fix(chatgpt): leave an empty string input for the backend to reject
OpenAI's Responses API answers 400 for input "", so wrapping it into a one-message list would turn that error into a billed completion on the Codex backend. Only a non-empty string becomes the user message.
This commit is contained in:
parent
3aeca94708
commit
dfd16b0b50
2 changed files with 13 additions and 1 deletions
|
|
@ -82,7 +82,7 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
litellm_params,
|
||||
headers,
|
||||
)
|
||||
if isinstance(input, str):
|
||||
if isinstance(input, str) and input != "":
|
||||
request["input"] = [{"role": "user", "content": [{"type": "input_text", "text": input}]}]
|
||||
base_instructions: Final = get_chatgpt_default_instructions()
|
||||
existing_instructions: Final = request.get("instructions")
|
||||
|
|
|
|||
|
|
@ -226,6 +226,18 @@ class TestChatGPTResponsesAPITransformation:
|
|||
|
||||
assert request["input"] == list_input
|
||||
|
||||
def test_chatgpt_leaves_empty_string_input_for_the_backend_to_reject(self) -> None:
|
||||
config: Final = ChatGPTResponsesAPIConfig()
|
||||
request: Final = config.transform_responses_api_request(
|
||||
model="chatgpt/gpt-6.1-sol",
|
||||
input="",
|
||||
response_api_optional_request_params={},
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert request["input"] == ""
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"model_name",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue