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

Retry API call on InternalServerError #670

Open
Mnaukal opened this issue Jan 3, 2025 · 0 comments
Open

Retry API call on InternalServerError #670

Mnaukal opened this issue Jan 3, 2025 · 0 comments

Comments

@Mnaukal
Copy link

Mnaukal commented Jan 3, 2025

While using the ChatGoogleGenerativeAI, my script sometimes crashes due to an internal server error: google.api_core.exceptions.InternalServerError: 500 Unable to submit request because the service is temporarily unavailable..

From the log messages, It seems that there is an internal retry mechanism in Google's package, as this appears before the crash: Retrying langchain_google_genai.chat_models._chat_with_retry.<locals>._chat_with_retry in 2.0 seconds as it raised InternalServerError: 500 Unable to submit request because the service is temporarily unavailable.., and often, the retry solves the error. However, I did not find a way to specify the number of retries, so it only retries once after 2 seconds.

In the ChatGoogleGenerativeAI constructor, it is possible to specify the max_retires parameter, but this is not passed to Google's package, so it does not work as expected in my case. Would it be possible to also include the google.api_core.exceptions.InternalServerError among the errors that cause a retry in your package (here)?

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

No branches or pull requests

1 participant