Closed Alpaca4610 closed 1 year ago
Plugin: ChatGPT官方接口版
✅ 所有测试通过,一切准备就绪!
✅ 标签: ChatGPT-#ea5252, OpenAI-#52ea92。 ✅ 项目 主页 返回状态码 200。 ✅ 包 nonebot-plugin-chatgpt-turbo 已发布至 PyPI。 ✅ 插件加载测试通过。
💡 如需修改信息,请直接修改 issue,机器人会自动更新检查结果。 💡 当插件加载测试失败时,请发布新版本后在当前页面下评论任意内容以触发测试。
♻️ 评论已更新至最新检查结果
💪 Powered by NoneBot2 Publish Bot
📃 商店发布检查结果
Plugin: ChatGPT官方接口版
⚠️ 在发布检查过程中,我们发现以下问题:
* ⚠️ 插件加载测试未通过。测试输出插件 nonebot-plugin-chatgpt-turbo 的信息如下: name : nonebot-plugin-chatgpt-turbo version : 0.1.0 description : A nonebot plugin for openai gpt3.5-turbo dependencies - httpx >=0.23.3,<0.24.0 - nonebot-adapter-onebot >=2.2.1,<3.0.0 - nonebot2 >=2.0.0rc3,<3.0.0 - openai >=0.27.0,<0.28.0 插件 nonebot_plugin_chatgpt_turbo 加载出错: 03-02 17:33:35 [SUCCESS] nonebot | NoneBot is initializing... 03-02 17:33:35 [INFO] nonebot | Current Env: prod 03-02 17:33:36 [ERROR] nonebot | Failed to import "nonebot_plugin_chatgpt_turbo" Traceback (most recent call last): File "/home/runner/work/nonebot2/nonebot2/plugin_test/runner.py", line 4, in <module> valid = load_plugin("nonebot_plugin_chatgpt_turbo") File "/home/runner/.cache/pypoetry/virtualenvs/plugin-test-rYmcgvOP-py3.10/lib/python3.10/site-packages/nonebot/plugin/load.py", line 34, in load_plugin return manager.load_plugin(module_path) > File "/home/runner/.cache/pypoetry/virtualenvs/plugin-test-rYmcgvOP-py3.10/lib/python3.10/site-packages/nonebot/plugin/manager.py", line 141, in load_plugin module = importlib.import_module(name) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "/home/runner/.cache/pypoetry/virtualenvs/plugin-test-rYmcgvOP-py3.10/lib/python3.10/site-packages/nonebot/plugin/manager.py", line 233, in exec_module super().exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/home/runner/.cache/pypoetry/virtualenvs/plugin-test-rYmcgvOP-py3.10/lib/python3.10/site-packages/nonebot_plugin_chatgpt_turbo/__init__.py", line 10, in <module> api_key = nonebot.get_driver().config.openai_api_key AttributeError: 'Config' object has no attribute 'openai_api_key'
详情
* ✅ 标签: ChatGPT-#ea5252, OpenAI-#52ea92。* ✅ 项目 [主页](https://github.com/Alpaca4610/nonebot_plugin_chatgpt_turbo) 返回状态码 200。* ✅ 包 [nonebot-plugin-chatgpt-turbo](https://pypi.org/project/nonebot-plugin-chatgpt-turbo/) 已发布至 PyPI。
💡 如需修改信息,请直接修改 issue,机器人会自动更新检查结果。 💡 当插件加载测试失败时,请发布新版本后在当前页面下评论任意内容以触发测试。
♻️ 评论已更新至最新检查结果
💪 Powered by NoneBot2 Publish Bot
test
你是不是忘记在PyPI上发布新版了
你是不是忘记在PyPI上发布新版了
orz,第一次上传插件没太注意这些细节,现在已经在pypi上更新了QAQ
请用openai的异步接口,你这异步太假了。openai默认是requests
orz,我之前直接把OpenAI官网API文档的调用example搬下来了。已改为第二种(第一种使用的时候有点问题,不知道是不是新版API文档还没更新)
你这也没改对啊,不是让你改session啊
async def get_response(user_id, content):
openai.api_key = api_key
- res_ = openai.ChatCompletion.create(
+ res_ = await openai.ChatCompletion.acreate(
model=model_id,
messages=[
{"role": "user", "content": content}
]
)
你这也没改对啊,不是让你改session啊
async def get_response(user_id, content): openai.api_key = api_key - res_ = openai.ChatCompletion.create( + res_ = await openai.ChatCompletion.acreate( model=model_id, messages=[ {"role": "user", "content": content} ] )
使用acreate()函数进行请求会返回Error communicating with OpenAI的错误信息。
已在代码中添加asyncio
不是,我不是给你了修改样例了吗,你在瞎改啥( 有错误你不应该找openai提issue吗,你这样虚假的异步只会卡住别人的机器人
不是,我不是给你了修改样例了吗,你在瞎改啥(
目前官方的异步API调用会出错,返回不了信息(
不是,我不是给你了修改样例了吗,你在瞎改啥(
目前官方的异步API调用会出错,返回不了信息(
model设置为最新的gpt-3.5-turbo时,调用会长时间无响应,返回Error communicating with OpenAI。所以我就自己整了个asyncio(
await openai.ChatCompletion.acreate
另外你的插件也不依赖httpx,不需要这个依赖
我的代码中使用的就是openai.ChatCompletion.create
函数( 问题是在于使用await openai.ChatCompletion.acreate
发送请求时会出现错误,而改用openai.ChatCompletion.create
才可以正常返回结果。
在下面的测试中,我用不同的命令触发异步和非异步的访问请求,结果是使用await openai.ChatCompletion.acreate
时无法返回结果。
https://github.com/openai/openai-python/issues/250#issuecomment-1451599906
https://github.com/openai/openai-python/issues/250#issuecomment-1451613399
看了openai-python项目下的两条issue,感觉是openai那边还没有更新异步请求函数( ,openai.ChatCompletion.**a**create
目前还无法使用
删除pyproject.poml中的httpx依赖
等他异步接口修好了再合吧
看openai的issue说是没有问题了,你再试试?
看openai的issue说是没有问题了,你再试试?
刚刚试了下还是不行,acreate没有修好。 https://github.com/openai/openai-python/issues/278#issue-1611338785
0.2.0更新:使用asyncio库的loop.run_in_executor实现异步调用,增加每个用户的上下文关联回复功能,增加代理设置功能
0.2.1更新:使用OpenAI的异步接口和代理
你依赖里多写了一个asyncio
更新依赖
你在pypi发版了吗
你在pypi发版了吗
发了
update
@Alpaca4610 @yanyongyu 本地挂了vpn,proxy = ‘http:\127.0.0.1:8001',升级了aiohttp版本3.8.4,在调用res_ = await openai.ChatCompletion.acreate( model=self.model_id, messages=self.content )
时,还是会出现Error communicating with OpenAI,是什么原因?
@Alpaca4610 @yanyongyu 本地挂了vpn,proxy = ‘http:\127.0.0.1:8001',升级了aiohttp版本3.8.4,在调用
res_ = await openai.ChatCompletion.acreate( model=self.model_id, messages=self.content )
时,还是会出现Error communicating with OpenAI,是什么原因?
注意proxy的端口和你VPN设置的端口一致,另外提issue请到https://github.com/Alpaca4610/nonebot_plugin_chatgpt_turbo/issues
插件名称:
ChatGPT官方接口版
插件功能:
适配新版OpenAI API的nonebot插件,可以调用官方稳定版ChatGPT进行回复
PyPI 项目名:
nonebot-plugin-chatgpt-turbo
插件 import 包名:
nonebot_plugin_chatgpt_turbo
插件项目仓库/主页链接:
https://github.com/Alpaca4610/nonebot_plugin_chatgpt_turbo
标签:
[{"label":"ChatGPT","color":"#ea5252"},{"label":"OpenAI","color":"#52ea92"}]