Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(streaming): remove commented-out retired-provider streaming tests

mateod134fa18ee8a
diff --git a/tests/local_testing/test_streaming.py b/tests/local_testing/test_streaming.py
index bf39d3155b7..e40b8830d8a 100644
--- a/tests/local_testing/test_streaming.py
+++ b/tests/local_testing/test_streaming.py
@@ -203,38 +203,6 @@ tools_schema = [
}
]
-# def test_completion_cohere_stream():
-# # this is a flaky test due to the cohere API endpoint being unstable
-# 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="command-nightly", messages=messages, stream=True, max_tokens=50,
-# )
-# complete_response = ""
-# # Add any assertions here to check the response
-# has_finish_reason = False
-# for idx, chunk in enumerate(response):
-# chunk, finished = streaming_format_tests(idx, chunk)
-# has_finish_reason = finished
-# if finished:
-# break
-# complete_response += chunk
-# if has_finish_reason is False:
-# raise Exception("Finish reason not in final 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_cohere_stream()
-
def test_completion_azure_stream_special_char():
litellm.set_verbose = True
@@ -466,9 +434,6 @@ def test_completion_azure_stream():
pytest.fail(f"Error occurred: {e}")
-# test_completion_azure_stream()
-
-
def test_completion_azure_function_calling_stream():
try:
litellm.set_verbose = False
@@ -491,9 +456,6 @@ def test_completion_azure_function_calling_stream():
pytest.fail(f"Error occurred: {e}")
-# test_completion_azure_function_calling_stream()
-
-
@pytest.mark.skip("Flaky ollama test - needs to be fixed")
def test_completion_ollama_hosted_stream():
try:
@@ -525,9 +487,6 @@ def test_completion_ollama_hosted_stream():
pytest.fail(f"Error occurred: {e}")
-# test_completion_ollama_hosted_stream()
-
-
@pytest.mark.parametrize(
"model",
[
@@ -658,7 +617,6 @@ async def test_completion_gemini_stream(sync_mode):
pytest.fail(f"Error occurred: {e}")
-# asyncio.run(test_acompletion_gemini_stream())
def gemini_mock_post_streaming(url, **kwargs):
# This generator simulates the streaming response with partial JSON content
def stream_response():
@@ -856,9 +814,6 @@ def test_completion_mistral_api_mistral_large_function_call_with_streaming():
pytest.fail(f"Error occurred: {e}")
-# test_completion_mistral_api_stream()
-
-
@pytest.mark.skip()
def test_completion_nlp_cloud_stream():
try:
@@ -892,9 +847,6 @@ def test_completion_nlp_cloud_stream():
pytest.fail(f"Error occurred: {e}")
-# test_completion_nlp_cloud_stream()
-
-
def test_completion_claude_stream_bad_key():
try:
litellm.cache = None
@@ -935,10 +887,6 @@ def test_completion_claude_stream_bad_key():
pytest.fail(f"Error occurred: {e}")
-# test_completion_claude_stream_bad_key()
-# test_completion_replicate_stream()
-
-
@pytest.mark.parametrize("provider", ["vertex_ai_beta"]) # ""
def test_vertex_ai_stream(provider):
from test_amazing_vertex_completion import (
@@ -997,78 +945,6 @@ def test_vertex_ai_stream(provider):
pytest.fail(f"Error occurred: {e}")
-# def test_completion_vertexai_stream():
-# try:
-# import os
-# os.environ["VERTEXAI_PROJECT"] = "pathrise-convert-1606954137718"
-# os.environ["VERTEXAI_LOCATION"] = "us-central1"
-# 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="vertex_ai/chat-bison", messages=messages, stream=True, max_tokens=50
-# )
-# complete_response = ""
-# has_finish_reason = False
-# # Add any assertions here to check the response
-# for idx, chunk in enumerate(response):
-# chunk, finished = streaming_format_tests(idx, chunk)
-# has_finish_reason = finished
-# if finished:
-# break
-# complete_response += chunk
-# if has_finish_reason is False:
-# raise Exception("finish reason not set for last chunk")
-# if complete_response.strip() == "":
-# raise Exception("Empty response received")
-# print(f"completion_response: {complete_response}")
-# except InvalidRequestError as e:
-# pass
-# except Exception as e:
-# pytest.fail(f"Error occurred: {e}")
-
-# test_completion_vertexai_stream()
-
-
-# def test_completion_vertexai_stream_bad_key():
-# try:
-# import os
-# 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="vertex_ai/chat-bison", messages=messages, stream=True, max_tokens=50
-# )
-# complete_response = ""
-# has_finish_reason = False
-# # Add any assertions here to check the response
-# for idx, chunk in enumerate(response):
-# chunk, finished = streaming_format_tests(idx, chunk)
-# has_finish_reason = finished
-# if finished:
-# break
-# complete_response += chunk
-# if has_finish_reason is False:
-# raise Exception("finish reason not set for last chunk")
-# if complete_response.strip() == "":
-# raise Exception("Empty response received")
-# print(f"completion_response: {complete_response}")
-# except InvalidRequestError as e:
-# pass
-# except Exception as e:
-# pytest.fail(f"Error occurred: {e}")
-
-# test_completion_vertexai_stream_bad_key()
-
-
@pytest.mark.skip(reason="Replicate extremely flaky.")
@pytest.mark.parametrize("sync_mode", [False, True])
@pytest.mark.asyncio
@@ -1130,39 +1006,6 @@ async def test_completion_replicate_llama3_streaming(sync_mode):
pytest.fail(f"Error occurred: {e}")
-# TEMP Commented out - replicate throwing an auth error
-# try:
-# litellm.set_verbose = True
-# 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="replicate/meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3", messages=messages, stream=True, max_tokens=50
-# )
-# complete_response = ""
-# has_finish_reason = False
-# # Add any assertions here to check the response
-# for idx, chunk in enumerate(response):
-# chunk, finished = streaming_format_tests(idx, chunk)
-# has_finish_reason = finished
-# if finished:
-# break
-# complete_response += chunk
-# if has_finish_reason is False:
-# raise Exception("finish reason not set for last chunk")
-# if complete_response.strip() == "":
-# raise Exception("Empty response received")
-# print(f"completion_response: {complete_response}")
-# except InvalidRequestError as e:
-# pass
-# except Exception as e:
-# pytest.fail(f"Error occurred: {e}")
-
-
@pytest.mark.parametrize("sync_mode", [True, False]) #
@pytest.mark.parametrize(
"model, region",
@@ -1393,11 +1236,6 @@ def test_completion_replicate_stream_bad_key():
pytest.fail(f"Error occurred: {e}")
-# test_completion_replicate_stream_bad_key()
-
-# test_completion_bedrock_claude_stream()
-
-
@pytest.mark.skip(reason="model end of life")
def test_completion_bedrock_ai21_stream():
try:
@@ -1436,9 +1274,6 @@ def test_completion_bedrock_ai21_stream():
pytest.fail(f"Error occurred: {e}")
-# test_completion_bedrock_ai21_stream()
-
-
def test_completion_bedrock_mistral_stream():
try:
litellm.set_verbose = False
@@ -1534,12 +1369,6 @@ def test_sagemaker_weird_response():
pytest.fail(f"An exception occurred - {str(e)}")
-# test_sagemaker_weird_response()
-
-
-# asyncio.run(test_sagemaker_streaming_async())
-
-
@pytest.mark.skip(reason="Account deleted by IBM.")
@pytest.mark.asyncio
async def test_completion_watsonx_stream():
@@ -1576,32 +1405,6 @@ async def test_completion_watsonx_stream():
pytest.fail(f"Error occurred: {e}")
-# test_completion_sagemaker_stream()
-
-
-# def test_maritalk_streaming():
-# messages = [{"role": "user", "content": "Hey"}]
-# try:
-# response = completion("maritalk", messages=messages, stream=True)
-# complete_response = ""
-# start_time = time.time()
-# for idx, chunk in enumerate(response):
-# chunk, finished = streaming_format_tests(idx, chunk)
-# complete_response += chunk
-# if finished:
-# break
-# if complete_response.strip() == "":
-# raise Exception("Empty response received")
-# except Exception:
-# pytest.fail(f"error occurred: {traceback.format_exc()}")
-
-
-# ai21_completion_call()
-
-
-# ai21_completion_call_bad_key()
-
-
@pytest.mark.skip(reason="flaky test")
@pytest.mark.asyncio
async def test_hf_completion_tgi_stream():
@@ -1629,60 +1432,6 @@ async def test_hf_completion_tgi_stream():
pytest.fail(f"Error occurred: {e}")
-# hf_test_completion_tgi_stream()
-
-# def test_completion_aleph_alpha():
-# try:
-# response = completion(
-# model="luminous-base", messages=messages, stream=True
-# )
-# # Add any assertions here to check the response
-# has_finished = False
-# complete_response = ""
-# start_time = time.time()
-# for idx, chunk in enumerate(response):
-# chunk, finished = streaming_format_tests(idx, chunk)
-# has_finished = finished
-# complete_response += chunk
-# if finished:
-# break
-# if has_finished is False:
-# raise Exception("finished reason missing from final chunk")
-# if complete_response.strip() == "":
-# raise Exception("Empty response received")
-# except Exception as e:
-# pytest.fail(f"Error occurred: {e}")
-
-# # test_completion_aleph_alpha()
-
-# def test_completion_aleph_alpha_bad_key():
-# try:
-# api_key = "bad-key"
-# response = completion(
-# model="luminous-base", messages=messages, stream=True, api_key=api_key
-# )
-# # Add any assertions here to check the response
-# has_finished = False
-# complete_response = ""
-# start_time = time.time()
-# for idx, chunk in enumerate(response):
-# chunk, finished = streaming_format_tests(idx, chunk)
-# has_finished = finished
-# complete_response += chunk
-# if finished:
-# break
-# if has_finished is False:
-# raise Exception("finished reason missing from final chunk")
-# if complete_response.strip() == "":
-# raise Exception("Empty response received")
-# except InvalidRequestError as e:
-# pass
-# except Exception as e:
-# pytest.fail(f"Error occurred: {e}")
-
-# test_completion_aleph_alpha_bad_key()
-
-
# test on openai completion call
def test_openai_chat_completion_call():
litellm.set_verbose = False
@@ -1710,9 +1459,6 @@ def test_openai_chat_completion_call():
print(f"complete response: {complete_response}")
-# test_openai_chat_completion_call()
-
-
def test_openai_chat_completion_complete_response_call():
try:
complete_response = completion(
@@ -1727,7 +1473,6 @@ def test_openai_chat_completion_complete_response_call():
pass
-# test_openai_chat_completion_complete_response_call()
@pytest.mark.parametrize(
"model",
[
@@ -1865,9 +1610,6 @@ def test_openai_text_completion_call():
pass
-# test_openai_text_completion_call()
-
-
# # test on together ai completion call - starcoder
def test_together_ai_completion_call_mistral():
try:
@@ -1931,7 +1673,6 @@ def test_together_ai_completion_call_starcoder_bad_key():
pass
-# test_together_ai_completion_call_starcoder_bad_key()
#### Test Function calling + streaming ####
@@ -1973,7 +1714,6 @@ def test_completion_openai_with_functions():
pytest.fail(f"Error occurred: {e}")
-# test_completion_openai_with_functions()
#### Test Async streaming ####
@@ -2005,8 +1745,6 @@ async def completion_call():
pass
-# asyncio.run(completion_call())
-
#### Test Function Calling + Streaming ####
final_openai_function_call_example = {
@@ -2310,9 +2048,6 @@ def test_streaming_and_function_calling(model):
raise e
-# test_azure_streaming_and_function_calling()
-
-
def test_success_callback_streaming():
def success_callback(kwargs, completion_response, start_time, end_time):
print(
@@ -2341,8 +2076,6 @@ def test_success_callback_streaming():
print(chunk["choices"][0])
-# test_success_callback_streaming()
-
from typing import List, Optional
#### STREAMING + FUNCTION CALLING ###