fix(ollama): enhance image data handling in content blocks for v1 support

This commit is contained in:
Mason Daugherty
2025-08-22 11:10:05 -04:00
parent 96b7f71f4a
commit a81823da2d

View File

@@ -269,8 +269,12 @@ def _lc_tool_call_to_openai_tool_call(tool_call_: ToolCall) -> dict:
def _get_image_from_data_content_block(block: dict) -> str:
"""Format standard data content block to format expected by Ollama."""
if block["type"] == "image":
if block["source_type"] == "base64":
if block.get("source_type") == "base64":
# v0
return block["data"]
if block.get("base64") is not None:
# v1
return block["base64"]
error_message = "Image data only supported through in-line base64 format."
raise ValueError(error_message)