zhayujie / bot-on-anything

Connect AI models (like ChatGPT-3.5/4.0, Baidu Yiyan, New Bing, Bard) to apps (like Wechat, public account, DingTalk, Telegram, QQ). 将 ChatGPT、必应、文心一言、谷歌Bard 等对话模型连接各类应用,如微信、公众号、QQ、Telegram、Gmail、Slack、Web、企业微信、飞书、钉钉等。
MIT License
3.89k stars 911 forks source link

Bing接入微信不成功 #181

Open Bin-fan opened 1 year ago

Bin-fan commented 1 year ago

bing接入微信不成功,请各位大佬指导。

参考配置完后config.json如下,cookies已隐藏,配置中完整。

 {
    "model": {
    "type" : "bing",
    "openai": {
      "api_key": "YOUR API KEY",
      "model": "gpt-3.5-turbo",
      "proxy": "",
      "conversation_max_tokens": 1000,
      "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。"
    },
    "baidu": {
      "acs_token": "YOUR ACS TOKEN",
      "cookie": "YOUR COOKIE"
    },
    "bing":{
        "cookies":[
       {
        "domain": ".bing.com",
        "expirationDate": 1680531349.764501,
        "hostOnly": false,
        "httpOnly": false,
        "name": "_U",
        "path": "/",
        "sameSite": "no_restriction",
        "secure": true,
        "session": false,
        "storeId": null,
        "value": "1Tsm********OmZg"
        }
      ]
    }
  },
 "channel": {
    "type": "wechat",
    "single_chat_prefix": ["Bing", "@Bing"],
    "single_chat_reply_prefix": "[Bing] ",
    "group_chat_prefix": ["@Bing"],
    "group_name_white_list": ["ChatGPT测试群"],
    "image_create_prefix": ["画", "看", "找一张"],

    "terminal": {
    },

    "wechat": {
    },

    "wechat_mp": {
      "token": "YOUR TOKEN",
      "port": "8088"
    },

    "gmail": {
      "subject_keyword": ["bot", "@bot"],
      "host_email": "xxxx@gmail.com",
      "host_password": "GMAIL ACCESS KEY"
    },

    "telegram": {
      "bot_token": "xx:xx"
    },

    "slack": {
      "slack_bot_token": "xoxb-xxxx",
      "slack_app_token": "xapp-xxxx"
    },

    "http": {
      "http_auth_secret_key": "6d25a684-9558-11e9-aa94-efccd7a0659b",
      "http_auth_password": "6.67428e-11",
      "port": "80"
    }
  }
}

可以正常扫描登录,登录成功,无法获消息和回应日志如下,中间有尝试重新登录,可以登录但消息还是没有回复。

