From 56853aca530dcb5ace7961ea742dca12db325f75 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 2 Sep 2023 16:10:19 -0700 Subject: [PATCH] fix azure streaming --- litellm/__pycache__/utils.cpython-311.pyc | Bin 83241 -> 83364 bytes litellm/utils.py | 9 ++++++--- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/litellm/__pycache__/utils.cpython-311.pyc b/litellm/__pycache__/utils.cpython-311.pyc index ce9ef07de65a501368311a1c7a89eb649d262a40..2826ca27fd6bbbeb5fc03e8ca28e312cbbe002a9 100644 GIT binary patch delta 502 zcmZurOGq106n*Etc}ZqEL(pMHW0fdssG*_;7eyB(RZt9dQxHNyC{1_mW=u&z;%_0S z2yW!La4|wbq%MTgKG2O&=prkHETrJ3qHaelbe4UQYP;~lJ(qLNJ(s()%s;MhYumC6 zqUzxAy5P@SUo2e23{444_4TOOilSRgMo|AKPYV16`M~m|gs#ZAmsJZMRq%rs-n=co z@=`THgLtlE`dObMb0nZlcTeobjYQRM_p?%b`N@ie}p-%2u2!KVo6-S<@i@j>`Z*>sQENjKgEms#%AZ2YvE1^V$ z;UI@5G2vi_daL5tfekLs9dthMgvv~D1+60P;&G%qs`#bMy7*2Wnb222^Xhm$J2Fr<&A$v1PPMU6_@$PrfQkB$wp${^1X@ic`7F_ge(yp+Eam_}UV zZb0t9l=BbKMe$mGYQZ|kdzo#A&miQ_6gC-rIh)2@6#HK@Km=!!KEXS)Z<3-jAot_d PjsEL@cbE%*7)yTu>A`|f delta 391 zcmZ3|&APISm3KKWFBbz4yxa9T#jlZfD=*_Sj>*|aIJwM#g3}pl7*iN02WE;*m*ZrV z64zw)D{=&i7cl{eTdXOmIVFijY7Em;I2o%IWPoA~3^({iCPZH0mtVkmgFn;~Hj0zU@zV89y*G=4`*p<%nz{pTy0MrcyO^nkcL>avq zC8sYDWvmmt#T#6bU*K7iT9jClnV+Z0GTlOqQI)lr1*m*_h8Uv`n-)6*L-ED!v&0yW zF{yrFV&qh~D< nMvRPXj1RWgS}^AF7)CQOs(xU=PJRT7e?gY5W0@}P%Ge12N^5Iz diff --git a/litellm/utils.py b/litellm/utils.py index 271aa0257b9..f8bd4bb5627 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1801,7 +1801,10 @@ class CustomStreamWrapper: raise ValueError(f"Unable to parse response. Original response: {chunk}") def handle_openai_chat_completion_chunk(self, chunk): - return chunk["choices"][0]["delta"]["content"] + try: + return chunk["choices"][0]["delta"]["content"] + except: + return "" def handle_baseten_chunk(self, chunk): try: @@ -1869,12 +1872,12 @@ class CustomStreamWrapper: else: # openai chat/azure models chunk = next(self.completion_stream) completion_obj["content"] = self.handle_openai_chat_completion_chunk(chunk) - + # LOGGING threading.Thread(target=self.logging_obj.success_handler, args=(completion_obj,)).start() # return this for all models return {"choices": [{"delta": completion_obj}]} - except: + except Exception as e: raise StopIteration async def __anext__(self): diff --git a/pyproject.toml b/pyproject.toml index 321de8908b9..0b0633f23e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.517" +version = "0.1.518" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"