From d282e7eaac853f5f4a475f211c66cc12d6dc5af9 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 2 Sep 2025 12:38:05 -0700 Subject: [PATCH] fix: handle non-str case --- litellm/llms/ollama/completion/transformation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/llms/ollama/completion/transformation.py b/litellm/llms/ollama/completion/transformation.py index 5689864017f..4a491c88963 100644 --- a/litellm/llms/ollama/completion/transformation.py +++ b/litellm/llms/ollama/completion/transformation.py @@ -331,8 +331,10 @@ class OllamaConfig(BaseConfig): response_text = response_json.get("response", "") content = None reasoning_content = None - if response_text is not None: + if response_text is not None and isinstance(response_text, str): reasoning_content, content = _parse_content_for_reasoning(response_text) + else: + content = response_text # type: ignore model_response.choices[0].message.content = content # type: ignore model_response.choices[0].message.reasoning_content = reasoning_content # type: ignore model_response.created = int(time.time())