Suxmx / nonebot_plugin_chatgpt_on_qq

基于chatGPT-3.5-turboAPI的nonebot插件
51 stars 9 forks source link

连接openai时后台报错,聊天窗口没有输出信息 #18

Closed Earmo closed 1 year ago

Earmo commented 1 year ago
04-23 03:00:51 [SUCCESS] nonebot | OneBot V11 1464331775 | [message.group.normal]: Message 514990020 from 1148409172@[群:162918419] "大书库 什么是猫娘"

04-23 03:00:51 [INFO] nonebot | Event will be handled by Matcher(type='message', module=plugins.black_word)

04-23 03:00:51 [INFO] nonebot | Event will be handled by Matcher(type='message', module=plugins.mute)

04-23 03:00:51 [INFO] nonebot | Matcher(type='message', module=plugins.black_word) running complete

04-23 03:00:51 [INFO] nonebot | Event will be handled by Matcher(type='message', module=extensive_plugin.nonebot_plugin_chatgpt_on_qq-main2)

04-23 03:00:51 [INFO] nonebot | Event will be handled by Matcher(type='message', module=basic_plugins.chat_history.chat_message)

04-23 03:00:51 [INFO] nonebot | Matcher(type='message', module=plugins.mute) running complete

04-23 03:00:51 [INFO] nonebot | Event will be handled by Matcher(type='message', module=plugins.parse_bilibili_json)

04-23 03:00:51 [INFO] nonebot | Matcher(type='message', module=plugins.parse_bilibili_json) running complete

04-23 03:00:51 [INFO] nonebot | Matcher(type='message', module=basic_plugins.chat_history.chat_message) running complete

04-23 03:00:51 [INFO] nonebot | Matcher(type='message', module=extensive_plugin.nonebot_plugin_chatgpt_on_qq-main2) running complete

04-23 03:00:51 [ERROR] nonebot | Running Matcher(type='message', module=extensive_plugin.nonebot_plugin_chatgpt_on_qq-main2) failed.

Traceback (most recent call last):

  File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 588, in arequest_raw

    result = await session.request(**request_kwargs)

  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 492, in _request

    req = self._request_class(

  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 305, in __init__

    self.update_host(url)

  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 366, in update_host

    raise InvalidURL(url)

aiohttp.client_exceptions.InvalidURL: /chat/completions

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt_on_qq-main2/chatGPT.py", line 73, in ask

    completion = await self._get_completion(user_input, temperature)

  File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt_on_qq-main2/chatGPT.py", line 87, in _get_completion

    return await openai.ChatCompletion.acreate(

  File "/usr/local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 45, in acreate

    return await super().acreate(*args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 217, in acreate

    response, _, api_key = await requestor.arequest(

  File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 300, in arequest

    result = await self.arequest_raw(

  File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 605, in arequest_raw

    raise error.APIConnectionError("Error communicating with OpenAI") from e

openai.error.APIConnectionError: Error communicating with OpenAI

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/zhenxun_bot/bot.py", line 21, in <module>

    nonebot.run()

  File "/usr/local/lib/python3.9/site-packages/nonebot/__init__.py", line 273, in run

    get_driver().run(*args, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/nonebot/drivers/fastapi.py", line 172, in run

    uvicorn.run(

  File "/usr/local/lib/python3.9/site-packages/uvicorn/main.py", line 569, in run

    server.run()

  File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run

    return asyncio.run(self.serve(sockets=sockets))

  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run

    return loop.run_until_complete(main)

  File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 142, in _check_matcher

    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

> File "/usr/local/lib/python3.9/site-packages/nonebot/message.py", line 188, in _run_matcher

    await matcher.run(bot, event, state, stack, dependency_cache)

  File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run

    await self.simple_run(bot, event, state, stack, dependency_cache)

  File "/usr/local/lib/python3.9/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run

    await handler(

  File "/usr/local/lib/python3.9/site-packages/nonebot/dependencies/__init__.py", line 108, in __call__

    return await cast(Callable[..., Awaitable[R]], self.call)(**values)

  File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt_on_qq-main2/__init__.py", line 66, in _

    answer = await newConversation.ask(userInput)

  File "/home/zhenxun_bot/extensive_plugin/nonebot_plugin_chatgpt_on_qq-main2/chatGPT.py", line 78, in ask

    raise ConnectionError

ConnectionError

image

配置如下 image

Suxmx commented 1 year ago

image 感觉最近好多这个报错啊 可以试试里面的解决方案

17

Suxmx commented 1 year ago

安装之后有成功对话过吗

Earmo commented 1 year ago

image 感觉最近好多这个报错啊 可以试试里面的解决方案 #17

删除代理的协议和后缀/吗,这个试过了,不行

Earmo commented 1 year ago

安装之后有成功对话过吗

指令是没问题的,但是连接openai不行 image

Suxmx commented 1 year ago

image 感觉最近好多这个报错啊 可以试试里面的解决方案 #17

删除代理的协议和后缀/吗,这个试过了,不行

不是 是改openai里的源码hhh 但是我没遇到过 所以感觉这个问题很玄学

image 如果确认配置文件里的代理和本身的代理都没问题的话 你的报错和 #10 的很像 都是Invalid URL image

0EL`0HXUJOJS677$HX2(8

@rick23318 他的解决方案是直接找到了openai库的代码 在/chat/completions前面加上了https://api.openai.com/v1的前缀你可以试试

Earmo commented 1 year ago

image 感觉最近好多这个报错啊 可以试试里面的解决方案 #17

删除代理的协议和后缀/吗,这个试过了,不行

不是 是改openai里的源码hhh 但是我没遇到过 所以感觉这个问题很玄学

image 如果确认配置文件里的代理和本身的代理都没问题的话 你的报错和 #10 的很像 都是Invalid URL image 0EL`0HXUJOJS677$HX2(8 @rick23318 他的解决方案是直接找到了openai库的代码 在/chat/completions前面加上了https://api.openai.com/v1的前缀你可以试试

这个可以👍

Suxmx commented 1 year ago

解决了?

Earmo commented 1 year ago

解决了?

是的

Suxmx commented 1 year ago

ok

F1Justin commented 1 year ago

我也遇到同样的问题,在加上了https://api.openai.com/v1的前缀以及删去代理的https://之后运行成功了

Suxmx commented 1 year ago

我也遇到同样的问题,在加上了https://api.openai.com/v1的前缀以及删去代理的https://之后运行成功了 好诡异...总不能是openai库出问题了吧...