refactor: add black formatting

This commit is contained in:
Krrish Dholakia 2023-12-25 14:10:38 +05:30
parent b87d630b0a
commit 4905929de3
156 changed files with 19723 additions and 10869 deletions

View file

@ -4,7 +4,9 @@ import sys, os
import traceback
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
from litellm import embedding, completion
@ -15,6 +17,7 @@ litellm.failure_callback = ["supabase"]
litellm.set_verbose = False
def test_supabase_logging():
try:
response = completion(
@ -27,41 +30,46 @@ def test_supabase_logging():
except Exception as e:
print(e)
# test_supabase_logging()
def test_acompletion_sync():
import asyncio
import time
async def completion_call():
try:
response = await litellm.acompletion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "write a poem"}],
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "write a poem"}],
max_tokens=10,
stream=True,
user="ishaanStreamingUser",
timeout=5
timeout=5,
)
complete_response = ""
start_time = time.time()
async for chunk in response:
chunk_time = time.time()
#print(chunk)
# print(chunk)
complete_response += chunk["choices"][0]["delta"].get("content", "")
#print(complete_response)
#print(f"time since initial request: {chunk_time - start_time:.5f}")
# print(complete_response)
# print(f"time since initial request: {chunk_time - start_time:.5f}")
if chunk["choices"][0].get("finish_reason", None) != None:
print("🤗🤗🤗 DONE")
return
except litellm.Timeout as e:
except litellm.Timeout as e:
pass
except:
print(f"error occurred: {traceback.format_exc()}")
pass
asyncio.run(completion_call())
# test_acompletion_sync()
@ -69,7 +77,3 @@ def test_acompletion_sync():
litellm.input_callback = []
litellm.success_callback = []
litellm.failure_callback = []