载入环节
{'model': {'type': 'bing', 'openai': {'api_key': 'YOUR API KEY', 'model': 'gpt-3.5-turbo', 'proxy': '', 'conversation_max_tokens': 1000, 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, 'baidu': {'acs_token': 'YOUR ACS TOKEN', 'cookie': 'YOUR COOKIE'}, 'bing': {'cookies': [{'domain': '.bing.com', 'expirationDate': 1680531349.764501, 'hostOnly': False, 'httpOnly': False, 'name': '_U', 'path': '/', 'sameSite': 'no_restriction', 'secure': True, 'session': False, 'storeId': None, 'value': '1Tsm********OmZg'}]}}, 'channel': {'type': 'wechat', 'single_chat_prefix': ['Bing', '@Bing'], 'single_chat_reply_prefix': '[Bing] ', 'group_chat_prefix': ['@Bing'], 'group_name_white_list': ['ChatGPT测试群'], 'image_create_prefix': ['画', '看', '找一张'], 'terminal': {}, 'wechat': {}, 'wechat_mp': {'token': 'YOUR TOKEN', 'port': '8088'}, 'gmail': {'subject_keyword': ['bot', '@bot'], 'host_email': 'xxxx@gmail.com', 'host_password': 'GMAIL ACCESS KEY'}, 'telegram': {'bot_token': 'xx:xx'}, 'slack': {'slack_bot_token': 'xoxb-xxxx', 'slack_app_token': 'xapp-xxxx'}, 'http': {'http_auth_secret_key': '6d25a684-9558-11e9-aa94-efccd7a0659b', 'http_auth_password': '6.67428e-11', 'port': '80'}}}
[INFO][2023-03-20 15:26:32][log.py:34] - [INIT] Start up: bing on wechat
█
Getting uuid of QR code.
Downloading QR code.
百度云接口配置不存在
{'model': {'type': 'bing', 'openai': {'api_key': 'YOUR API KEY', 'model': 'gpt-3.5-turbo', 'proxy': '', 'conversation_max_tokens': 1000, 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, 'baidu': {'acs_token': 'YOUR ACS TOKEN', 'cookie': 'YOUR COOKIE'}, 'bing': {'cookies': [{'domain': '.bing.com', 'expirationDate': 1680531349.764501, 'hostOnly': False, 'httpOnly': False, 'name': '_U', 'path': '/', 'sameSite': 'no_restriction', 'secure': True, 'session': False, 'storeId': None, 'value': '1Tsm********OmZg'}]}}, 'channel': {'type': 'wechat', 'single_chat_prefix': ['Bing', '@Bing'], 'single_chat_reply_prefix': '[Bing] ', 'group_chat_prefix': ['@Bing'], 'group_name_white_list': ['ChatGPT测试群'], 'image_create_prefix': ['画', '看', '找一张'], 'terminal': {}, 'wechat': {}, 'wechat_mp': {'token': 'YOUR TOKEN', 'port': '8088'}, 'gmail': {'subject_keyword': ['bot', '@bot'], 'host_email': 'xxxx@gmail.com', 'host_password': 'GMAIL ACCESS KEY'}, 'telegram': {'bot_token': 'xx:xx'}, 'slack': {'slack_bot_token': 'xoxb-xxxx', 'slack_app_token': 'xapp-xxxx'}, 'http': {'http_auth_secret_key': '6d25a684-9558-11e9-aa94-efccd7a0659b', 'http_auth_password': '6.67428e-11', 'port': '80'}}}

Please scan the QR code to log in.
Please press confirm on your phone.
Loading the contact, this may take a little while.
Login successfully as 饭团
Start auto replying.
[ERROR][2023-03-20 15:30:04][wechat_channel.py:140] - 'type' object is not subscriptable
Traceback (most recent call last):
  File "/root/bot-on-anything/channel/wechat/wechat_channel.py", line 136, in _do_send
    reply_text = super().build_reply_content(query, context)
  File "/root/bot-on-anything/channel/channel.py", line 31, in build_reply_content
    return Bridge().fetch_reply_content(query, context)
  File "/root/bot-on-anything/bridge/bridge.py", line 9, in fetch_reply_content
    return model_factory.create_bot(config.conf().get("model").get("type")).reply(query, context)
  File "/root/bot-on-anything/model/model_factory.py", line 29, in create_bot
    from model.bing.new_bing_model import BingModel
  File "/root/bot-on-anything/model/bing/new_bing_model.py", line 13, in <module>
    class BingModel(Model):
  File "/root/bot-on-anything/model/bing/new_bing_model.py", line 24, in BingModel
    def reply(self, query: str, context=None) -> tuple[str, dict]:
TypeError: 'type' object is not subscriptable
[ERROR][2023-03-20 15:39:33][log.py:45] - App startup failed!
[ERROR][2023-03-20 15:39:33][log.py:50] - Expecting property name enclosed in double quotes: line 32 column 3 (char 897)
Traceback (most recent call last):
  File "app.py", line 10, in <module>
    config.load_config()
  File "/root/bot-on-anything/config.py", line 17, in load_config
    config = json.loads(config_str)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 32 column 3 (char 897)

载入环节
{'model': {'type': 'bing', 'openai': {'api_key': 'YOUR API KEY', 'model': 'gpt-3.5-turbo', 'proxy': '', 'conversation_max_tokens': 1000, 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, 'baidu': {'acs_token': 'YOUR ACS TOKEN', 'cookie': 'YOUR COOKIE'}, 'bing': {'cookies': [{'domain': '.bing.com', 'expirationDate': 1680531349.764501, 'hostOnly': False, 'httpOnly': False, 'name': '_U', 'path': '/', 'sameSite': 'no_restriction', 'secure': True, 'session': False, 'storeId': None, 'value': '1Tsm********OmZg'}]}}, 'channel': {'type': 'wechat', 'single_chat_prefix': ['Bing', '@Bing'], 'single_chat_reply_prefix': '[Bing] ', 'group_chat_prefix': ['@Bing'], 'group_name_white_list': ['ChatGPT测试群'], 'image_create_prefix': ['画', '看', '找一张'], 'terminal': {}, 'wechat': {}, 'wechat_mp': {'token': 'YOUR TOKEN', 'port': '8088'}, 'gmail': {'subject_keyword': ['bot', '@bot'], 'host_email': 'xxxx@gmail.com', 'host_password': 'GMAIL ACCESS KEY'}, 'telegram': {'bot_token': 'xx:xx'}, 'slack': {'slack_bot_token': 'xoxb-xxxx', 'slack_app_token': 'xapp-xxxx'}, 'http': {'http_auth_secret_key': '6d25a684-9558-11e9-aa94-efccd7a0659b', 'http_auth_password': '6.67428e-11', 'port': '80'}}}
[INFO][2023-03-20 15:46:25][log.py:34] - [INIT] Start up: bing on wechat
█
Start auto replying.
百度云接口配置不存在
{'model': {'type': 'bing', 'openai': {'api_key': 'YOUR API KEY', 'model': 'gpt-3.5-turbo', 'proxy': '', 'conversation_max_tokens': 1000, 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, 'baidu': {'acs_token': 'YOUR ACS TOKEN', 'cookie': 'YOUR COOKIE'}, 'bing': {'cookies': [{'domain': '.bing.com', 'expirationDate': 1680531349.764501, 'hostOnly': False, 'httpOnly': False, 'name': '_U', 'path': '/', 'sameSite': 'no_restriction', 'secure': True, 'session': False, 'storeId': None, 'value': '1Tsm********OmZg'}]}}, 'channel': {'type': 'wechat', 'single_chat_prefix': ['Bing', '@Bing'], 'single_chat_reply_prefix': '[Bing] ', 'group_chat_prefix': ['@Bing'], 'group_name_white_list': ['ChatGPT测试群'], 'image_create_prefix': ['画', '看', '找一张'], 'terminal': {}, 'wechat': {}, 'wechat_mp': {'token': 'YOUR TOKEN', 'port': '8088'}, 'gmail': {'subject_keyword': ['bot', '@bot'], 'host_email': 'xxxx@gmail.com', 'host_password': 'GMAIL ACCESS KEY'}, 'telegram': {'bot_token': 'xx:xx'}, 'slack': {'slack_bot_token': 'xoxb-xxxx', 'slack_app_token': 'xapp-xxxx'}, 'http': {'http_auth_secret_key': '6d25a684-9558-11e9-aa94-efccd7a0659b', 'http_auth_password': '6.67428e-11', 'port': '80'}}}
[ERROR][2023-03-20 15:47:11][wechat_channel.py:140] - 'type' object is not subscriptable
Traceback (most recent call last):
  File "/root/bot-on-anything/channel/wechat/wechat_channel.py", line 136, in _do_send
    reply_text = super().build_reply_content(query, context)
  File "/root/bot-on-anything/channel/channel.py", line 31, in build_reply_content
    return Bridge().fetch_reply_content(query, context)
  File "/root/bot-on-anything/bridge/bridge.py", line 9, in fetch_reply_content
    return model_factory.create_bot(config.conf().get("model").get("type")).reply(query, context)
  File "/root/bot-on-anything/model/model_factory.py", line 29, in create_bot
    from model.bing.new_bing_model import BingModel
  File "/root/bot-on-anything/model/bing/new_bing_model.py", line 13, in <module>
    class BingModel(Model):
  File "/root/bot-on-anything/model/bing/new_bing_model.py", line 24, in BingModel
    def reply(self, query: str, context=None) -> tuple[str, dict]:
TypeError: 'type' object is not subscriptable

载入环节
{'model': {'type': 'bing', 'openai': {'api_key': 'YOUR API KEY', 'model': 'gpt-3.5-turbo', 'proxy': '', 'conversation_max_tokens': 1000, 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, 'baidu': {'acs_token': 'YOUR ACS TOKEN', 'cookie': 'YOUR COOKIE'}, 'bing': {'cookies': [{'domain': '.bing.com', 'expirationDate': 1680531349.764501, 'hostOnly': False, 'httpOnly': False, 'name': '_U', 'path': '/', 'sameSite': 'no_restriction', 'secure': True, 'session': False, 'storeId': None, 'value': '1Tsm********OmZg'}]}}, 'channel': {'type': 'wechat', 'single_chat_prefix': ['Bing', '@Bing'], 'single_chat_reply_prefix': '[Bing] ', 'group_chat_prefix': ['@Bing'], 'group_name_white_list': ['ChatGPT测试群'], 'image_create_prefix': ['画', '看', '找一张'], 'terminal': {}, 'wechat': {}, 'wechat_mp': {'token': 'YOUR TOKEN', 'port': '8088'}, 'gmail': {'subject_keyword': ['bot', '@bot'], 'host_email': 'xxxx@gmail.com', 'host_password': 'GMAIL ACCESS KEY'}, 'telegram': {'bot_token': 'xx:xx'}, 'slack': {'slack_bot_token': 'xoxb-xxxx', 'slack_app_token': 'xapp-xxxx'}, 'http': {'http_auth_secret_key': '6d25a684-9558-11e9-aa94-efccd7a0659b', 'http_auth_password': '6.67428e-11', 'port': '80'}}}
[INFO][2023-03-20 16:01:11][log.py:34] - [INIT] Start up: bing on wechat
█
Please press confirm on your phone.
百度云接口配置不存在
{'model': {'type': 'bing', 'openai': {'api_key': 'YOUR API KEY', 'model': 'gpt-3.5-turbo', 'proxy': '', 'conversation_max_tokens': 1000, 'character_desc': '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'}, 'baidu': {'acs_token': 'YOUR ACS TOKEN', 'cookie': 'YOUR COOKIE'}, 'bing': {'cookies': [{'domain': '.bing.com', 'expirationDate': 1680531349.764501, 'hostOnly': False, 'httpOnly': False, 'name': '_U', 'path': '/', 'sameSite': 'no_restriction', 'secure': True, 'session': False, 'storeId': None, 'value': '1Tsm********OmZg'}]}}, 'channel': {'type': 'wechat', 'single_chat_prefix': ['Bing', '@Bing'], 'single_chat_reply_prefix': '[Bing] ', 'group_chat_prefix': ['@Bing'], 'group_name_white_list': ['ChatGPT测试群'], 'image_create_prefix': ['画', '看', '找一张'], 'terminal': {}, 'wechat': {}, 'wechat_mp': {'token': 'YOUR TOKEN', 'port': '8088'}, 'gmail': {'subject_keyword': ['bot', '@bot'], 'host_email': 'xxxx@gmail.com', 'host_password': 'GMAIL ACCESS KEY'}, 'telegram': {'bot_token': 'xx:xx'}, 'slack': {'slack_bot_token': 'xoxb-xxxx', 'slack_app_token': 'xapp-xxxx'}, 'http': {'http_auth_secret_key': '6d25a684-9558-11e9-aa94-efccd7a0659b', 'http_auth_password': '6.67428e-11', 'port': '80'}}}
[ERROR][2023-03-20 16:01:27][log.py:45] - App startup failed!
[ERROR][2023-03-20 16:01:27][log.py:50] - list index out of range
Traceback (most recent call last):
  File "app.py", line 21, in <module>
    channel.startup()
  File "/root/bot-on-anything/channel/wechat/wechat_channel.py", line 43, in startup
    itchat.auto_login(enableCmdQR=2, hotReload=True)
  File "/usr/local/lib/python3.8/dist-packages/itchat/components/register.py", line 31, in auto_login
    self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback,
  File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 60, in login
    status = self.check_login()
  File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 151, in check_login
    if process_login_info(self, r.text):
  File "/usr/local/lib/python3.8/dist-packages/itchat/components/login.py", line 196, in process_login_info
    skey = re.findall('<skey>(.*?)</skey>', r.text, re.S)[0]
IndexError: list index out of range
RegimenArsenic commented 1 year ago

可能你python版本比较低,你把new_bing_model.py的24行的" -> tuple[str, dict]"删除掉,改成

    def reply(self, query: str, context=None):

试试看正不正常

Bin-fan commented 1 year ago

可能是因为root用户执行pip3 install EdgeGPT --upgrade会报错 改用非root用户设置成功