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.06k stars 7.47k forks source link

第三方接口无法使用claude3模型 #2063

Closed Zoumachuan closed 3 weeks ago

Zoumachuan commented 1 month ago

前置确认

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

操作系统类型?

Linux

运行的python版本是?

python 3.7

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

Latest Release

运行的channel类型是?

wx(个人微信, itchat)

复现步骤 🕹

修改config.json后正常启动chatgpt-on-wechat,此时可以运行正常的OpenAI家族模型。

问题描述 😯

已知该第三方站点有调用claude-3-opus-20240229模型的能力(已在其他app上验证使用过),以下为config.json的详细内容 { "channel_type": "wx", "model": "claude-3-opus-20240229", "open_ai_api_key": "sk-TL6****585C26a15", "open_ai_api_base": "https://api.*****.cn/v1", "claude_api_key": "", "text_to_image": "dall-e-3", "voice_to_text": "openai", "text_to_voice": "openai", "proxy": "", "hot_reload": true, "single_chat_prefix": [""], "single_chat_reply_prefix": "", "group_chat_prefix": ["@bot"], "group_name_white_list": ["ALL_GROUP"], 我试图通过以上方式调用claude3的模型,但无法正常回复,详情请见下方终端日志。

终端日志 📒

[INFO][2024-06-07 19:38:41][bridge.py:61] - create bot claudeAPI for chat
[INFO][2024-06-07 19:38:41][claude_api_bot.py:42] - [CLAUDE_API] query=在吗
[WARNING][2024-06-07 19:38:43][claude_api_bot.py:116] - [CLAUDE_API] Exception: Error code: 403 - {'error': {'type': 'forbidden', 'message': 'Request not allowed'}}
[INFO][2024-06-07 19:38:43][claude_api_bot.py:54] - {'completion_tokens': 0, 'content': '我现在有点累了,等会再来吧'}
[ERROR][2024-06-07 19:38:43][chat_channel.py:303] - Worker return exception: 'total_tokens'
Traceback (most recent call last):
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/root/chatgpt-on-wechat/channel/chat_channel.py", line 170, in _handle
    reply = self._generate_reply(context)
  File "/root/chatgpt-on-wechat/channel/chat_channel.py", line 193, in _generate_reply
    reply = super().build_reply_content(context.content, context)
  File "/root/chatgpt-on-wechat/channel/channel.py", line 38, in build_reply_content
    return Bridge().fetch_reply_content(query, context)
  File "/root/chatgpt-on-wechat/bridge/bridge.py", line 76, in fetch_reply_content
    return self.get_bot("chat").reply(query, context)
  File "/root/chatgpt-on-wechat/bot/claudeapi/claude_api_bot.py", line 56, in reply
    result["total_tokens"],
KeyError: 'total_tokens'
6vision commented 3 weeks ago

试一下这个pr