zhayujie / chatgpt-on-wechat

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT4.0/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
https://docs.link-ai.tech/cow
MIT License
28.44k stars 7.55k forks source link

channel切换为wechaty后,编译遇到问题,报错,提示'WechatyChannel' object has no attribute 'handler_pool' #1748

Open SamYueHW opened 5 months ago

SamYueHW commented 5 months ago

前置确认

⚠️ 搜索issues中是否已存在类似问题

操作系统类型?

MacOS

运行的python版本是?

python 3.7

使用的chatgpt-on-wechat版本是?

Latest Release

运行的channel类型是?

wxy(个人微信, wechaty)

复现步骤 🕹

No response

问题描述 😯

config.json里已经改为 "channel_type": "wxy", ”wechaty_puppet_service_token": "puppet_padlocal_d6。。。“

终端日志 📒

[INFO][2024-02-14 23:18:09][role.py:69] - [Role] inited
[INFO][2024-02-14 23:18:09][dungeon.py:56] - [Dungeon] inited
[INFO][2024-02-14 23:18:09][hello.py:24] - [Hello] inited
[INFO][2024-02-14 23:18:09][finish.py:23] - [Finish] inited
[ERROR][2024-02-14 23:18:09][app.py:66] - App startup failed!
[ERROR][2024-02-14 23:18:09][app.py:67] - 'WechatyChannel' object has no attribute 'handler_pool'
Traceback (most recent call last):
  File "/Users/samuelyue/Desktop/Coding/cow/chatgpt-on-wechat/app.py", line 61, in run
    start_channel(channel_name)
  File "/Users/samuelyue/Desktop/Coding/cow/chatgpt-on-wechat/app.py", line 40, in start_channel
    channel.startup()
  File "/Users/samuelyue/Desktop/Coding/cow/chatgpt-on-wechat/channel/wechat/wechaty_channel.py", line 42, in startup
    asyncio.run(self.main())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/Users/samuelyue/Desktop/Coding/cow/chatgpt-on-wechat/channel/wechat/wechaty_channel.py", line 47, in main
    self.handler_pool._initializer = lambda: asyncio.set_event_loop(loop)
AttributeError: 'WechatyChannel' object has no attribute 'handler_pool'
mashagua commented 5 months ago

我也遇到了,解决了吗

SamYueHW commented 5 months ago

没解决

mashagua @.***>于2024年2月19日 周一下午8:21写道:

我也遇到了,解决了吗

— Reply to this email directly, view it on GitHub https://github.com/zhayujie/chatgpt-on-wechat/issues/1748#issuecomment-1952020653, or unsubscribe https://github.com/notifications/unsubscribe-auth/A62JMPYAUWKN2PS24VK2JWDYUMKP7AVCNFSM6AAAAABDIPNBA2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJSGAZDANRVGM . You are receiving this because you authored the thread.Message ID: @.***>

fireStarGXZ commented 4 months ago

我也出现这个问题了 [ERROR][2024-02-29 21:48:31][app.py:66] - App startup failed! [ERROR][2024-02-29 21:48:31][app.py:67] - 'WechatyChannel' object has no attribute 'handler_pool' Traceback (most recent call last): File "/root/chatgpt-on-wechat/app.py", line 61, in run start_channel(channel_name) File "/root/chatgpt-on-wechat/app.py", line 40, in start_channel channel.startup() File "/root/chatgpt-on-wechat/channel/wechat/wechaty_channel.py", line 42, in startup asyncio.run(self.main()) File "/usr/lib64/python3.8/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/root/chatgpt-on-wechat/channel/wechat/wechaty_channel.py", line 47, in main self.handler_pool._initializer = lambda: asyncio.set_event_loop(loop) AttributeError: 'WechatyChannel' object has no attribute 'handler_pool'

felixiao commented 4 months ago

遇到同样问题,有人知道怎么解决嘛?还有wechaty的个微的token是要去买嘛?免费的只有7天时间

mashagua commented 4 months ago

遇到同样问题,有人知道怎么解决嘛?还有wechaty的个微的token是要去买嘛?免费的只有7天时间

对,是要去买,一个月200,一年的话打5折,这个就是不知道它对应的wechaty的版本是哪个,没有写在requirements.txt里,最新装的好像没有那个属性

gattaca2017 commented 3 months ago
from channel.chat_channel import ChatChannel, handler_pool   # add 

class WechatyChannel(ChatChannel):
    NOT_SUPPORT_REPLYTYPE = []

    def __init__(self):
        super().__init__()
        self.handler_pool = handler_pool    # add this line
kvgary commented 3 months ago

@SamYueHW 问题解决了吗?

PinkPanther-ny commented 3 months ago

已解决,请看我的这个PR https://github.com/zhayujie/chatgpt-on-wechat/pull/1884

mashagua commented 3 months ago

self.handler_pool = handler_pool # add this line

添加了之后原来的问题是没有了,但是出现了 Traceback (most recent call last): File "/root/miniconda3/lib/python3.10/site-packages/wechaty/wechaty.py", line 445, in start await self.puppet.start() File "/root/miniconda3/lib/python3.10/site-packages/wechaty_puppet_service/puppet.py", line 911, in start self._init_puppet() File "/root/miniconda3/lib/python3.10/site-packages/wechaty_puppet_service/puppet.py", line 876, in _init_puppet raise WechatyPuppetGrpcError( wechaty_puppet.exceptions.WechatyPuppetGrpcError: WechatyPuppetGrpcError('can"t fetch endpoint from chatie server. You can try it later, or make sure that your pc can connect to heroku server ', None, None)

finexss commented 1 month ago

self.handler_pool = handler_pool # add this line

添加了之后原来的问题是没有了,但是出现了 Traceback (most recent call last): File "/root/miniconda3/lib/python3.10/site-packages/wechaty/wechaty.py", line 445, in start await self.puppet.start() File "/root/miniconda3/lib/python3.10/site-packages/wechaty_puppet_service/puppet.py", line 911, in start self._init_puppet() File "/root/miniconda3/lib/python3.10/site-packages/wechaty_puppet_service/puppet.py", line 876, in _init_puppet raise WechatyPuppetGrpcError( wechaty_puppet.exceptions.WechatyPuppetGrpcError: WechatyPuppetGrpcError('can"t fetch endpoint from chatie server. You can try it later, or make sure that your pc can connect to heroku server ', None, None)

是的,我的也出现了,不知道是不是wechaty的版本不对还是其它什么原因。