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.
739 stars 110 forks source link

apikey访问频率问题 #19

Open reckonzzz opened 1 year ago

reckonzzz commented 1 year ago

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.

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

talkingwallace commented 1 year ago

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

namasikanam commented 1 year ago

改一下 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