mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
fix: map Chat Completion file type to Responses API input_file
When bridging /chat/completions to the Responses API, content items with
type 'file' were falling through to the default handler and being
stringified as input_text. This caused the model to receive the Python
dict representation as plain text instead of the actual file content.
Add explicit handling for type 'file' that correctly maps:
{"type": "file", "file": {"file_data": "...", "filename": "..."}}
to:
{"type": "input_file", "file_data": "...", "filename": "..."}
Fixes BerriAI/litellm#23588
This commit is contained in:
parent
25ee2fb3f9
commit
0bdfd95ad8
1 changed files with 14 additions and 0 deletions
|
|
@ -693,6 +693,20 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):
|
|||
verbose_logger.debug(
|
||||
f"Chat provider: image -> {converted}"
|
||||
)
|
||||
elif item_type == "file":
|
||||
# Map Chat Completion file to Responses API input_file
|
||||
# {"type": "file", "file": {"file_data": "...", "filename": "..."}}
|
||||
# -> {"type": "input_file", "file_data": "...", "filename": "..."}
|
||||
file_data = item.get("file", {})
|
||||
converted = {"type": "input_file"}
|
||||
if isinstance(file_data, dict):
|
||||
for key in ["file_id", "file_data", "filename"]:
|
||||
if key in file_data:
|
||||
converted[key] = file_data[key]
|
||||
result.append(converted)
|
||||
verbose_logger.debug(
|
||||
f"Chat provider: file -> {converted}"
|
||||
)
|
||||
elif item_type in [
|
||||
"input_text",
|
||||
"input_image",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue