mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
(fix) supabase test
This commit is contained in:
parent
f03fac9e02
commit
0f94c477f1
1 changed files with 42 additions and 42 deletions
|
@ -1,54 +1,54 @@
|
||||||
#### What this tests ####
|
# #### What this tests ####
|
||||||
# This tests if logging to the supabase integration actually works
|
# # This tests if logging to the supabase integration actually works
|
||||||
# pytest mistakes intentional bad calls as failed tests -> [TODO] fix this
|
# # pytest mistakes intentional bad calls as failed tests -> [TODO] fix this
|
||||||
import sys, os
|
# import sys, os
|
||||||
import traceback
|
# import traceback
|
||||||
import pytest
|
# import pytest
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath('../..')) # Adds the parent directory to the system path
|
# sys.path.insert(0, os.path.abspath('../..')) # Adds the parent directory to the system path
|
||||||
import litellm
|
# import litellm
|
||||||
from litellm import embedding, completion
|
# from litellm import embedding, completion
|
||||||
|
|
||||||
litellm.input_callback = ["supabase"]
|
# litellm.input_callback = ["supabase"]
|
||||||
litellm.success_callback = ["supabase"]
|
# litellm.success_callback = ["supabase"]
|
||||||
litellm.failure_callback = ["supabase"]
|
# litellm.failure_callback = ["supabase"]
|
||||||
|
|
||||||
|
|
||||||
litellm.set_verbose = False
|
# litellm.set_verbose = False
|
||||||
|
|
||||||
user_message = "Hello, how are you?"
|
# user_message = "Hello, how are you?"
|
||||||
messages = [{ "content": user_message,"role": "user"}]
|
# messages = [{ "content": user_message,"role": "user"}]
|
||||||
|
|
||||||
|
|
||||||
#openai call
|
# #openai call
|
||||||
response = completion(
|
# response = completion(
|
||||||
model="gpt-3.5-turbo",
|
# model="gpt-3.5-turbo",
|
||||||
messages=[{"role": "user", "content": "Hi 👋 - i'm openai"}],
|
# messages=[{"role": "user", "content": "Hi 👋 - i'm openai"}],
|
||||||
user="ishaan22"
|
# user="ishaan22"
|
||||||
)
|
# )
|
||||||
|
|
||||||
import asyncio
|
# import asyncio
|
||||||
import time
|
# import time
|
||||||
async def completion_call():
|
# async def completion_call():
|
||||||
try:
|
# try:
|
||||||
response = await litellm.acompletion(
|
# response = await litellm.acompletion(
|
||||||
model="gpt-3.5-turbo", messages=messages, stream=True
|
# model="gpt-3.5-turbo", messages=messages, stream=True
|
||||||
)
|
# )
|
||||||
complete_response = ""
|
# complete_response = ""
|
||||||
start_time = time.time()
|
# start_time = time.time()
|
||||||
async for chunk in response:
|
# async for chunk in response:
|
||||||
chunk_time = time.time()
|
# chunk_time = time.time()
|
||||||
print(chunk)
|
# print(chunk)
|
||||||
complete_response += chunk["choices"][0]["delta"].get("content", "")
|
# complete_response += chunk["choices"][0]["delta"].get("content", "")
|
||||||
print(complete_response)
|
# print(complete_response)
|
||||||
print(f"time since initial request: {chunk_time - start_time:.5f}")
|
# print(f"time since initial request: {chunk_time - start_time:.5f}")
|
||||||
|
|
||||||
if chunk["choices"][0].get("finish_reason", None) != None:
|
# if chunk["choices"][0].get("finish_reason", None) != None:
|
||||||
print("🤗🤗🤗 DONE")
|
# print("🤗🤗🤗 DONE")
|
||||||
except:
|
# except:
|
||||||
print(f"error occurred: {traceback.format_exc()}")
|
# print(f"error occurred: {traceback.format_exc()}")
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
asyncio.run(completion_call())
|
# asyncio.run(completion_call())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue