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

openai.error.RateLimitError 限流问题 #50

Closed
Ratten-fanger opened this issue Feb 6, 2023 · 18 comments
Closed

openai.error.RateLimitError 限流问题 #50

Ratten-fanger opened this issue Feb 6, 2023 · 18 comments

Comments

@Ratten-fanger
Copy link

[INFO][2023-02-06 15:49:21][open_ai_bot.py:20] - [OPEN_AI] query=@在吗
[ERROR][2023-02-06 15:49:21][wechat_channel.py:116] - can only concatenate str (not "NoneType") to str
Traceback (most recent call last):
File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 112, in _do_send
reply_text = super().build_reply_content(query, context).strip()
File "/root/chatgpt-on-wechat/channel/channel.py", line 31, in build_reply_content
return Bridge().fetch_reply_content(query, context)
File "/root/chatgpt-on-wechat/bridge/bridge.py", line 9, in fetch_reply_content
return bot_factory.create_bot("openAI").reply(query, context)
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 26, in reply
new_query = Session.build_session_query(query, from_user_id)
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 129, in build_session_query
prompt += "Q: " + conversation["question"] + "\n\n\nA: " + conversation["answer"] + "<|im_end|>\n"
TypeError: can only concatenate str (not "NoneType") to str

@zhayujie
Copy link
Owner

zhayujie commented Feb 6, 2023

完整报错信息:

openai.error.RateLimitError: The server had an error while processing your request. Sorry about that! 

你的config.json是如何配置的, 在吗前面有个@, 是触发条件吗

@Ratten-fanger
Copy link
Author

{
"open_ai_api_key": "xx",
"single_chat_prefix": [""],
"single_chat_reply_prefix": "",
"group_chat_prefix": ["@bot"],
"group_name_white_list": "ALL_GROUP",
"image_create_prefix": ["画", "看", "找"],
"conversation_max_tokens": 2000,
"character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你乐于回答人们的任何问题"
}

@Ratten-fanger
Copy link
Author

@是我手动加的,即使不加也报错
[INFO][2023-02-06 16:00:15][open_ai_bot.py:20] - [OPEN_AI] query=你好
[ERROR][2023-02-06 16:00:15][wechat_channel.py:116] - can only concatenate str (not "NoneType") to str
Traceback (most recent call last):
File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 112, in _do_send
reply_text = super().build_reply_content(query, context).strip()
File "/root/chatgpt-on-wechat/channel/channel.py", line 31, in build_reply_content
return Bridge().fetch_reply_content(query, context)
File "/root/chatgpt-on-wechat/bridge/bridge.py", line 9, in fetch_reply_content
return bot_factory.create_bot("openAI").reply(query, context)
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 26, in reply
new_query = Session.build_session_query(query, from_user_id)
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 129, in build_session_query
prompt += "Q: " + conversation["question"] + "\n\n\nA: " + conversation["answer"] + "<|im_end|>\n"
TypeError: can only concatenate str (not "NoneType") to str

@Ratten-fanger
Copy link
Author

配置文件不变,重启后就正常了。所以我现在也不能复现了

@zhayujie
Copy link
Owner

zhayujie commented Feb 6, 2023

[ERROR][2023-02-06 16:00:15][wechat_channel.py:116] - can only concatenate str (not "NoneType") to str

好的 我稍后看下

@ynzheng
Copy link

ynzheng commented Feb 6, 2023

同样的问题

@ynzheng
Copy link

ynzheng commented Feb 6, 2023

