mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-22 10:40:46 +00:00
fix(chatgpt): wrap string Responses input as user message
Co-authored-by: lark <WyJsYXJrIiwiZGVmYXVsdCJd@agents.commonly.invalid> Agent-Model: codex/gpt-6-sol/high
This commit is contained in:
parent
ecdc0f9ab9
commit
b516616aa5
2 changed files with 25 additions and 0 deletions
|
|
@ -77,6 +77,8 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
litellm_params: GenericLiteLLMParams,
|
||||
headers: dict,
|
||||
) -> dict:
|
||||
if isinstance(input, str):
|
||||
input = [{"role": "user", "content": input}]
|
||||
request: Final = super().transform_responses_api_request(
|
||||
model,
|
||||
input,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,29 @@ def local_model_cost_map(monkeypatch: pytest.MonkeyPatch) -> Generator[None, Non
|
|||
|
||||
|
||||
class TestChatGPTResponsesAPITransformation:
|
||||
@pytest.mark.parametrize(
|
||||
("input_value", "expected_input"),
|
||||
[
|
||||
("Reply with OK", [{"role": "user", "content": "Reply with OK"}]),
|
||||
("", [{"role": "user", "content": ""}]),
|
||||
(
|
||||
[{"role": "user", "content": "Reply with OK"}],
|
||||
[{"role": "user", "content": "Reply with OK"}],
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_chatgpt_wraps_string_input_for_codex_responses(self, input_value, expected_input) -> None:
|
||||
config = ChatGPTResponsesAPIConfig()
|
||||
request = config.transform_responses_api_request(
|
||||
model="chatgpt/gpt-5.3-codex",
|
||||
input=input_value,
|
||||
response_api_optional_request_params={},
|
||||
litellm_params=GenericLiteLLMParams(),
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert request["input"] == expected_input
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("requested_tier", "expected_tier"),
|
||||
[("default", "default"), ("priority", "priority"), ("fast", "priority")],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue