diff --git a/dist/litellm-0.1.647-py3-none-any.whl b/dist/litellm-0.1.647-py3-none-any.whl new file mode 100644 index 000000000..a50b70b3b Binary files /dev/null and b/dist/litellm-0.1.647-py3-none-any.whl differ diff --git a/dist/litellm-0.1.647.tar.gz b/dist/litellm-0.1.647.tar.gz new file mode 100644 index 000000000..b51f80f93 Binary files /dev/null and b/dist/litellm-0.1.647.tar.gz differ diff --git a/dist/litellm-0.1.648-py3-none-any.whl b/dist/litellm-0.1.648-py3-none-any.whl new file mode 100644 index 000000000..01202543b Binary files /dev/null and b/dist/litellm-0.1.648-py3-none-any.whl differ diff --git a/dist/litellm-0.1.648.tar.gz b/dist/litellm-0.1.648.tar.gz new file mode 100644 index 000000000..29daa5693 Binary files /dev/null and b/dist/litellm-0.1.648.tar.gz differ diff --git a/dist/litellm-0.1.649-py3-none-any.whl b/dist/litellm-0.1.649-py3-none-any.whl new file mode 100644 index 000000000..5f303516c Binary files /dev/null and b/dist/litellm-0.1.649-py3-none-any.whl differ diff --git a/dist/litellm-0.1.649.tar.gz b/dist/litellm-0.1.649.tar.gz new file mode 100644 index 000000000..9f81924cb Binary files /dev/null and b/dist/litellm-0.1.649.tar.gz differ diff --git a/dist/litellm-0.1.650-py3-none-any.whl b/dist/litellm-0.1.650-py3-none-any.whl new file mode 100644 index 000000000..34d54ae69 Binary files /dev/null and b/dist/litellm-0.1.650-py3-none-any.whl differ diff --git a/dist/litellm-0.1.650.tar.gz b/dist/litellm-0.1.650.tar.gz new file mode 100644 index 000000000..d1fcf698b Binary files /dev/null and b/dist/litellm-0.1.650.tar.gz differ diff --git a/litellm/__pycache__/utils.cpython-311.pyc b/litellm/__pycache__/utils.cpython-311.pyc index 9384cfc96..b1f1c387f 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 1423ff2a6..8728d4031 100644 --- a/litellm/tests/test_streaming.py +++ b/litellm/tests/test_streaming.py @@ -116,9 +116,11 @@ def test_openai_chat_completion_call(): complete_response = "" start_time = time.time() for chunk in response: - chunk_time = time.time() - print(f"time since initial request: {chunk_time - start_time:.5f}") print(chunk) + if chunk["choices"][0]["finish_reason"]: + break + # if chunk["choices"][0]["delta"]["role"] != "assistant": + # raise Exception("invalid role") if "content" in chunk["choices"][0]["delta"]: complete_response += chunk["choices"][0]["delta"]["content"] print(f'complete_chunk: {complete_response}') diff --git a/litellm/utils.py b/litellm/utils.py index 8ee4e3c48..7e688c558 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -89,10 +89,12 @@ class Message(OpenAIObject): self.logprobs = logprobs class Delta(OpenAIObject): - def __init__(self, content=" ", logprobs=None, role="assistant", **params): + def __init__(self, content="", logprobs=None, role=None, **params): super(Delta, self).__init__(**params) - self.content = content - self.role = role + if content != "": + self.content = content + if role: + self.role = role class Choices(OpenAIObject): @@ -2501,9 +2503,11 @@ class CustomStreamWrapper: 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.content = completion_obj["content"] + model_response.choices[0].delta = { + "content": completion_obj["content"], + } if "role" in completion_obj: - model_response.choices[0].delta.role = completion_obj["role"] + model_response.choices[0].delta = completion_obj return model_response except StopIteration: raise StopIteration diff --git a/pyproject.toml b/pyproject.toml index 1760797fb..90a294583 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.647" +version = "0.1.650" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"