Giter Site home page Giter Site logo

aiwechat-vercel's Introduction

GitHub •  访客统计

👨‍💻 I Want To Say 🙋‍♂️

✍️  code for fun!

  Strive to improve my coding level on the way of learning in the future.

  just for fun

💪 正在学习:

   Go Java Kotlin TypeScript

🧠 计划学习:

   Flutter Nodejs Docker Shell Script

🧰 常用的工具:

   Windows Linux Ios Android Google Chrome Edge Visual Studio Code Git GitHub

html5 ios VSCode python javascript vue github node

🚀 Actions 🚀

Anurag's GitHub stats Top Langs




aiwechat-vercel's People

Contributors

david-dong828 avatar lin-z-z avatar myimilo avatar neoshui avatar pwh-pwh avatar qabot-zh avatar tsfans avatar wsqstar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aiwechat-vercel's Issues

ChatGpt代理API支持问题

首先感谢大佬的项目,我在搭建过程中遇到了如下的问题:

很多与openai接口对齐的代理服务在调用时会返回'error, status code: 403, message: invalid character '<' looking for beginning of value'

比如go-proxy-bing以及uu.ci等代理服务都有同样问题,并且接口地址均加上了'/v1',但该问题仍然存在。同样的接口在nextchat中配置均能正常回复,请问这个如何解决呢?

订阅号对话增加鉴定机制

个人订阅号如果被别人关注,也会有被滥用的可能。能不能增加一个功能/addme,用户输入对接暗号,成为被认证的用户,这样跟订阅号对话才能唤醒AI,否则统一回复一句“功能还在开发中。”
这个对接暗号也是在变量中配置,类似 password = "天王盖地虎",用户输入 /addme 天王盖地虎,就握手成功。

重复响应问题

查看 newapi 的记录能看到有时候会发起两次请求:

image

对应 vercel 的 log 也的确是包含了两条:

image

image

这是某种重试 bug 吗?

多模型是否支持?

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= 请求能返回正常内容。

优化了一下部署教程

大佬的项目很好,但是对于我这个小白来说复刻还是遇到了一些问题,我按照自己的实现步骤调整了一下教程。

前置准备

  1. 域名
  2. cloudflare解析
  3. GitHub账号
  4. Vercel
  5. 微信公众号(管理员)

步骤

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

  • 添加一个redis数据库:
    image|689x424

  • 重新部署项目deployments - Redeploy,等待过程中去配置公众号

  • 微信公众平台后台管理页面上找到设置与开发 -基本配置 -服务器配置

  • 服务器配置 - 修改配置:

    • 服务器地址url为https://你的域名/api/wx
    • 令牌(Token):之前设置的WX_TOKEN
    • 消息加解密密钥(EncodingAESKey):直接随机
    • 消息加解密:明文模式(后续添加支持加密)

如果提交 出现 “系统发生错误,请稍后重试”,请在浏览器通过你的域名/api/check检测项目是否部署成功,微信报错是因为访问URL返回有错,你可以尝试检查配置后重新部署

  • 提交成功后,记得启用:
    image|690x61
  • 关注公众号去试试吧

支持自定义 Gemini model

现在有gemini-1.5-pro-latest模型可以使用,但是不知道key填什么。麻烦大佬支持下自定义Gemini model

Build Failed 大佬指点下咋报错了

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)

部署成功后,针对简单的问题会直接回答,复杂问题没有回答。

如题,我看了我反代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"

增加自动回复功能

在订阅号使用的时候,有时的回答有延迟,在这个等待过程中不知道是否是正在思考还是服务器没响应。增加一个每次接收信息就先自动回复一句(可通过变量自定义内容),这样使用者就知道服务器还在工作。
image

panic: runtime error: index out of range [0] with length 0 大佬帮看看咋回事,谢谢

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=你的问题是可以正常返回答复

但是公众号问问题就跟复读机一样只会回复我问的问题

【BUG】询问复杂问题时报错504,上下文连贯性问题

如题

环境

Bot:gpt-4

问题描述

1.在我询问一个复杂问题时,会出现网关超时的问题。
54aa96217f40eeee8c0e429d578a7f7
2.上下文连贯性有些问题
image

优化建议

  • 等待请求响应时间,是否可以支持自定义?
  • 超出500个字符的回答,是否可以分多次回应,避免被微信吞掉。

通义千问响应有问题

一开始是有请求错误:
c931c7a0426236bd9850163395c1b77

后面则无响应:
160730e82f34aa06ab96e9d4ce5915a

vercel上对应的日志显示,最后两个问题其实请求发出甚至得到响应了,但是处理消息的时候出了问题:
image

点开日志详情:
对应维生素提问得到的响应内容:

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

是不是因为内容太长被截断,导致无法正确解析?

redis消息同步问题

如图,Question2被Q3覆盖,且 redis 记录中的Q2、Q3回答不同,看上去是Q2被覆盖前后请求了两次api

image

支持GPT或者Google的Vision

目前发送图片是图床功能,但现在gpt-4-turbo和gemini都支持图片输入,所以我觉得可以将发送图片后的默认动作改为对话,更直观。需图床相对用的少一点

祝您五一快乐!

作者大大,后期会考虑添加验证模块吗?

比如:访问密码啥的

作者您好!本项目支持自己添加预设吗?

比如:作为AI助手,你需要遵守以下规范:不发布任何违法违规内容,保持友好对话;明确告知用户身份,仅回复用户提出的问题;有针对性地为用户服务,避免主动发布内容;提醒用户审慎使用内容,避免法律风险。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.