Quan666 / ELFChatBot

闲聊QQ机器人,也就是人工智障
GNU General Public License v3.0
102 stars 5 forks source link

关于Chatgpt Token #19

Closed binc0120 closed 1 year ago

binc0120 commented 1 year ago

`12-07 04:36:13 [ERROR] nonebot | Failed to import "ELFChatBot" Traceback (most recent call last): File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\username\AppData\Local\Programs\Python\Python310\Scripts\nb.exe__main.py", line 7, in sys.exit(main()) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in call return self.main(*args, kwargs) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main rv = self.invoke(ctx) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke return callback(*args, **kwargs) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nb_cli\commands\main.py", line 30, in run run_bot(file, app) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nb_cli\handlers\deploy.py", line 20, in run_bot module = importlib.import_module(module_name) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Users\username\Desktop\Mybot.\bot.py", line 8, in nonebot.load_plugins("src/plugins") File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\load.py", line 39, in load_plugins return manager.load_all_plugins() File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 172, in load_all_plugins return set( File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 173, in filter(None, (self.load_plugin(name) for name in self.available_plugins))

File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 148, in load_plugin module = importlib.import_module( File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\plugin\manager.py", line 237, in exec_module super().exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Users\username\Desktop\Mybot.\src\plugins\ELFChatBot__init__.py", line 1, in from . import ELF_bot, Random_bot, chatgpt_bot File "C:\Users\username\Desktop\Mybot.\src\plugins\ELFChatBot\ELF_bot.py", line 10, in from .config import config File "C:\Users\username\Desktop\Mybot.\src\plugins\ELFChatBot\config.py", line 29 chatgpt_session_token: Optional[str] = eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0.....QqaqJBBc1A ^ SyntaxError: invalid decimal literal`

Quan666 commented 1 year ago

你没加双引号,而且你把你token放上来了

binc0120 commented 1 year ago

谢谢!我看这个token经常变还以为放上来没关系... 另外想问一下这是什么原因...发送了chatgpt给机器人后能获得回复“输入你的问题” 但之后输入类似123或你好都会报错 `[ERROR] nonebot | Running matcher <Matcher from src.plugins.ELFChatBot.ELF_bot, type=message, priority=5, temp=False> failed. Traceback (most recent call last): File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\username\AppData\Local\Programs\Python\Python310\Scripts\nb.exe__main.py", line 7, in sys.exit(main()) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in call return self.main(*args, kwargs) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main rv = self.invoke(ctx) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke return callback(*args, *kwargs) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nb_cli\commands\main.py", line 30, in run run_bot(file, app) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nb_cli\handlers\deploy.py", line 25, in run_bot nonebot.run(app=f"{module_name}:{app}") File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot__init__.py", line 261, in run get_driver().run(args, *kwargs) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\drivers\fastapi.py", line 170, in run uvicorn.run( File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\main.py", line 576, in run server.run() File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 636, in run_until_complete self.run_forever() File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py", line 321, in run_forever super().run_forever() File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 603, in run_forever self._run_once() File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1899, in _run_once handle._run() File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, self._args) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\message.py", line 146, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\message.py", line 196, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\internal\matcher.py", line 672, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\internal\matcher.py", line 639, in simple_run await handler( File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\nonebot\dependencies__init.py", line 92, in call__ return await self.call(**values) File "C:\Users\username\Desktop\Mybot.\src\plugins\ELFChatBot\ELF_bot.py", line 126, in handle_Chat r_msg = await bot.sendMsg(msg) File "C:\Users\username\Desktop\Mybot.\src\plugins\ELFChatBot\ChatBotApi\baiduBot.py", line 101, in sendMsg self._api_url + "?access_token=" + self._token, TypeError: can only concatenate str (not "NoneType") to str`

Quan666 commented 1 year ago

把你聊天记录放上来看看

binc0120 commented 1 year ago

zzz 1:00:44 PM chatgpt

zzz 1:06:52 PM chatgpt

bot 1:06:53 PM 输入你的问题

重试(重新回答)

刷新(重置上下文)

说 再见 结束聊天~

zzz 1:07:00 PM 你好

bot 1:07:02 PM can only concatenate str (not "NoneType") to str

zzz 1:07:14 PM 再见

bot 1:07:15 PM 下次再聊哟!

zzz 1:07:23 PM 你好

zzz 1:07:38 PM chatgpt 你好

bot 1:07:39 PM can only concatenate str (not "NoneType") to str

zzz 1:07:50 PM 你好

bot 1:07:51 PM can only concatenate str (not "NoneType") to str

zzz 1:08:18 PM 再见

bot 1:08:21 PM 下次再聊哟!

zzz 1:08:29 PM 刷新

zzz 1:10:15 PM chatgpt

bot 1:10:16 PM 输入你的问题

重试(重新回答)

刷新(重置上下文)

说 再见 结束聊天~

zzz 1:10:26 PM 你好?

bot 1:10:26 PM can only concatenate str (not "NoneType") to str

zzz 1:11:25 PM 1+1

bot 1:11:26 PM can only concatenate str (not "NoneType") to str

Quan666 commented 1 year ago

是最新版本吗

binc0120 commented 1 year ago

我一开始是根据https://github.com/Quan666/ELF_RSS/blob/2.0/docs/%E9%83%A8%E7%BD%B2%E6%95%99%E7%A8%8B.md部署然后再把plugins/ELFChatBot复制到部署好的plugin里面,之后就是按照说明,聊天的时候出现can only concatenate str (not "NoneType") to str。

我刚刚试了一下直接下载这里的代码到本地,然后再根据步骤安装requirements,在nb run的时候出现了 ModuleNotFoundError: No module named 'nonebot.adapters.cqhttp 尝试了 https://github.com/nonebot/discussions/discussions/13#discussioncomment-738461 https://github.com/nonebot/discussions/discussions/161 还是不行...

Quan666 commented 1 year ago

你按照之前的步骤,下载最新代码试试,现在这个应该是你依赖出了问题,重新部署试试

Quan666 commented 1 year ago

下载最新的 requirements.txt 后再试试

binc0120 commented 1 year ago

谢谢你的帮助,我发现除了第一次部署的时候按照流程操作然后nb run没问题以外,之后几次重新部署以及最新的这次用nb run都会出现 ModuleNotFoundError: No module named 'nonebot.adapters.cqhttp

binc0120 commented 1 year ago

用最开始部署的(nb run不会出现问题的)解决了... (不知道为什么重新部署的那几次没办法nb run,明明是同样操作流程...) 下载最新的ELFChatBot然后复制到plugins里面,然后在src/plugins/ELFChatBot/ChatBotApi 里改了authorization和session_token,试着启动和chatgpt开始聊天突然神奇的正常了... 非常感谢!