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

docker部署之后,对接微信glm-4模型出现报错,无论是用官方key还是中转都报错 #1856

Closed ins13014778 closed 1 month ago

ins13014778 commented 5 months ago

前置确认

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

操作系统类型?

Linux

运行的python版本是?

python 3.10

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

Latest Release

运行的channel类型是?

wx(个人微信, itchat)

复现步骤 🕹

[ERROR] 请再问我一次 [ERROR] 我现在有点累了,等会再来吧

问题描述 😯

No response

终端日志 📒

chatgpt-on-wechat  | Please press confirm on your phone.
chatgpt-on-wechat  | Loading the contact, this may take a little while.
chatgpt-on-wechat  | [INFO][2024-03-27 19:20:31][wechat_channel.py:131] - Wechat login success, user_id: @357eda951ce1a75f55092eb046a108b925106cdbfd96cc215f50329b02496fd9, nickname: ChatGPT
chatgpt-on-wechat  | Start auto replying.
chatgpt-on-wechat  | [INFO][2024-03-27 19:20:46][bridge.py:54] - create bot chatGPT for chat
chatgpt-on-wechat  | [INFO][2024-03-27 19:20:46][chat_gpt_bot.py:49] - [CHATGPT] query=请你随机使用一种风格介绍你自己,并告诉用户输入#help可以查看帮助信息。
chatgpt-on-wechat  | [WARNING][2024-03-27 19:20:49][chat_gpt_session.py:85] - num_tokens_from_messages() is not implemented for model GLM-4. Returning num tokens assuming gpt-3.5-turbo.
chatgpt-on-wechat  | [INFO][2024-03-27 19:20:50][chat_channel.py:117] - [WX]receive group at
chatgpt-on-wechat  | [INFO][2024-03-27 19:20:50][chat_gpt_bot.py:49] - [CHATGPT] query=ChatGPT 你好
chatgpt-on-wechat  | [WARNING][2024-03-27 19:20:50][chat_gpt_session.py:85] - num_tokens_from_messages() is not implemented for model GLM-4. Returning num tokens assuming gpt-3.5-turbo.
chatgpt-on-wechat  | [WARNING][2024-03-27 19:20:51][chat_gpt_bot.py:145] - [CHATGPT] Bad Gateway: Invalid response object from API: '{"code":500,"statusText":"","message":"messages[0]:content和tool_calls 字段不能同时为空 (request id: 2024032803205153046158283084664)","data":null}' (HTTP response code was 500)
chatgpt-on-wechat  | [WARNING][2024-03-27 19:20:52][chat_gpt_bot.py:145] - [CHATGPT] Bad Gateway: Invalid response object from API: '{"code":500,"statusText":"","message":"messages[0]:content和tool_calls 字段不能同时为空 (request id: 202403280320527069257375266367)","data":null}' (HTTP response code was 500)
chatgpt-on-wechat  | [WARNING][2024-03-27 19:21:01][chat_gpt_bot.py:160] - [CHATGPT] 第1次重试
chatgpt-on-wechat  | [WARNING][2024-03-27 19:21:02][chat_gpt_bot.py:160] - [CHATGPT] 第1次重试
chatgpt-on-wechat  | [WARNING][2024-03-27 19:21:03][chat_gpt_bot.py:145] - [CHATGPT] Bad Gateway: Invalid response object from API: '{"code":500,"statusText":"","message":"messages[0]:content和tool_calls 字段不能同时为空 (request id: 202403280321032556308178222247)","data":null}' (HTTP response code was 500)
chatgpt-on-wechat  | [WARNING][2024-03-27 19:21:03][chat_gpt_bot.py:145] - [CHATGPT] Bad Gateway: Invalid response object from API: '{"code":500,"statusText":"","message":"messages[0]:content和tool_calls 字段不能同时为空 (request id: 2024032803210344732099979550294)","data":null}' (HTTP response code was 500)
chatgpt-on-wechat  | [WARNING][2024-03-27 19:21:13][chat_gpt_bot.py:160] - [CHATGPT] 第2次重试
chatgpt-on-wechat  | [WARNING][2024-03-27 19:21:13][chat_gpt_bot.py:160] - [CHATGPT] 第2次重试
chatgpt-on-wechat  | [WARNING][2024-03-27 19:21:14][chat_gpt_bot.py:145] - [CHATGPT] Bad Gateway: Invalid response object from API: '{"code":500,"statusText":"","message":"messages[0]:content和tool_calls 字段不能同时为空 (request id: 2024032803211419849333844912756)","data":null}' (HTTP response code was 500)           给我个合理解决办法
sailliu commented 5 months ago

从你的日志来看你还是用的是openAI的模型,glm-4是智普的模型,大概率是你的config.json配置有误

ins13014778 commented 5 months ago

GLM-4 日志[INFO][2024-03-28 21:23:00][chat_gpt_bot.py:49] - [CHATGPT] query=你好 [WARNING][2024-03-28 21:23:00][chat_gpt_session.py:85] - num_tokens_from_messages() is not implemented for model GLM-4. Returning num tokens assuming gpt-3.5-turbo. [ERROR][2024-03-28 21:23:00][chat_gpt_bot.py:155] - [CHATGPT] Exception: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details. Traceback (most recent call last): File "/root/chatgpt-on-wechat/bot/chatgpt/chat_gpt_bot.py", line 123, in reply_text response = openai.ChatCompletion.create(api_key=api_key, messages=session.messages, *args) File "/usr/local/python3/lib/python3.8/site-packages/openai/api_resources/chat_completion.py", line 25, in create return super().create(args, **kwargs) File "/usr/local/python3/lib/python3.8/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 149, in create ) = cls.__prepare_create_request( File "/usr/local/python3/lib/python3.8/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 106, in prepare_create_request requestor = api_requestor.APIRequestor( File "/usr/local/python3/lib/python3.8/site-packages/openai/api_requestor.py", line 138, in init__ self.api_key = key or util.default_api_key() File "/usr/local/python3/lib/python3.8/site-packages/openai/util.py", line 186, in default_api_key raise openai.error.AuthenticationError( openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = ', or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = '. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details. [INFO][2024-03-28 21:23:01][wechat_channel.py:217] - [WX] sendMsg=Reply(type=ERROR, content=[ERROR] 我现在有点累了,等会再来吧), receiver=@2429f13a3cc362616bf0c36c4d167a85086f1e8b32ed175a70178a5520fcb1c0 配置 { "model": "GLM-4", "single_chat_prefix": [""], "expires_in_seconds": 3600, "group_chat_prefix": ["@Ai"], "group_chat_reply_prefix": "Ai", "group_chat_reply_suffix": "", "group_name_white_list": ["河南艺术职业学院群", "ChatGPT测试群2"], "group_welcome_msg": "", "conversation_max_tokens": 4000, "zhipu_ai_api_key": "fastgpt-mE8GutOrDmkYNFhGgnV9Y70afAYvaXA3ogpm6OlL19XMOtiD8R6xnBH0", "zhipu_ai_api_base": "https://77.100661.xyz/api/v1" }

kingdocker commented 4 months ago

chatgpt-on-wechat | [INFO][2024-03-27 19:20:46][bridge.py:54] - create bot chatGPT for chat chatgpt-on-wechat | [INFO][2024-03-27 19:20:46][chat_gpt_bot.py:49]

这看上去还是ChatGPT。