forked from phoenix/litellm-mirror
(test) flaky cohere endpoint for streaming
This commit is contained in:
parent
3e40ba39bf
commit
60e9433476
1 changed files with 29 additions and 28 deletions
|
@ -190,34 +190,35 @@ def streaming_format_tests(idx, chunk):
|
||||||
print(f"extracted chunk: {extracted_chunk}")
|
print(f"extracted chunk: {extracted_chunk}")
|
||||||
return extracted_chunk, finished
|
return extracted_chunk, finished
|
||||||
|
|
||||||
def test_completion_cohere_stream():
|
# def test_completion_cohere_stream():
|
||||||
try:
|
# this is a flaky test due to the cohere API endpoint being unstable
|
||||||
messages = [
|
# try:
|
||||||
{"role": "system", "content": "You are a helpful assistant."},
|
# messages = [
|
||||||
{
|
# {"role": "system", "content": "You are a helpful assistant."},
|
||||||
"role": "user",
|
# {
|
||||||
"content": "how does a court case get to the Supreme Court?",
|
# "role": "user",
|
||||||
},
|
# "content": "how does a court case get to the Supreme Court?",
|
||||||
]
|
# },
|
||||||
response = completion(
|
# ]
|
||||||
model="command-nightly", messages=messages, stream=True, max_tokens=50,
|
# response = completion(
|
||||||
)
|
# model="command-nightly", messages=messages, stream=True, max_tokens=50,
|
||||||
complete_response = ""
|
# )
|
||||||
# Add any assertions here to check the response
|
# complete_response = ""
|
||||||
has_finish_reason = False
|
# # Add any assertions here to check the response
|
||||||
for idx, chunk in enumerate(response):
|
# has_finish_reason = False
|
||||||
chunk, finished = streaming_format_tests(idx, chunk)
|
# for idx, chunk in enumerate(response):
|
||||||
has_finish_reason = finished
|
# chunk, finished = streaming_format_tests(idx, chunk)
|
||||||
if finished:
|
# has_finish_reason = finished
|
||||||
break
|
# if finished:
|
||||||
complete_response += chunk
|
# break
|
||||||
if has_finish_reason is False:
|
# complete_response += chunk
|
||||||
raise Exception("Finish reason not in final chunk")
|
# if has_finish_reason is False:
|
||||||
if complete_response.strip() == "":
|
# raise Exception("Finish reason not in final chunk")
|
||||||
raise Exception("Empty response received")
|
# if complete_response.strip() == "":
|
||||||
print(f"completion_response: {complete_response}")
|
# raise Exception("Empty response received")
|
||||||
except Exception as e:
|
# print(f"completion_response: {complete_response}")
|
||||||
pytest.fail(f"Error occurred: {e}")
|
# except Exception as e:
|
||||||
|
# pytest.fail(f"Error occurred: {e}")
|
||||||
|
|
||||||
# test_completion_cohere_stream()
|
# test_completion_cohere_stream()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue