From f1270a7c782960c3029d2da1dac7bbf043de7755 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 22 Dec 2023 12:23:42 +0530 Subject: [PATCH] fix(utils.py): handle ollama yielding a dict --- litellm/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index 87c543fc8..a63b9aeda 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -5811,7 +5811,10 @@ class CustomStreamWrapper: def handle_ollama_stream(self, chunk): try: - json_chunk = json.loads(chunk) + if isinstance(chunk, dict): + json_chunk = chunk + else: + json_chunk = json.loads(chunk) if "error" in json_chunk: raise Exception(f"Ollama Error - {json_chunk}")