mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
test: cleanup duplicate tests + add error handling for backend api errors
This commit is contained in:
parent
14d54f7af5
commit
24395492aa
3 changed files with 17 additions and 31 deletions
|
|
@ -1,19 +1,23 @@
|
|||
import sys, os
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
import os, io
|
||||
import io
|
||||
import os
|
||||
|
||||
sys.path.insert(
|
||||
0, os.path.abspath("../..")
|
||||
) # Adds the parent directory to the system path
|
||||
import pytest
|
||||
import litellm
|
||||
from litellm import embedding, completion, completion_cost, Timeout
|
||||
from litellm import RateLimitError
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
import litellm
|
||||
from litellm import RateLimitError, Timeout, completion, completion_cost, embedding
|
||||
|
||||
litellm.num_retries = 3
|
||||
|
||||
|
||||
|
|
@ -37,28 +41,6 @@ def test_chat_completion_cohere():
|
|||
pytest.fail(f"Error occurred: {e}")
|
||||
|
||||
|
||||
def test_chat_completion_cohere_stream():
|
||||
try:
|
||||
litellm.set_verbose = False
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Hey",
|
||||
},
|
||||
]
|
||||
response = completion(
|
||||
model="cohere_chat/command-r",
|
||||
messages=messages,
|
||||
max_tokens=10,
|
||||
stream=True,
|
||||
)
|
||||
print(response)
|
||||
for chunk in response:
|
||||
print(chunk)
|
||||
except Exception as e:
|
||||
pytest.fail(f"Error occurred: {e}")
|
||||
|
||||
|
||||
def test_chat_completion_cohere_tool_calling():
|
||||
try:
|
||||
litellm.set_verbose = True
|
||||
|
|
|
|||
|
|
@ -3630,6 +3630,8 @@ def test_chat_completion_cohere_stream():
|
|||
print(response)
|
||||
for chunk in response:
|
||||
print(chunk)
|
||||
except litellm.APIConnectionError as e:
|
||||
pass
|
||||
except Exception as e:
|
||||
pytest.fail(f"Error occurred: {e}")
|
||||
|
||||
|
|
|
|||
|
|
@ -567,11 +567,13 @@ async def test_completion_predibase_streaming(sync_mode):
|
|||
raise Exception("Empty response received")
|
||||
|
||||
print(f"complete_response: {complete_response}")
|
||||
except litellm.Timeout as e:
|
||||
except litellm.Timeout:
|
||||
pass
|
||||
except litellm.InternalServerError as e:
|
||||
except litellm.InternalServerError:
|
||||
pass
|
||||
except litellm.ServiceUnavailableError as e:
|
||||
except litellm.ServiceUnavailableError:
|
||||
pass
|
||||
except litellm.APIConnectionError:
|
||||
pass
|
||||
except Exception as e:
|
||||
print("ERROR class", e.__class__)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue