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

Note and solve: Rate Limit openai gpt-3.5-turbo #10

Open
threeColorFr opened this issue Apr 18, 2023 · 2 comments
Open

Note and solve: Rate Limit openai gpt-3.5-turbo #10

threeColorFr opened this issue Apr 18, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@threeColorFr
Copy link
Member

threeColorFr commented Apr 18, 2023

"error-stage1:Rate limit reached for default-gpt-3.5-turbo in organization org-NATszHOraQIVn1LhMbHGpI3Q on requests per min. Limit: 3 / min. Please try again in 20s. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method."

openai官方对请求速率限制一分钟3个,在此提醒一下。
因为是多轮框架,所以一个实例中间可能会断,影响结果。
Solve:TODO

@threeColorFr
Copy link
Member Author

如果有多个账号的话,可以对api进行封装,实现超limit换key

# 封装openai Create,实现换key功能
with open("tokens.txt", "r") as f:
    keys = f.readlines()
    keys = [key.strip() for key in keys]

all_keys = itertools.cycle(keys)

def create(**args):
    global all_keys
    openai.api_key = next(all_keys)
    try:
        result = openai.ChatCompletion.create(**args)
    except openai.error.RateLimitError:
        result = create(**args)
    return result

@threeColorFr threeColorFr added the help wanted Extra attention is needed label Apr 23, 2023
@threeColorFr threeColorFr changed the title Note: Rate Limit openai gpt-3.5-turbo Note and solve: Rate Limit openai gpt-3.5-turbo Apr 23, 2023
@threeColorFr
Copy link
Member Author

see code access.py for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant