From 60cc3d6b309c3059474c6bd1483a0399bc1422bf Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 30 Jan 2024 15:35:23 -0800 Subject: [PATCH] fix(utils.py): fix streaming delta content being none edge-case --- litellm/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index 3aaf5351492..8f00c115dbb 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -7487,7 +7487,10 @@ class CustomStreamWrapper: logprobs = None original_chunk = None # this is used for function/tool calling if len(str_line.choices) > 0: - if str_line.choices[0].delta.content is not None: + if ( + str_line.choices[0].delta is not None + and str_line.choices[0].delta.content is not None + ): text = str_line.choices[0].delta.content else: # function/tool calling chunk - when content is None. in this case we just return the original chunk from openai original_chunk = str_line