Adding PromptLayer test for tags

This commit is contained in:
Samy Chouiti 2024-01-18 10:00:31 +01:00
parent 370e7777e3
commit f8759f1b37

View file

@ -11,7 +11,6 @@ litellm.success_callback = ["promptlayer"]
litellm.set_verbose = True
import time
# def test_promptlayer_logging():
# try:
# # Redirect stdout
@ -65,8 +64,33 @@ def test_promptlayer_logging_with_metadata():
print(e)
test_promptlayer_logging_with_metadata()
def test_promptlayer_logging_with_metadata_tags():
try:
# Redirect stdout
old_stdout = sys.stdout
sys.stdout = new_stdout = io.StringIO()
response = completion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hi 👋 - i'm ai21"}],
temperature=0.2,
max_tokens=20,
metadata={"model": "ai21", "pl_tags": ["env:dev"]},
)
# Restore stdout
time.sleep(1)
sys.stdout = old_stdout
output = new_stdout.getvalue().strip()
print(output)
if "LiteLLM: Prompt Layer Logging: success" not in output:
raise Exception("Required log message not found!")
except Exception as e:
print(e)
test_promptlayer_logging_with_metadata()
test_promptlayer_logging_with_metadata_tags()
# def test_chat_openai():
# try: