forked from phoenix/litellm-mirror
(docs) fix exception mapping
This commit is contained in:
parent
e4f1e2b138
commit
34886a99cc
1 changed files with 14 additions and 13 deletions
|
@ -44,19 +44,20 @@ except openai.APITimeoutError as e:
|
||||||
## Usage - Catching Streaming Exceptions
|
## Usage - Catching Streaming Exceptions
|
||||||
```python
|
```python
|
||||||
import litellm
|
import litellm
|
||||||
response = litellm.completion(
|
try:
|
||||||
model="gpt-3.5-turbo",
|
response = litellm.completion(
|
||||||
messages=[
|
model="gpt-3.5-turbo",
|
||||||
{
|
messages=[
|
||||||
"role": "user",
|
{
|
||||||
"content": "hello, write a 20 pg essay"
|
"role": "user",
|
||||||
}
|
"content": "hello, write a 20 pg essay"
|
||||||
],
|
}
|
||||||
timeout=0.0001, # this will raise an exception
|
],
|
||||||
stream=True,
|
timeout=0.0001, # this will raise an exception
|
||||||
)
|
stream=True,
|
||||||
for chunk in response:
|
)
|
||||||
print(chunk)
|
for chunk in response:
|
||||||
|
print(chunk)
|
||||||
except openai.APITimeoutError as e:
|
except openai.APITimeoutError as e:
|
||||||
print("Passed: Raised correct exception. Got openai.APITimeoutError\nGood Job", e)
|
print("Passed: Raised correct exception. Got openai.APITimeoutError\nGood Job", e)
|
||||||
print(type(e))
|
print(type(e))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue