mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
refactor(chatgpt): bind the coerced input instead of rebinding the parameter
Greptile flagged the parameter rebinding and the explanatory comments against the repo conventions in CLAUDE.md, which bans rebinding a function parameter (LIT011) and keeps comments to suppressions, TODOs and genuinely complex logic Bind a Final local for the coerced input rather than reassigning `input`, and drop both prose comments; the rationale lives in the commit and the PR body rather than duplicated at the call site. The mutable-ok suppression stays, since it is the allowed kind and the list is still constructed Behaviour is unchanged: 24 tests pass, and the same 4 fail with only the provider file reverted to base Signed-off-by: Alexander Chernov <alexander@chernov.it>
This commit is contained in:
parent
c9117ec6c1
commit
3ee1ccf3fd
1 changed files with 6 additions and 7 deletions
|
|
@ -66,13 +66,14 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
litellm_params: GenericLiteLLMParams,
|
||||
headers: dict,
|
||||
) -> dict:
|
||||
# The Responses API accepts a string or a list, but this backend
|
||||
# rejects a string with {"detail": "Input must be a list"}.
|
||||
if isinstance(input, str):
|
||||
input = [{"role": "user", "content": input}] # mutable-ok: the wire payload this backend requires
|
||||
coerced_input: Final = (
|
||||
[{"role": "user", "content": input}] # mutable-ok: the wire shape this backend accepts
|
||||
if isinstance(input, str)
|
||||
else input
|
||||
)
|
||||
request: Final = super().transform_responses_api_request(
|
||||
model,
|
||||
input,
|
||||
coerced_input,
|
||||
response_api_optional_request_params,
|
||||
litellm_params,
|
||||
headers,
|
||||
|
|
@ -103,8 +104,6 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
"reasoning",
|
||||
"previous_response_id",
|
||||
"truncation",
|
||||
# The chat-to-responses bridge translates response_format into
|
||||
# "text"; dropping it here discards strict schemas silently.
|
||||
"text",
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue