From 486c8ccc3003dd1780ff0f616b2032d1b6e3e21e Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 25 Apr 2024 20:01:36 -0700 Subject: [PATCH] fix(utils.py): handle pydantic v1 --- litellm/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index 40a8512b9a..1185380c3f 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -10194,7 +10194,10 @@ class CustomStreamWrapper: for idx, choice in enumerate(original_chunk.choices): try: if isinstance(choice, BaseModel): - choice_json = choice.model_dump() + try: + choice_json = choice.model_dump() + except Exception as e: + choice_json = choice.dict() choice_json.pop( "finish_reason", None ) # for mistral etc. which return a value in their last chunk (not-openai compatible).