zhayujie / chatgpt-on-wechat

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

通义千问有更简易的接入方式 #1836

Closed evachxji closed 6 months ago

evachxji commented 7 months ago

⚠️ 搜索是否存在类似issue

总结

通义千问快速接入文档:https://help.aliyun.com/zh/dashscope/developer-reference/quick-start 官方文档里只需填写API-KEY即可调用(就像chatGPT一样简单),为什么本系统需要5个参数呢:

"qwen_access_key_id": "",
"qwen_access_key_secret": "",
"qwen_agent_key": "",
"qwen_app_id": "",
"qwen_node_id": ""

另外我按着阿里云的文档鼓捣了一下午,这个填写的qwen_access_key_id、qwen_access_key_secret始终有问题,阿里云接口返回错误信息:

[INFO][2024-03-25 17:15:37][bridge.py:51] - create bot qwen for chat [ERROR][2024-03-25 17:15:38][chat_channel.py:303] - Worker return exception: create token error, code=Forbidden, message=User not authorized to operate on the specified resource. RequestId: C2BA9D6F-8EE8-54B6-87FE-08B86D561792 Traceback (most recent call last): File "C:\Users\juncheng.ye\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "D:\code\explore\chatgpt-on-wechat-4\channel\chat_channel.py", line 170, in _handle reply = self._generate_reply(context) File "D:\code\explore\chatgpt-on-wechat-4\channel\chat_channel.py", line 193, in _generate_reply reply = super().build_reply_content(context.content, context) File "D:\code\explore\chatgpt-on-wechat-4\channel\channel.py", line 38, in build_reply_content return Bridge().fetch_reply_content(query, context) File "D:\code\explore\chatgpt-on-wechat-4\bridge\bridge.py", line 66, in fetch_reply_content return self.get_bot("chat").reply(query, context) File "D:\code\explore\chatgpt-on-wechat-4\bridge\bridge.py", line 57, in get_bot self.bots[typename] = create_bot(self.btype[typename]) File "D:\code\explore\chatgpt-on-wechat-4\bot\bot_factory.py", line 49, in create_bot return AliQwenBot() File "D:\code\explore\chatgpt-on-wechat-4\bot\ali\ali_qwen_bot.py", line 24, in init self.api_key_expired_time = self.set_api_key() File "D:\code\explore\chatgpt-on-wechat-4\bot\ali\ali_qwen_bot.py", line 149, in set_api_key api_key, expired_time = self.api_key_client().create_token(agent_key=self.agent_key()) File "D:\code\explore\chatgpt-on-wechat\venv\lib\site-packages\broadscope_bailian\api\access_token_client.py", line 50, in create_token raise RuntimeError("create token error, code=%s, message=%s RequestId: %s" RuntimeError: create token error, code=Forbidden, message=User not authorized to operate on the specified resource. RequestId: C2BA9D6F-8EE8-54B6-87FE-08B86D561792

这是我按照教程配置的,已经添加了所有权限 image

同时我看到阿里官方的这段说明,是不是也表示 AccessKey、Access Secret Key 在新的对接文档里其实已经不需要了? https://help.aliyun.com/document_detail/2621347.html image

举例

No response

动机

现有教程无法对接通义千问,好像是阿里云那边的问题,新建的AccessKey即便授权了,也无法正常获取token

LaterZcl commented 7 months ago

确实如此,现在是通过APIKey,调用接口。需要等作者更新通义千问的接入方式

evachxji commented 7 months ago

附一个官方的升级说明,我在尝试自己改造相关代码,提交一个PR。(python新手,抛砖引玉下) https://help.aliyun.com/document_detail/2713164.html image