Skip to content

Commit 063b83c

Browse files
handle list of dicts in OllamaChatConfig.transform_request()
1 parent 12bae8f commit 063b83c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

litellm/llms/ollama/chat/transformation.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,22 @@ def transform_request(
277277
m, BaseModel
278278
): # avoid message serialization issues - https://github.com/BerriAI/litellm/issues/5319
279279
m = m.model_dump(exclude_none=True)
280+
281+
content = m.get("content")
282+
if content is not None and isinstance(content, list):
283+
for content_item in content:
284+
if "text" in content_item:
285+
new_messages.append({
286+
"role": m["role"],
287+
"content": content_item["text"]
288+
})
289+
else:
290+
verbose_logger.warning(
291+
'Dropping item in message["content"] with keys %s. Only items with a "text" key are supported.',
292+
content_item.keys()
293+
)
294+
continue
295+
280296
tool_calls = m.get("tool_calls")
281297
if tool_calls is not None and isinstance(tool_calls, list):
282298
new_tools: List[OllamaToolCall] = []

0 commit comments

Comments
 (0)