talkingwallace / ChatGPT-Paper-Reader

This repo offers a simple interface that helps you to read&summerize research papers in pdf format. You can ask some questions after reading. This interface is developed based on openai API and using GPT-3.5-turbo model.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

apikey访问频率问题

reckonzzz opened this issue · comments

openai.error.RateLimitError: Rate limit reached for default-gpt-3.5-turbo in organization org-PanV93eoQzPe3QALIzkJ8Iof on requests per min. Limit: 3 / min. Please try again in 20s.

请问这是因为访问频率过快吗?怎么解决这个问题呢?

commented

看起来是的 要不等一阵再试试看 或者降低一下发送频率

改一下 gpt_reader/bot/openai.pyOpenAIBotCore 这个类的 communicate 函数就好了。

def communicate(self, msg: List[dict], return_raw_text=True):
    received = False
    while not received:
        try:
            response = openai.ChatCompletion.create(
                model=self.model,
                messages=msg,
                temperature=self.temperature
            )
        except openai.error.RateLimitError:
            time.sleep(20)
        else:
            received = True

    if return_raw_text:
        return response["choices"][0]["message"]["content"]
    else:
        return response