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

fix(client/async): correctly retry in all cases #1803

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

fzyzcjy
Copy link
Contributor

@fzyzcjy fzyzcjy commented Oct 20, 2024

  • I understand that this repository is auto-generated and my pull request may not be merged

I know this is auto generated, thus this PR may serve as a hint to fix the upstream code-generator bug.

Reproduction

import logging
from openai import OpenAI, AsyncOpenAI
import openai

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(levelname)s - %(filename)s:%(funcName)s:%(lineno)d - %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S')

# look at log and it DOES retry
client = OpenAI(api_key='dummy', base_url='https://localhost:1111') # deliberate not exist domain
client.chat.completions.create(messages=[], model='my-model')

# this is buggy and the log show NO retry
client = AsyncOpenAI(api_key='dummy', base_url='https://localhost:1111') # deliberate not exist domain
await client.chat.completions.create(messages=[], model='my-model')

Analysis

You can look at AsyncOpenAI vs OpenAI to see why this line of code is wrong. Or, look at a dozen line above this line to see how other errors are handled to see why this is wrong.

Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

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

🤦 thanks for reporting and fixing!

@RobertCraigie RobertCraigie changed the base branch from main to next October 21, 2024 06:42
@RobertCraigie RobertCraigie changed the title AsyncOpenAI does not do any retries when Exception occurs fix(client/async): correctly retry in all cases Oct 21, 2024
@RobertCraigie RobertCraigie merged commit 9fe3f3f into openai:next Oct 21, 2024
2 checks passed
@stainless-app stainless-app bot mentioned this pull request Oct 21, 2024
@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented Oct 21, 2024

You are welcome!

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