[INFO][2023-02-06 16:44:30][open_ai_bot.py:20] - [OPEN_AI] query=红包还给我[合十]
[ERROR][2023-02-06 16:44:32][open_ai_bot.py:51] - The server had an error while processing your request. Sorry about that!
Traceback (most recent call last):
File "/mnt/hkHomeData/home/ubuntu/github.com/zhayujie/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 39, in reply_text
response = openai.Completion.create(
File "/home/ubuntu/anaconda3/envs/py39/lib/python3.9/site-packages/openai/api_resources/completion.py", line 25, in create
return super().create(*args, **kwargs)
File "/home/ubuntu/anaconda3/envs/py39/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "/home/ubuntu/anaconda3/envs/py39/lib/python3.9/site-packages/openai/api_requestor.py", line 227, in request
resp, got_stream = self._interpret_response(result, stream)
File "/home/ubuntu/anaconda3/envs/py39/lib/python3.9/site-packages/openai/api_requestor.py", line 620, in _interpret_response
self._interpret_response_line(
File "/home/ubuntu/anaconda3/envs/py39/lib/python3.9/site-packages/openai/api_requestor.py", line 680, in _interpret_response_line
raise self.handle_error_response(
openai.error.RateLimitError: The server had an error while processing your request. Sorry about that!

@Cy9nusG4rd3n
Copy link

同样的问题,感觉不太稳定

[INFO][2023-02-06 16:35:16][open_ai_bot.py:20] - [OPEN_AI] query=在吗
[ERROR][2023-02-06 16:35:20][open_ai_bot.py:51] - The server had an error while processing your request. Sorry about that!
Traceback (most recent call last):
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 47, in reply_text
stop=["#"]
File "/usr/local/lib/python3.7/dist-packages/openai/api_resources/completion.py", line 25, in create
return super().create(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/openai/api_resources/abstract/engine_api_resource.py", line 160, in create
request_timeout=request_timeout,
File "/usr/local/lib/python3.7/dist-packages/openai/api_requestor.py", line 227, in request
resp, got_stream = self._interpret_response(result, stream)
File "/usr/local/lib/python3.7/dist-packages/openai/api_requestor.py", line 624, in _interpret_response
stream=False,
File "/usr/local/lib/python3.7/dist-packages/openai/api_requestor.py", line 681, in _interpret_response_line
rbody, rcode, resp.data, rheaders, stream_error=stream_error
openai.error.RateLimitError: The server had an error while processing your request. Sorry about that!
[ERROR][2023-02-06 16:35:20][wechat_channel.py:116] - object of type 'NoneType' has no len()
Traceback (most recent call last):
File "/root/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 112, in _do_send
reply_text = super().build_reply_content(query, context).strip()
File "/root/chatgpt-on-wechat/channel/channel.py", line 31, in build_reply_content
return Bridge().fetch_reply_content(query, context)
File "/root/chatgpt-on-wechat/bridge/bridge.py", line 9, in fetch_reply_content
return bot_factory.create_bot("openAI").reply(query, context)
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 31, in reply
Session.save_session(query, reply_content, from_user_id)
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 157, in save_session
Session.discard_exceed_conversation(user_session[user_id], max_tokens)
File "/root/chatgpt-on-wechat/bot/openai/open_ai_bot.py", line 167, in discard_exceed_conversation
count += len(history_conv["question"]) + len(history_conv["answer"])
TypeError: object of type 'NoneType' has no len()
image
image

@zhayujie
Copy link
Owner

zhayujie commented Feb 6, 2023

该问题已修复,重新拉取下代码即可解决。

问题原因 openai接口会偶发 出现访问速率超限的异常

openai.error.RateLimitError: The server had an error while processing your request. Sorry about that!

在保存到会话历史的时候,没有对这种异常数据做处理,导致后续对话都会失败。现在修复后,不会再影响后续对话。

@Ratten-fanger @ynzheng @Cy9nusG4rd3n

@xiaohua123456
Copy link

该问题已修复,重新拉取下代码即可解决。

问题原因 openai接口会偶发 出现访问速率超限的异常

openai.error.RateLimitError: The server had an error while processing your request. Sorry about that!

在保存到会话历史的时候,没有对这种异常数据做处理,导致后续对话都会失败。现在修复后,不会再影响后续对话。

@Ratten-fanger @ynzheng @Cy9nusG4rd3n

重新更新代码后仍然出现了该问题。

@tao19970417
Copy link

[INFO][2023-02-06 17:30:08][open_ai_bot.py:20] - [OPEN_AI] query=流浪地球
[ERROR][2023-02-06 17:30:10][open_ai_bot.py:52] - You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions.
Traceback (most recent call last):
File "C:\Users\aaa\PycharmProjects\chatgpt-on-wechat\bot\openai\open_ai_bot.py", line 40, in reply_text
response = openai.Completion.create(
File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_resources\completion.py", line 25, in create
return super().create(*args, **kwargs)
File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 227, in request
resp, got_stream = self._interpret_response(result, stream)
File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 620, in _interpret_response
self._interpret_response_line(
File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 680, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions.
[ERROR][2023-02-06 17:30:10][wechat_channel.py:116] - 'NoneType' object has no attribute 'strip'
Traceback (most recent call last):
File "C:\Users\aaa\PycharmProjects\chatgpt-on-wechat\channel\wechat\wechat_channel.py", line 112, in _do_send
reply_text = super().build_reply_content(query, context).strip()
AttributeError: 'NoneType' object has no attribute 'strip'

最新代码仍然出现了问题,麻烦看一下呢 @zhayujie

@Ratten-fanger
Copy link
Author

Ratten-fanger commented Feb 6, 2023

拉取最新代码后,会偶发openai.error.RateLimitError: The server had an error while processing your request. Sorry about that!
,但似乎不会影响后续问题了,十分感谢

@zhayujie
Copy link
Owner

zhayujie commented Feb 6, 2023

[INFO][2023-02-06 17:30:08][open_ai_bot.py:20] - [OPEN_AI] query=流浪地球 [ERROR][2023-02-06 17:30:10][open_ai_bot.py:52] - You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions. Traceback (most recent call last): File "C:\Users\aaa\PycharmProjects\chatgpt-on-wechat\bot\openai\open_ai_bot.py", line 40, in reply_text response = openai.Completion.create( File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_resources\completion.py", line 25, in create return super().create(*args, **kwargs) File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create response, _, api_key = requestor.request( File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 227, in request resp, got_stream = self._interpret_response(result, stream) File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 620, in _interpret_response self._interpret_response_line( File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 680, in _interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions. [ERROR][2023-02-06 17:30:10][wechat_channel.py:116] - 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "C:\Users\aaa\PycharmProjects\chatgpt-on-wechat\channel\wechat\wechat_channel.py", line 112, in _do_send reply_text = super().build_reply_content(query, context).strip() AttributeError: 'NoneType' object has no attribute 'strip'

最新代码仍然出现了问题,麻烦看一下呢 @zhayujie

这里报错的是

You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions.

你有修改使用的模型嘛

@tao19970417
Copy link

[INFO][2023-02-06 17:30:08][open_ai_bot.py:20] - [OPEN_AI] query=流浪地球 [ERROR][2023-02-06 17:30:10][open_ai_bot.py:52] - You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions. Traceback (most recent call last): File "C:\Users\aaa\PycharmProjects\chatgpt-on-wechat\bot\openai\open_ai_bot.py", line 40, in reply_text response = openai.Completion.create( File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_resources\completion.py", line 25, in create return super().create(*args, **kwargs) File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create response, _, api_key = requestor.request( File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 227, in request resp, got_stream = self._interpret_response(result, stream) File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 620, in _interpret_response self._interpret_response_line( File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\openai\api_requestor.py", line 680, in _interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions. [ERROR][2023-02-06 17:30:10][wechat_channel.py:116] - 'NoneType' object has no attribute 'strip' Traceback (most recent call last): File "C:\Users\aaa\PycharmProjects\chatgpt-on-wechat\channel\wechat\wechat_channel.py", line 112, in _do_send reply_text = super().build_reply_content(query, context).strip() AttributeError: 'NoneType' object has no attribute 'strip'
最新代码仍然出现了问题,麻烦看一下呢 @zhayujie

这里报错的是

You requested a model that is not compatible with this engine. Please contact us through our help center at help.openai.com for further questions.

你有修改使用的模型嘛

我没有改过诶,模型哪里可以修改吗?

@zhayujie
Copy link
Owner

zhayujie commented Feb 6, 2023

重新更新代码后仍然出现了该问题。

这个报错是 openai 做的访问速率限制,还是有可能出现的,但是应该不会影响后续对话了吧?

@ninirobot
Copy link

ninirobot commented Feb 6, 2023

大佬,我也出现了openai.error.RateLimitError: The server had an error while processing your request. Sorry about that!的问题,这个能在哪里修补一下提高这个速率上限吗?后续对话貌似不影响,好像重新问几次也能继续对话。

zhayujie pushed a commit that referenced this issue Feb 6, 2023
zhayujie added a commit that referenced this issue Feb 6, 2023
@zhayujie
Copy link
Owner

zhayujie commented Feb 6, 2023

最新的提交中对于 openai.error.RateLimitError 异常进行了捕获,默认sleep 5s后重试一次,如果仍然报错则回复兜底话术。白天观察下报错情况,能否重试成功。


P.S. openai后台应该是根据当时 整体的负载压力来进行限流的,我在晚上较快频率提问了很多次也没能复现这个问题。

@zhayujie zhayujie changed the title 最新版(2023.02.05)运行半小时后出现如下报错 openai.error.RateLimitError: The server had an error while processing your request. Sorry about that! Feb 6, 2023
@zhayujie zhayujie changed the title openai.error.RateLimitError: The server had an error while processing your request. Sorry about that! openai.error.RateLimitError 限流问题 Feb 6, 2023
@xiaohua123456
Copy link

重新更新代码后仍然出现了该问题。

这个报错是 openai 做的访问速率限制,还是有可能出现的,但是应该不会影响后续对话了吧?

已经不影响后续对话了。

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

No branches or pull requests

7 participants