mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
streaming fixes
This commit is contained in:
parent
fa441e9a3e
commit
7b19d62564
12 changed files with 14 additions and 8 deletions
BIN
dist/litellm-0.1.647-py3-none-any.whl
vendored
Normal file
BIN
dist/litellm-0.1.647-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
dist/litellm-0.1.647.tar.gz
vendored
Normal file
BIN
dist/litellm-0.1.647.tar.gz
vendored
Normal file
Binary file not shown.
BIN
dist/litellm-0.1.648-py3-none-any.whl
vendored
Normal file
BIN
dist/litellm-0.1.648-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
dist/litellm-0.1.648.tar.gz
vendored
Normal file
BIN
dist/litellm-0.1.648.tar.gz
vendored
Normal file
Binary file not shown.
BIN
dist/litellm-0.1.649-py3-none-any.whl
vendored
Normal file
BIN
dist/litellm-0.1.649-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
dist/litellm-0.1.649.tar.gz
vendored
Normal file
BIN
dist/litellm-0.1.649.tar.gz
vendored
Normal file
Binary file not shown.
BIN
dist/litellm-0.1.650-py3-none-any.whl
vendored
Normal file
BIN
dist/litellm-0.1.650-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
dist/litellm-0.1.650.tar.gz
vendored
Normal file
BIN
dist/litellm-0.1.650.tar.gz
vendored
Normal file
Binary file not shown.
Binary file not shown.
|
@ -116,9 +116,11 @@ def test_openai_chat_completion_call():
|
||||||
complete_response = ""
|
complete_response = ""
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
for chunk in response:
|
for chunk in response:
|
||||||
chunk_time = time.time()
|
|
||||||
print(f"time since initial request: {chunk_time - start_time:.5f}")
|
|
||||||
print(chunk)
|
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"]:
|
if "content" in chunk["choices"][0]["delta"]:
|
||||||
complete_response += chunk["choices"][0]["delta"]["content"]
|
complete_response += chunk["choices"][0]["delta"]["content"]
|
||||||
print(f'complete_chunk: {complete_response}')
|
print(f'complete_chunk: {complete_response}')
|
||||||
|
|
|
@ -89,10 +89,12 @@ class Message(OpenAIObject):
|
||||||
self.logprobs = logprobs
|
self.logprobs = logprobs
|
||||||
|
|
||||||
class Delta(OpenAIObject):
|
class Delta(OpenAIObject):
|
||||||
def __init__(self, content=" ", logprobs=None, role="assistant", **params):
|
def __init__(self, content="<special_litellm_token>", logprobs=None, role=None, **params):
|
||||||
super(Delta, self).__init__(**params)
|
super(Delta, self).__init__(**params)
|
||||||
self.content = content
|
if content != "<special_litellm_token>":
|
||||||
self.role = role
|
self.content = content
|
||||||
|
if role:
|
||||||
|
self.role = role
|
||||||
|
|
||||||
|
|
||||||
class Choices(OpenAIObject):
|
class Choices(OpenAIObject):
|
||||||
|
@ -2501,9 +2503,11 @@ class CustomStreamWrapper:
|
||||||
threading.Thread(target=self.logging_obj.success_handler, args=(completion_obj,)).start()
|
threading.Thread(target=self.logging_obj.success_handler, args=(completion_obj,)).start()
|
||||||
# return this for all models
|
# return this for all models
|
||||||
model_response = ModelResponse(stream=True)
|
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:
|
if "role" in completion_obj:
|
||||||
model_response.choices[0].delta.role = completion_obj["role"]
|
model_response.choices[0].delta = completion_obj
|
||||||
return model_response
|
return model_response
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "litellm"
|
name = "litellm"
|
||||||
version = "0.1.647"
|
version = "0.1.650"
|
||||||
description = "Library to easily interface with LLM API providers"
|
description = "Library to easily interface with LLM API providers"
|
||||||
authors = ["BerriAI"]
|
authors = ["BerriAI"]
|
||||||
license = "MIT License"
|
license = "MIT License"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue