Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch api error #5

Merged
merged 3 commits into from
Jun 12, 2024
Merged

catch api error #5

merged 3 commits into from
Jun 12, 2024

Conversation

ruoyao-wang
Copy link
Collaborator

Try to catch openai.APIError.

@@ -121,7 +121,7 @@ def stream_llm_gpt(prompt, model="gpt-3.5-turbo", **kwargs):
pbar.close()
break

except (openai.APITimeoutError, ChunkedEncodingError, ReadError, RemoteProtocolError) as e:
except (openai.APITimeoutError, openai.APIError, ChunkedEncodingError, ReadError, RemoteProtocolError) as e:
# Append the response we received so far to messages.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Append the response we received so far to messages.
if isinstance(e, openai.APIError):
print("*****", e.type)
# Append the response we received so far to messages.

@MarcCote MarcCote merged commit bfb9e7c into main Jun 12, 2024
@MarcCote MarcCote deleted the error_catching branch June 12, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants