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 ServiceUnavailableError #4789

Merged

Conversation

yuta0x89
Copy link
Contributor

@yuta0x89 yuta0x89 commented Jun 24, 2023

Background

This is the PR for retrying when a ServiceUnavailableError occurs.
This is an improved version of #4744 .

Changes

The code has been modified to perform a retry operation when a ServiceUnavailableError (503 error) occurs.

The original code handles specific exceptions such as APIError and Timeout that occur when calling the OpenAI API. When one of the two exceptions occurs, Auto-GPT checks if the HTTP status code of that exception is 429, 502, 503, or if the default number of retry attempts (num_attempts) has been reached. If so, it rethrows (raises) the exception.

However, when specific exceptions such as APIError and Timeout occur, the HTTP status code can not become 503. The HTTP status code becomes 503 only when a ServiceUnavailableError occurs. Therefore, I added the process to handle the occurrence of ServiceUnavailableError.

Documentation

Test Plan

PR Quality Checklist

  • My pull request is atomic and focuses on a single change.
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes.
  • I have run the following commands against my code to ensure it passes our linters:
    black .
    isort .
    mypy
    autoflake --remove-all-unused-imports --recursive --ignore-init-module-imports --ignore-pass-after-docstring autogpt tests --in-place

@netlify
Copy link

netlify bot commented Jun 24, 2023

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 3440994
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/649a03134cc60a00089776ee

@codecov
Copy link

codecov bot commented Jun 24, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09 🎉

Comparison is base (9e99db1) 70.77% compared to head (3440994) 70.87%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4789      +/-   ##
==========================================
+ Coverage   70.77%   70.87%   +0.09%     
==========================================
  Files          68       68              
  Lines        3326     3327       +1     
  Branches      532      532              
==========================================
+ Hits         2354     2358       +4     
+ Misses        795      793       -2     
+ Partials      177      176       -1     
Impacted Files Coverage Δ
autogpt/llm/providers/openai.py 90.82% <100.00%> (+0.08%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@waynehamadi waynehamadi merged commit b157054 into Significant-Gravitas:master Jun 26, 2023
@yuta0x89 yuta0x89 deleted the retry-ServiceUnavailableError branch June 27, 2023 14:27
@yuta0x89 yuta0x89 mentioned this pull request Jun 27, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants