mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
(test) catch streaming + timeout exceptions
This commit is contained in:
parent
a2e2889d88
commit
7c79d10e9f
1 changed files with 29 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ def test_timeout():
|
|||
litellm.set_verbose=False
|
||||
try:
|
||||
response = litellm.completion(
|
||||
model="gpt-4",
|
||||
model="gpt-3.5-turbo",
|
||||
timeout=0.01,
|
||||
messages=[
|
||||
{
|
||||
|
|
@ -33,4 +33,31 @@ def test_timeout():
|
|||
pass
|
||||
except Exception as e:
|
||||
pytest.fail(f"Did not raise error `openai.APITimeoutError`. Instead raised error type: {type(e)}, Error: {e}")
|
||||
test_timeout()
|
||||
# test_timeout()
|
||||
|
||||
|
||||
|
||||
def test_timeout_streaming():
|
||||
# this Will Raise a timeout
|
||||
litellm.set_verbose=False
|
||||
try:
|
||||
response = litellm.completion(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "hello, write a 20 pg essay"
|
||||
}
|
||||
],
|
||||
timeout=0.0001,
|
||||
stream=True,
|
||||
)
|
||||
for chunk in response:
|
||||
print(chunk)
|
||||
except openai.APITimeoutError as e:
|
||||
print("Passed: Raised correct exception. Got openai.APITimeoutError\nGood Job", e)
|
||||
print(type(e))
|
||||
pass
|
||||
except Exception as e:
|
||||
pytest.fail(f"Did not raise error `openai.APITimeoutError`. Instead raised error type: {type(e)}, Error: {e}")
|
||||
test_timeout_streaming()
|
||||
Loading…
Add table
Reference in a new issue