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
29.49k stars 7.8k forks source link

使用自定义api_base后报错[chat_gpt_bot.py:155] - [CHATGPT] Exception: 'usage' #1953

Closed troublemakerMibu closed 3 months ago

troublemakerMibu commented 3 months ago

前置确认

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

操作系统类型?

Docker

运行的python版本是?

other

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

Latest Release

运行的channel类型是?

other

复现步骤 🕹

我使用了自定义的api接口,来自于项目https://github.com/missuo/FreeDuckDuckGo/tree/main,经过测试使用curl的方式可以获得正常的回复。 我使用的是钉钉进行连接,正确配置了相关参数之后可以正常在单聊和群聊中@bot。 但是在和机器人发信息的时候,机器人一直回复:[ERROR]我现在有点累了,等会再来吧 image

我查看服务器日志时显示: image

问题描述 😯

我的docker-compose.yml配置: version: '2.0' services: chatgpt-on-wechat: image: zhayujie/chatgpt-on-wechat container_name: chatgpt-on-wechat security_opt:

终端日志 📒

chatgpt-tool-hub version: 0.5.0 [INFO][2024-05-09 12:28:04][plugin_manager.py:41] - Plugin tool_v0.5 registered, path=./plugins/tool [INFO][2024-05-09 12:28:04][plugin_manager.py:41] - Plugin Banwords_v1.0 registered, path=./plugins/banwords [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin GODCMD not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin KEYWORD not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin BANWORDS not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin LINKAI not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin TOOL not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin ROLE not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin DUNGEON not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin BDUNIT not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin HELLO not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][plugin_manager.py:123] - Plugin FINISH not found in pconfig, adding to pconfig... [INFO][2024-05-09 12:28:04][godcmd.py:194] - [Godcmd] 因未设置口令,本次的临时口令为8579。 [INFO][2024-05-09 12:28:04][godcmd.py:210] - [Godcmd] inited [INFO][2024-05-09 12:28:04][keyword.py:40] - [keyword] {} [INFO][2024-05-09 12:28:04][keyword.py:42] - [keyword] inited. [WARNING][2024-05-09 12:28:04][banwords.py:54] - [Banwords] init failed, ignore or see https://github.com/zhayujie/chatgpt-on-wechat/tree/master/plugins/banwords . [WARNING][2024-05-09 12:28:04][plugin_manager.py:150] - Failed to init BANWORDS, diabled. [Errno 2] No such file or directory: '/app/plugins/banwords/banwords.txt' [INFO][2024-05-09 12:28:04][linkai.py:34] - [LinkAI] inited, config={'group_app_map': {'测试群名1': 'default', '测试群名2': 'Kv2fXJcH'}, 'midjourney': {'enabled': False, 'auto_translate': True, 'img_proxy': True, 'max_tasks': 3, 'max_tasks_per_user': 1, 'use_image_create_prefix': True}, 'summary': {'enabled': False, 'group_enabled': True, 'max_file_size': 5000, 'type': ['FILE', 'SHARING']}} [INFO][2024-05-09 12:28:05][tool.py:28] - [tool] inited [INFO][2024-05-09 12:28:05][role.py:69] - [Role] inited [INFO][2024-05-09 12:28:05][dungeon.py:56] - [Dungeon] inited [WARNING][2024-05-09 12:28:05][bdunit.py:42] - [BDunit] init failed, ignore [WARNING][2024-05-09 12:28:05][plugin_manager.py:150] - Failed to init BDUNIT, diabled. config.json not found [INFO][2024-05-09 12:28:05][hello.py:38] - [Hello] inited [INFO][2024-05-09 12:28:05][finish.py:23] - [Finish] inited 2024-05-09 12:28:05,854 dingtalk_stream.client INFO open connection, url=https://api.dingtalk.com/v1.0/gateway/connections/open [stream.py:131] 2024-05-09 12:28:06,090 dingtalk_stream.client INFO endpoint is {'endpoint': 'wss://wss-open-connection.dingtalk.com:443/connect', 'ticket': '9640d9b4-0dff-11ef-b568-d230038a41ab'} [stream.py:72] [INFO][2024-05-09 12:28:31][bridge.py:59] - create bot chatGPT for chat [INFO][2024-05-09 12:28:31][chat_gpt_bot.py:49] - [CHATGPT] query=@bot 你好 [ERROR][2024-05-09 12:28:37][chat_gpt_bot.py:155] - [CHATGPT] Exception: 'usage' Traceback (most recent call last): File "/app/bot/chatgpt/chat_gpt_bot.py", line 127, in reply_text "total_tokens": response["usage"]["total_tokens"], KeyError: 'usage'

chenbe1990 commented 3 months ago

应该是返回结果的格式和chatgpt的返回格式不一样导致response["usage"]["total_tokens"]这个值获取不了

xjd077 commented 3 months ago

解决了吗?我也遇到了这个问题

6vision commented 3 months ago

三方api返回不是标准的openai格式

wobure123 commented 3 months ago

不修复一下呀,没拿到usage给个默认值呗