mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
bump pyproject version
This commit is contained in:
parent
6430bdb636
commit
b45bb78bee
5 changed files with 86 additions and 81 deletions
Binary file not shown.
Binary file not shown.
|
@ -214,6 +214,31 @@ def test_completion_cohere_stream():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pytest.fail(f"Error occurred: {e}")
|
pytest.fail(f"Error occurred: {e}")
|
||||||
|
|
||||||
|
def test_completion_claude_stream():
|
||||||
|
try:
|
||||||
|
messages = [
|
||||||
|
{"role": "system", "content": "You are a helpful assistant."},
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "how does a court case get to the Supreme Court?",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
response = completion(
|
||||||
|
model="claude-instant-1", messages=messages, stream=True, max_tokens=50
|
||||||
|
)
|
||||||
|
complete_response = ""
|
||||||
|
# Add any assertions here to check the response
|
||||||
|
for idx, chunk in enumerate(response):
|
||||||
|
chunk, finished = streaming_format_tests(idx, chunk)
|
||||||
|
if finished:
|
||||||
|
break
|
||||||
|
complete_response += chunk
|
||||||
|
if complete_response.strip() == "":
|
||||||
|
raise Exception("Empty response received")
|
||||||
|
print(f"completion_response: {complete_response}")
|
||||||
|
except Exception as e:
|
||||||
|
pytest.fail(f"Error occurred: {e}")
|
||||||
|
# test_completion_claude_stream()
|
||||||
|
|
||||||
def test_completion_bedrock_ai21_stream():
|
def test_completion_bedrock_ai21_stream():
|
||||||
try:
|
try:
|
||||||
|
@ -327,28 +352,6 @@ def test_together_ai_completion_call_starcoder():
|
||||||
print(f"error occurred: {traceback.format_exc()}")
|
print(f"error occurred: {traceback.format_exc()}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_completion_nlp_cloud_streaming():
|
|
||||||
try:
|
|
||||||
messages = [
|
|
||||||
{"role": "system", "content": "You are a helpful assistant."},
|
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": "how does a court case get to the Supreme Court?",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
response = completion(model="dolphin", messages=messages, stream=True, logger_fn=logger_fn)
|
|
||||||
complete_response = ""
|
|
||||||
# Add any assertions here to check the response
|
|
||||||
for idx, chunk in enumerate(response):
|
|
||||||
chunk, finished = streaming_format_tests(idx, chunk)
|
|
||||||
if finished:
|
|
||||||
break
|
|
||||||
complete_response += chunk
|
|
||||||
if complete_response == "":
|
|
||||||
raise Exception("Empty response received")
|
|
||||||
except Exception as e:
|
|
||||||
pytest.fail(f"Error occurred: {e}")
|
|
||||||
|
|
||||||
#### Test Function calling + streaming ####
|
#### Test Function calling + streaming ####
|
||||||
|
|
||||||
def test_completion_openai_with_functions():
|
def test_completion_openai_with_functions():
|
||||||
|
|
|
@ -2506,14 +2506,13 @@ class CustomStreamWrapper:
|
||||||
return chunk_data['outputText']
|
return chunk_data['outputText']
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
## needs to handle the empty string case (even starting chunk can be an empty string)
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
model_response = ModelResponse(stream=True, model=self.model)
|
model_response = ModelResponse(stream=True, model=self.model)
|
||||||
try:
|
try:
|
||||||
|
while True: # loop until a non-empty string is found
|
||||||
# return this for all models
|
# return this for all models
|
||||||
completion_obj = {"content": ""}
|
completion_obj = {"content": ""}
|
||||||
if self.sent_first_chunk == False:
|
|
||||||
completion_obj["role"] = "assistant"
|
|
||||||
self.sent_first_chunk = True
|
|
||||||
if self.custom_llm_provider and self.custom_llm_provider == "anthropic":
|
if self.custom_llm_provider and self.custom_llm_provider == "anthropic":
|
||||||
chunk = next(self.completion_stream)
|
chunk = next(self.completion_stream)
|
||||||
completion_obj["content"] = self.handle_anthropic_chunk(chunk)
|
completion_obj["content"] = self.handle_anthropic_chunk(chunk)
|
||||||
|
@ -2567,6 +2566,9 @@ 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()
|
||||||
model_response.model = self.model
|
model_response.model = self.model
|
||||||
if len(completion_obj["content"]) > 0: # cannot set content of an OpenAI Object to be an empty string
|
if len(completion_obj["content"]) > 0: # cannot set content of an OpenAI Object to be an empty string
|
||||||
|
if self.sent_first_chunk == False:
|
||||||
|
completion_obj["role"] = "assistant"
|
||||||
|
self.sent_first_chunk = True
|
||||||
model_response.choices[0].delta = Delta(**completion_obj)
|
model_response.choices[0].delta = Delta(**completion_obj)
|
||||||
return model_response
|
return model_response
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "litellm"
|
name = "litellm"
|
||||||
version = "0.1.685"
|
version = "0.1.686"
|
||||||
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