test(test_async_fn.py): catch timeouts

This commit is contained in:
Krrish Dholakia 2023-11-17 18:01:52 -08:00
parent 9f51462933
commit 8e430fcfbe

View file

@ -20,6 +20,8 @@ def test_sync_response():
try: try:
response = completion(model="gpt-3.5-turbo", messages=messages, timeout=5) response = completion(model="gpt-3.5-turbo", messages=messages, timeout=5)
print(f"response: {response}") print(f"response: {response}")
except litellm.Timeout as e:
pass
except Exception as e: except Exception as e:
pytest.fail(f"An exception occurred: {e}") pytest.fail(f"An exception occurred: {e}")
# test_sync_response() # test_sync_response()
@ -29,12 +31,11 @@ def test_sync_response_anyscale():
user_message = "Hello, how are you?" user_message = "Hello, how are you?"
messages = [{"content": user_message, "role": "user"}] messages = [{"content": user_message, "role": "user"}]
try: try:
response = completion(model="anyscale/mistralai/Mistral-7B-Instruct-v0.1", messages=messages) response = completion(model="anyscale/mistralai/Mistral-7B-Instruct-v0.1", messages=messages, timeout=5)
except litellm.Timeout as e:
pass
except Exception as e: except Exception as e:
pytest.fail(f"An exception occurred: {e}") pytest.fail(f"An exception occurred: {e}")
test_sync_response()
print(f"STARTING ANYSCALE RESPONSE")
test_sync_response_anyscale()
# test_sync_response_anyscale() # test_sync_response_anyscale()
def test_async_response_openai(): def test_async_response_openai():