GitHub •
✍️ code for fun!
Strive to improve my coding level on the way of learning in the future.
just for fun
💪 正在学习:
🧠 计划学习:
🧰 常用的工具:
使用vercel的functions,将ai功能加入微信公众号
Home Page: https://aiwechat-vercel.vercel.app
License: MIT License
GitHub •
✍️ code for fun!
Strive to improve my coding level on the way of learning in the future.
just for fun
💪 正在学习:
🧠 计划学习:
🧰 常用的工具:
象油管上那些教学视频,一步一步跟着操作,谢谢
不懂的人关注,也没必要看这个
首先感谢大佬的项目,我在搭建过程中遇到了如下的问题:
很多与openai接口对齐的代理服务在调用时会返回'error, status code: 403, message: invalid character '<' looking for beginning of value'
比如go-proxy-bing以及uu.ci等代理服务都有同样问题,并且接口地址均加上了'/v1',但该问题仍然存在。同样的接口在nextchat中配置均能正常回复,请问这个如何解决呢?
个人订阅号如果被别人关注,也会有被滥用的可能。能不能增加一个功能/addme
,用户输入对接暗号,成为被认证的用户,这样跟订阅号对话才能唤醒AI,否则统一回复一句“功能还在开发中。”
这个对接暗号也是在变量中配置,类似 password = "天王盖地虎",用户输入 /addme 天王盖地虎
,就握手成功。
作为一个特定 gpts 使用,另外增加一个参数,不允许 /help 等命令模式。只在环境变量中设置。
chatgpt能不能支持多模型,比如同时支持gpt-4-turbo,gpt-3.5-turbo,gpt-3.5-turbo-0125这些型号
api/wx的log显示,在微信设置好token并保存后:time="2024-03-18T06:57:32Z" level=debug msg="response msg ="
再有其他请求,就显示EOF。
/api/chat?msg= 请求能返回正常内容。
error, status code: 403, message: invalid character '<' looking for beginning of value
请求后返回,请问是什么原因
需不需要加屏蔽词之类的?
增加公众号原有的功能:自定义关键词自动回复,特别需要这个功能
大佬的项目很好,但是对于我这个小白来说复刻还是遇到了一些问题,我按照自己的实现步骤调整了一下教程。
GPT_TOKEN
: 你的gpt token
GPT_URL
: (选填)默认https://api.openai.com/v1
gptModel
: (选填)默认gpt-3.5-turbo
WX_TOKEN
:必须为英文或数字,长度为3-32字符,一会儿配置微信公众号开发平台设置的token
botType
: gpt (机器人类型)
设置里添加自定义域名,然后去cloudflare DNS里添加一条 cname
解析到cname-china.vercel-dns.com
重新部署项目deployments
- Redeploy
,等待过程中去配置公众号
微信公众平台后台管理页面上找到设置与开发
-基本配置
-服务器配置
服务器配置 - 修改配置:
https://你的域名/api/wx
WX_TOKEN
如果提交 出现 “系统发生错误,请稍后重试”,请在浏览器通过
你的域名/api/check
检测项目是否部署成功,微信报错是因为访问URL返回有错,你可以尝试检查配置后重新部署
现在有gemini-1.5-pro-latest模型可以使用,但是不知道key填什么。麻烦大佬支持下自定义Gemini model
微信似乎对订阅号加了什么限制
Build Failed
The following Serverless Functions contain an invalid "runtime": - api/chat (provided.al2) - api/check (provided.al2) - api/index (provided.al2) - api/wx (provided.al2) - api/wx_menu (provided.al2)
rt
订阅号的限制,无法回复太长的内容…
因为我之前玩过cow项目,就有提示订阅号的缺点就是无法回复过长的内容。
大佬你这个我部署好后也试了,让gpt讲故事因为太长的确没有回复,其他简短的回答都正常。
如题,我看了我反代chatgpt的日志是有生成回答的,但是不知道是否由于回答内容太多/符号太多比如**?导致微信公众号无法发送?
日志如下:
backend-to-api-other_1 | 2024-03-04 06:15:09,893 [INFO] - 完整消息: 成为一个好人是一个长期的过程,需要不断地努力和自我提升。以下是一些成为好人的建议:
backend-to-api-other_1 |
backend-to-api-other_1 | 1. 善待他人:尊重他人、理解他们的感受、给予他们关怀和支持。尽量避免伤害他人的行为,而是选择去帮助和鼓励他们。
backend-to-api-other_1 |
backend-to-api-other_1 | 2. 诚实正直:诚实是一个好人的基本品质。坦诚地与他人交往,不说谎、不欺骗。保持诚实和透明可以赢得他人的信任和尊重。
backend-to-api-other_1 |
backend-to-api-other_1 | 3. 善良慷慨:善良和慷慨是成为一个好人的重要特征。愿意帮助他人、分享自己的资源和时间,对需要帮助的人伸出援手。
backend-to-api-other_1 |
backend-to-api-other_1 | 4. 尊重差异:尊重他人的不同观点、信仰、文化和生活方式。学会包容和接纳不同的人群,避免歧视和偏见。
backend-to-api-other_1 |
backend-to-api-other_1 | 5. 自我反省:不断审视自己的行为和态度,认识到自己的不足之处并努力改进。接受他人的批评和建议,用心成长。
backend-to-api-other_1 |
backend-to-api-other_1 | 6. 宽容谅解:学会宽容和谅解他人的过错和失误。不要轻易怀恨在心,而是选择原谅和释放内心的怨恨。
backend-to-api-other_1 |
backend-to-api-other_1 | 7. 尊重环境:爱护环境,保护自然资源,减少对地球的负面影响。积极参与环保活动,为创建一个更美好的地球贡献自己的力量。
backend-to-api-other_1 |
backend-to-api-other_1 | 8. 关注社会:关心社会公益事业,为社会贡献力量。可以通过志愿活动、捐款等方式帮助那些需要帮助的人群。
backend-to-api-other_1 |
backend-to-api-other_1 | 9. 保持谦逊:谦逊是成为一个好人的重要品质。不自负、不自大,而是保持谦虚和谦恭的态度与他人相处。
backend-to-api-other_1 |
backend-to-api-other_1 | 10. 积极学习:不断学习和成长,提升自己的知识和技能。通过不断学习,可以更好地理解世界、认识自己,从而成为一个更好的人。
backend-to-api-other_1 |
backend-to-api-other_1 | 成为一个好人是一个渐进的过程,需要不断地付出努力和坚持。重要的是,要真诚地对待他人,用心去关爱和帮助他人,以积极的态度去影响和改变周围的世界。
backend-to-api-other_1 | 2024-03-04 06:15:09,894 [INFO] - 接受到停止信号,停止数据处理线程-外层
backend-to-api-other_1 | 192.168.32.1 - - [04/Mar/2024:06:15:10 +0000] "POST /v1/chat/completions HTTP/1.1" 200 4158 "-" "Go-http-client/1.1"
如题,不用管理路由转发之类的什么的吗?在vercel上部署go项目好像没那么方便
那个模型没配置就彻底没法用了。这个如何再切换回GPT呢
panic: runtime error: index out of range [0] with length 0
goroutine 13 [running]:
github.com/pwh-pwh/aiwechat-vercel/chat.(*SimpleGptChat).chat(0xc000152c40, {0xc00013c2c0, 0x1c}, {0xc0001394f0, 0x9})
/vercel/path0/chat/gpt.go:61 +0x6ae
github.com/pwh-pwh/aiwechat-vercel/chat.WithTimeChat.func1()
/vercel/path0/chat/chat.go:177 +0x34
created by github.com/pwh-pwh/aiwechat-vercel/chat.WithTimeChat in goroutine 1
/vercel/path0/chat/chat.go:176 +0x271
Error: Runtime exited with error: exit status 2
你好,我这个是个人订阅号,我搭建好之后。
使用https://域名/api/chat?msg=hi 是有信息输出的:
你好!有什么我可以帮您的吗?
使用/api/check 信息如下:
echo: true
gpt: true
spark: true
qwen: false
gemini: true
DEFAULT BOT: spark
但是在公众号发消息,却无响应,请问是什么情况啊
大佬求助,我部署完了后,用你的域名/api/chat?msg=你的问题是可以正常返回答复
但是公众号问问题就跟复读机一样只会回复我问的问题
vercel上对应的日志显示,最后两个问题其实请求发出甚至得到响应了,但是处理消息的时候出了问题:
点开日志详情:
对应维生素提问得到的响应内容:
xt":[{"content":"维生","role":"assistant","index":0}]}}}
0
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":1,"text":[{"content":"素是一类","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":2,"text":[{"content":"有机化合物,","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":3,"text":[{"content":"它们在人体中","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":4,"text":[{"content":"发挥着重要的生理功能","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":5,"text":[{"content":"。","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":6,"text":[{"content":"根据其化学性质和功能,维生素可以分为以下几类:\n\n1.","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":7,"text":[{"content":" 水溶性维生素:包括维生素B族(如维生素B1、B2、B3、B5、B6、B7、B9、B12)和维生素C。","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":8,"text":[{"content":"这些维生素在水中溶解,不容易在体内积累,多余的部分会通过尿液排出体外。\n\n","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":9,"text":[{"content":"2. 脂溶性维生素:包括维生素A、D、E和K。","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":10,"text":[{"content":"这些维生素在脂肪中溶解,可以在体内储存,过量摄入可能会导致中毒。\n\n","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":11,"text":[{"content":"需要注意的是,虽然维生素对人体健康至关重要,但并不意味着摄入越多越好。","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":1},"payload":{"choices":{"status":1,"seq":12,"text":[{"content":"过量摄入某些维生素可能会对身体造成负面影响。","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bba18@dx18e2dba29b89a4b550","status":2},"payload":{"choices":{"status":2,"seq":13,"text":[{"content":"因此,建议在日常饮食中均衡摄入各类营养素,如果有需要,可以咨询医生或营养师的建议。","role":"assistant","index":0}]},"usage":{"text":{"question_tokens":3,"prompt_tokens":11,"completion_tokens":176,"total_tokens":187}}}}
2
收到最终结果
total_tokens: 187
time="2024-03-11T13:36:03Z" level=debug msg="request msg =<xml><ToUserName><![CDATA[gh_006fd739c19c]]></ToUserName>\n<FromUserName><![CDATA[oMQaQ6VItcMHQsokVWgQY2WxCdYc]]></FromUserName>\n<CreateTime>1710164151</CreateTime>\n<MsgType><![CDATA[text]]></MsgType>\n<Content><![CDATA[维生素有多少种]]></Content>\n<MsgId>24483666501140544</MsgId>\n</xml>"
time="2024-03-11T13:36:03Z" level=debug msg="response msg =&{CommonToken:{XMLName:{Space: Local:} ToUserName:oMQaQ6VItcMHQsokVWgQY2WxCdYc FromUserName:gh_006fd739c19c CreateTime:1710164163 MsgType:text} Content:}"
对应“长河落日圆”提问的响应:
{"header":{"code":0,"message":"Success","sid":"cht000bbe50@dx18e2dbbd4ceb8f2550","status":0},"payload":{"choices":{"status":0,"seq":0,"text":[{"content":"“","role":"assistant","index":0}]}}}
0
{"header":{"code":0,"message":"Success","sid":"cht000bbe50@dx18e2dbbd4ceb8f2550","status":1},"payload":{"choices":{"status":1,"seq":1,"text":[{"content":"长河","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bbe50@dx18e2dbbd4ceb8f2550","status":1},"payload":{"choices":{"status":1,"seq":2,"text":[{"content":"落日圆","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bbe50@dx18e2dbbd4ceb8f2550","status":1},"payload":{"choices":{"status":1,"seq":3,"text":[{"content":"”这句诗出自","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bbe50@dx18e2dbbd4ceb8f2550","status":1},"payload":{"choices":{"status":1,"seq":4,"text":[{"content":"**唐代王维的","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bbe50@dx18e2dbbd4ceb8f2550","status":1},"payload":{"choices":{"status":1,"seq":5,"text":[{"content":"《使至塞上》","role":"assistant","index":0}]}}}
1
{"header":{"code":0,"message":"Success","sid":"cht000bbe50@dx18e2dbbd4ceb8f2550","status":1},"payload":{"choices":{"status":1,"seq":6,"text":[{"content":"**。\n","role":"assistant","index":0}]}}}
1
是不是因为内容太长被截断,导致无法正确解析?
语音这个该怎么弄呢?
语音发出去,是存在哪的呢?
比如要求AI返回的内容小于500字。然后程序上对500字以上的截断。现在直接不返回,体验上会差点
支持fastgpt吗
目前发送图片是图床功能,但现在gpt-4-turbo和gemini都支持图片输入,所以我觉得可以将发送图片后的默认动作改为对话,更直观。需图床相对用的少一点
作者大大,后期会考虑添加验证模块吗?
比如:访问密码啥的
比如:作为AI助手,你需要遵守以下规范:不发布任何违法违规内容,保持友好对话;明确告知用户身份,仅回复用户提出的问题;有针对性地为用户服务,避免主动发布内容;提醒用户审慎使用内容,避免法律风险。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.