mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
* Add O3-Mini for Azure and Remove Vision Support (#8161) * Azure Released O3-mini at the same time as OAI, so i've added support here. Confirmed to work with Sweden Central. * [FIX] replace cgi for python 3.13 with email.Message as suggested in PEP 594 (#8160) * Update model_prices_and_context_window.json (#8120) codestral2501 pricing on vertex_ai * Fix/db view names (#8119) * Fix to case sensitive DB Views name * Fix to case sensitive DB View names * Added quotes to check query as well * Added quotes to create view query * test: handle server error for flaky test vertex ai has unstable endpoints --------- Co-authored-by: Wanis Elabbar <70503629+elabbarw@users.noreply.github.com> Co-authored-by: Honghua Dong <dhh1995@163.com> Co-authored-by: superpoussin22 <vincent.nadal@orange.fr> Co-authored-by: Miguel Armenta <37154380+ma-armenta@users.noreply.github.com>
89 lines
2.3 KiB
Python
89 lines
2.3 KiB
Python
#### What this tests ####
|
|
# This tests calling batch_completions by running 100 messages together
|
|
|
|
import sys, os
|
|
import traceback
|
|
import pytest
|
|
|
|
sys.path.insert(
|
|
0, os.path.abspath("../..")
|
|
) # Adds the parent directory to the system path
|
|
from openai import APITimeoutError as Timeout
|
|
import litellm
|
|
|
|
litellm.num_retries = 0
|
|
from litellm import (
|
|
batch_completion,
|
|
batch_completion_models,
|
|
completion,
|
|
batch_completion_models_all_responses,
|
|
)
|
|
|
|
# litellm.set_verbose=True
|
|
|
|
|
|
def test_batch_completions():
|
|
messages = [[{"role": "user", "content": "write a short poem"}] for _ in range(3)]
|
|
model = "gpt-3.5-turbo"
|
|
litellm.set_verbose = True
|
|
try:
|
|
result = batch_completion(
|
|
model=model,
|
|
messages=messages,
|
|
max_tokens=10,
|
|
temperature=0.2,
|
|
request_timeout=1,
|
|
)
|
|
print(result)
|
|
print(len(result))
|
|
assert len(result) == 3
|
|
|
|
for response in result:
|
|
assert response.choices[0].message.content is not None
|
|
except Timeout as e:
|
|
print(f"IN TIMEOUT")
|
|
pass
|
|
except litellm.InternalServerError as e:
|
|
print(f"IN INTERNAL SERVER ERROR")
|
|
pass
|
|
except Exception as e:
|
|
pytest.fail(f"An error occurred: {e}")
|
|
|
|
|
|
# test_batch_completions()
|
|
|
|
|
|
def test_batch_completions_models():
|
|
try:
|
|
result = batch_completion_models(
|
|
models=["gpt-3.5-turbo", "gpt-3.5-turbo", "gpt-3.5-turbo"],
|
|
messages=[{"role": "user", "content": "Hey, how's it going"}],
|
|
)
|
|
print(result)
|
|
except Timeout as e:
|
|
pass
|
|
except Exception as e:
|
|
pytest.fail(f"An error occurred: {e}")
|
|
|
|
|
|
# test_batch_completions_models()
|
|
|
|
|
|
def test_batch_completion_models_all_responses():
|
|
try:
|
|
responses = batch_completion_models_all_responses(
|
|
models=["gemini/gemini-1.5-flash", "claude-3-haiku-20240307"],
|
|
messages=[{"role": "user", "content": "write a poem"}],
|
|
max_tokens=10,
|
|
)
|
|
print(responses)
|
|
assert len(responses) == 2
|
|
except Timeout as e:
|
|
pass
|
|
except litellm.APIError as e:
|
|
pass
|
|
except Exception as e:
|
|
pytest.fail(f"An error occurred: {e}")
|
|
|
|
|
|
# test_batch_completion_models_all_responses()
|