Chatgpt登陆后一直在转圈请求429错误的解决办法

Chatgpt登陆后一直在转圈请求429错误的解决办法

如果您使用ChatGPT登陆后遇到了持续转圈或请求429错误,可能是由于请求次数过多导致的限制。为了解决这个问题,可以尝试以下几个方法:

  1. 等待一段时间后再次尝试登陆。由于请求次数过多,ChatGPT可能会限制您的请求,因此等待一段时间后再次尝试登陆可能会解决问题。

  2. 检查您的网络连接。如果您的网络连接不稳定或网络速度较慢,可能会导致ChatGPT无法正常工作。请确保您的网络连接良好,并且网络速度足够快。

  3. 尝试清除浏览器缓存。有时候浏览器缓存可能会导致问题,尝试清除浏览器缓存后再次尝试登陆可能会解决问题。

我使用了指数退避重试解决了问题

1、创建一个python脚本

# imports
import random
import time

import openai


# define a retry decorator
def retry_with_exponential_backoff(
        func,
        initial_delay: float = 1,
        exponential_base: float = 2,
        jitter: bool = True,
        max_retries: int = 10,
        errors: tuple = (openai.error.RateLimitError,),
):
    """Retry a function with exponential backoff."""

    def wrapper(*args, **kwargs):
        # Initialize variables
        num_retries = 0
        delay = initial_delay

        # Loop until a successful response or max_retries is hit or an exception is raised
        while True:
            try:
                return func(*args, **kwargs)

            # Retry on specific errors
            except errors as e:
                # Increment retries
                num_retries += 1

                # Check if max retries has been reached
                if num_retries > max_retries:
                    raise Exception(
                        f"Maximum number of retries ({max_retries}) exceeded."
                    )

                # Increment the delay
                delay *= exponential_base * (1 + jitter * random.random())

                # Sleep for the delay
                time.sleep(delay)

            # Raise exceptions for any errors not specified
            except Exception as e:
                raise e

    return wrapper


@retry_with_exponential_backoff
def completions_with_backoff(**kwargs):
    return openai.Completion.create(**kwargs)

注:此脚本中,要下载openai第三方包
使用命令如下:

pip install openai -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

下载完成后需要注意urllib3的版本

pip install urllib3==1.25.11

再次运行上次代码,若无报错,重新刷新openai界面,则无429错误

若上面不成功,在试试下面的

import openai
from openai.error import RateLimitError
import backoff

@backoff.on_exception(backoff.expo, RateLimitError)
def completions_with_backoff(**kwargs):
    response = openai.Completion.create(**kwargs)
    return response

尝试多运行几次

还有下面这个方法也可以试试

import backoff  
import openai 

openai.api_key= ''  # 你的OpenAI API
@backoff.on_exception(backoff.expo, openai.error.RateLimitError)
def completions_with_backoff(**kwargs):
    return openai.Completion.create(**kwargs)


completions_with_backoff(model="text-davinci-002", prompt="Once upon a time,")

还有就是先关掉代理,刷新页面,在切换其他代理,刷新一下可以了
若还是不行,就等几个小时自动就好了

  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

旺仔001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值