diff --git a/dist/litellm-0.1.644-py3-none-any.whl b/dist/litellm-0.1.644-py3-none-any.whl new file mode 100644 index 000000000..4979a2db4 Binary files /dev/null and b/dist/litellm-0.1.644-py3-none-any.whl differ diff --git a/dist/litellm-0.1.644.tar.gz b/dist/litellm-0.1.644.tar.gz new file mode 100644 index 000000000..3e9d956bb Binary files /dev/null and b/dist/litellm-0.1.644.tar.gz differ diff --git a/litellm/__pycache__/__init__.cpython-311.pyc b/litellm/__pycache__/__init__.cpython-311.pyc index 58688f27f..4dd38f2b1 100644 Binary files a/litellm/__pycache__/__init__.cpython-311.pyc and b/litellm/__pycache__/__init__.cpython-311.pyc differ diff --git a/litellm/__pycache__/main.cpython-311.pyc b/litellm/__pycache__/main.cpython-311.pyc index fcec8b4e6..48f542741 100644 Binary files a/litellm/__pycache__/main.cpython-311.pyc and b/litellm/__pycache__/main.cpython-311.pyc differ diff --git a/litellm/__pycache__/utils.cpython-311.pyc b/litellm/__pycache__/utils.cpython-311.pyc index 189cf63d1..8ffdbc4ea 100644 Binary files a/litellm/__pycache__/utils.cpython-311.pyc and b/litellm/__pycache__/utils.cpython-311.pyc differ diff --git a/litellm/tests/test_streaming.py b/litellm/tests/test_streaming.py index 0ec8563ab..1423ff2a6 100644 --- a/litellm/tests/test_streaming.py +++ b/litellm/tests/test_streaming.py @@ -121,13 +121,14 @@ def test_openai_chat_completion_call(): print(chunk) if "content" in chunk["choices"][0]["delta"]: complete_response += chunk["choices"][0]["delta"]["content"] - if complete_response == "": + print(f'complete_chunk: {complete_response}') + if complete_response.strip() == "": raise Exception("Empty response received") except: print(f"error occurred: {traceback.format_exc()}") pass -# test_openai_chat_completion_call() +test_openai_chat_completion_call() async def completion_call(): try: response = completion( diff --git a/litellm/utils.py b/litellm/utils.py index 4c31c774a..b9d636506 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2451,7 +2451,11 @@ class CustomStreamWrapper: def __next__(self): try: +<<<<<<< HEAD completion_obj = {"content": "", "role": ""} # default to role being assistant +======= + completion_obj = {"content": ""} # default to role being assistant +>>>>>>> 31d771b (fix streaming error) if self.model in litellm.anthropic_models: chunk = next(self.completion_stream) completion_obj["content"] = self.handle_anthropic_chunk(chunk) @@ -2496,15 +2500,12 @@ class CustomStreamWrapper: else: # openai chat/azure models chunk = next(self.completion_stream) completion_obj["content"] = chunk["choices"][0]["delta"]["content"] - completion_obj["role"] = chunk["choices"][0]["delta"]["role"] - # return chunk # open ai returns finish_reason, we should just return the openai chunk - - #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 model_response = ModelResponse(stream=True) - model_response.choices[0].delta = completion_obj + model_response.choices[0].delta.content = completion_obj["content"] return model_response except StopIteration: raise StopIteration diff --git a/pyproject.toml b/pyproject.toml index d2f571150..10039fe8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.644" +version = "0.1.645" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"