mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
updates to tests
This commit is contained in:
parent
ab35fdb635
commit
4d17c57373
3 changed files with 29 additions and 29 deletions
|
@ -213,13 +213,7 @@ try:
|
||||||
response = completion(model="claude-instant-1", messages=messages)
|
response = completion(model="claude-instant-1", messages=messages)
|
||||||
except AuthenticationError:
|
except AuthenticationError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Restore stdout
|
|
||||||
sys.stdout = old_stdout
|
|
||||||
output = new_stdout.getvalue().strip()
|
|
||||||
|
|
||||||
print(output)
|
|
||||||
|
|
||||||
if "Logging Details Pre-API Call" not in output:
|
if "Logging Details Pre-API Call" not in output:
|
||||||
raise Exception("Required log message not found!")
|
raise Exception("Required log message not found!")
|
||||||
elif "Logging Details Post-API Call" not in output:
|
elif "Logging Details Post-API Call" not in output:
|
||||||
|
@ -231,6 +225,11 @@ try:
|
||||||
score += 1
|
score += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"exception type: {type(e).__name__}")
|
print(f"exception type: {type(e).__name__}")
|
||||||
|
# Restore stdout
|
||||||
|
sys.stdout = old_stdout
|
||||||
|
output = new_stdout.getvalue().strip()
|
||||||
|
|
||||||
|
print(output)
|
||||||
pytest.fail(f"Error occurred: {e}")
|
pytest.fail(f"Error occurred: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,34 +2,34 @@
|
||||||
# This tests error logging (with custom user functions) for the `completion` + `embedding` endpoints without callbacks (i.e. slack, posthog, etc. not set)
|
# This tests error logging (with custom user functions) for the `completion` + `embedding` endpoints without callbacks (i.e. slack, posthog, etc. not set)
|
||||||
# Requirements: Remove any env keys you have related to slack/posthog/etc. + anthropic api key (cause an exception)
|
# Requirements: Remove any env keys you have related to slack/posthog/etc. + anthropic api key (cause an exception)
|
||||||
|
|
||||||
import sys, os
|
# import sys, os
|
||||||
import traceback
|
# import traceback
|
||||||
|
|
||||||
sys.path.insert(
|
# sys.path.insert(
|
||||||
0, os.path.abspath("../..")
|
# 0, os.path.abspath("../..")
|
||||||
) # Adds the parent directory to the system path
|
# ) # Adds the parent directory to the system path
|
||||||
import litellm
|
# import litellm
|
||||||
from litellm import embedding, completion
|
# from litellm import embedding, completion
|
||||||
from infisical import InfisicalClient
|
# from infisical import InfisicalClient
|
||||||
import pytest
|
# import pytest
|
||||||
|
|
||||||
infisical_token = os.environ["INFISICAL_TOKEN"]
|
# infisical_token = os.environ["INFISICAL_TOKEN"]
|
||||||
|
|
||||||
litellm.secret_manager_client = InfisicalClient(token=infisical_token)
|
# litellm.secret_manager_client = InfisicalClient(token=infisical_token)
|
||||||
|
|
||||||
user_message = "Hello, whats the weather in San Francisco??"
|
# user_message = "Hello, whats the weather in San Francisco??"
|
||||||
messages = [{"content": user_message, "role": "user"}]
|
# messages = [{"content": user_message, "role": "user"}]
|
||||||
|
|
||||||
|
|
||||||
def test_completion_openai():
|
# def test_completion_openai():
|
||||||
try:
|
# try:
|
||||||
response = completion(model="gpt-3.5-turbo", messages=messages)
|
# response = completion(model="gpt-3.5-turbo", messages=messages)
|
||||||
# Add any assertions here to check the response
|
# # Add any assertions here to check the response
|
||||||
print(response)
|
# print(response)
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
litellm.secret_manager_client = None
|
# litellm.secret_manager_client = None
|
||||||
pytest.fail(f"Error occurred: {e}")
|
# pytest.fail(f"Error occurred: {e}")
|
||||||
litellm.secret_manager_client = None
|
# litellm.secret_manager_client = None
|
||||||
|
|
||||||
|
|
||||||
test_completion_openai()
|
# test_completion_openai()
|
||||||
|
|
|
@ -1956,6 +1956,7 @@ def completion_with_split_tests(models={}, messages=[], use_client=False, overri
|
||||||
completion_with_split_tests(models=models, messages=messages)
|
completion_with_split_tests(models=models, messages=messages)
|
||||||
"""
|
"""
|
||||||
import random
|
import random
|
||||||
|
model_configs = {}
|
||||||
if use_client and not override_client:
|
if use_client and not override_client:
|
||||||
if "id" not in kwargs or kwargs["id"] is None:
|
if "id" not in kwargs or kwargs["id"] is None:
|
||||||
raise ValueError("Please tag this completion call, if you'd like to update it's split test values through the UI. - eg. `completion_with_split_tests(.., id=1234)`.")
|
raise ValueError("Please tag this completion call, if you'd like to update it's split test values through the UI. - eg. `completion_with_split_tests(.., id=1234)`.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue