mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(anthropic-adapter): preserve image blocks in tool results during format conversion
When converting Anthropic /v1/messages to OpenAI /v1/chat/completions format, single-image tool results had their image data stored as a plain URL string in ChatCompletionToolMessage.content, instead of a structured ChatCompletionImageObject list. This caused downstream models (e.g. vLLM) to treat the base64 data URI as plain text, making image recognition fail. The multi-item tool result path already handled this correctly by creating a ChatCompletionImageObject. This fix applies the same pattern to the single-item case.
This commit is contained in:
parent
9e6d2d2069
commit
b510628bc2
1 changed files with 6 additions and 1 deletions
|
|
@ -480,7 +480,12 @@ class LiteLLMAnthropicMessagesAdapter:
|
|||
tool_call_id=content.get(
|
||||
"tool_use_id", ""
|
||||
),
|
||||
content=openai_image_url,
|
||||
content=[ChatCompletionImageObject(
|
||||
type="image_url",
|
||||
image_url=ChatCompletionImageUrlObject(
|
||||
url=openai_image_url
|
||||
),
|
||||
)],
|
||||
)
|
||||
self._add_cache_control_if_applicable(
|
||||
content, tool_result, model
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue