houko / wechatgpt Goto Github PK
View Code? Open in Web Editor NEWwechatgpt golang版 chatgpt机器人(可docker部署),目前支持wechat,telegram
License: MIT License
wechatgpt golang版 chatgpt机器人(可docker部署),目前支持wechat,telegram
License: MIT License
linux:Linux 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x72df83]
goroutine 24 [running]:
github.com/wechatgpt/wechatbot/handler/wechat.(*GroupMessageHandler).ReplyText(0xc0000517e0?, 0xc0000ec780)
/app/handler/wechat/wechat_handler.go:38 +0x123
github.com/wechatgpt/wechatbot/handler/wechat.(*GroupMessageHandler).handle(0x76dd80?, 0xc00006baa0?)
/app/handler/wechat/wechat_handler.go:22 +0x2a
github.com/wechatgpt/wechatbot/handler/wechat.Handler(0xc0000ec780?)
/app/handler/wechat/handler.go:27 +0x4e
github.com/eatmoreapple/openwechat.(*Bot).syncCheck(0xc0000f6000)
/go/pkg/mod/github.com/eatmoreapple/[email protected]/bot.go:288 +0x1d8
github.com/eatmoreapple/openwechat.(*Bot).WebInit.func1()
/go/pkg/mod/github.com/eatmoreapple/[email protected]/bot.go:240 +0x7d
sync.(*Once).doSlow(0x346f424151414449?, 0x424d4c47494d4f47?)
/usr/local/go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(0x364e56776b784c57?, 0x6249704354714152?)
/usr/local/go/src/sync/once.go:65 +0x1f
created by github.com/eatmoreapple/openwechat.(*Bot).WebInit
/go/pkg/mod/github.com/eatmoreapple/[email protected]/bot.go:235 +0x1cd
get this error,how to do?
2022/12/13 21:24:01 {"id":"cmpl-6MzYEguqQcKjUHk2zdUsmTK2SZv98","object":"text_completion","created":1670937838,"model":"text-davinci-003","choices":[{"text":"是:\n\n这取决于您的银行。一般来说,您的银行卡密码是您用来登录网上银行的密码,或者您在激活银行卡时设置的密码。如果您忘记了密码,可以联系您的银行客服进行重置。","index":0,"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":15,"completion_tokens":173,"total_tokens":188}}
2022/12/13 21:24:01 gpt response text: 是:
这取决于您的银行。一般来说,您的银行卡密码是您用来登录网上银行的密码,或者您在激活银行卡时设置的密码。如果您忘记了密码,可以联系您的银行客服进行重置。
2022/12/13 21:24:02 Ret(1204)
ERRO[0316] handle error: Ret(1204)
2022/12/14 19:30:39 扫码成功,请在手机上确认登录
time="2022-12-14T19:30:48Z" level=fatal msg="write token.json: bad file descriptor"
这是因为什么
您的功能请求是否与问题相关?请描述。
目前chatGPT服务器经常会有故障的情况,比如服务器过载,但是程序把出错消息给吃掉了,用户并不知道为什么失败了
描述您想要的解决方案
出错的信息也应该显示在聊天窗口中
如果能提供以上功能,我将非常感谢!
如题
重现
重现行为的步骤:
无
预期行为
发送消息,telegram bot 回复消息
截图
time="2023-02-15T12:04:32Z" level=warning msg="没有找到配置文件,尝试读取环境变量"
time="2023-02-15T12:04:34Z" level=info msg="Authorized on account: jack_automatic_bot"
time="2023-02-15T12:05:00Z" level=info msg="request openai json string : {\"model\":\"text-davinci-003\",\"prompt\":\"?\",\"max_tokens\":4000,\"temperature\":0.7,\"top_p\":1,\"frequency_penalty\":0,\"presence_penalty\":0}"
time="2023-02-15T12:05:02Z" level=info msg="Post \"https://api.openai.com/v1/completions\": EOF"
time="2023-02-15T12:05:12Z" level=info msg="request openai json string : {\"model\":\"text-davinci-003\",\"prompt\":\"你好?\",\"max_tokens\":4000,\"temperature\":0.7,\"top_p\":1,\"frequency_penalty\":0,\"presence_penalty\":0}"
time="2023-02-15T12:05:15Z" level=info msg="Post \"https://api.openai.com/v1/completions\": EOF"
PC (请填写以下信息):
附加上下文
在此处添加有关该问题的任何其他上下文。
重现
重现行为的步骤:
预期行为
对您预期发生的事情的清晰简洁的描述。
截图
![image](https://user-images.githubusercontent.com/58323216/218317088-969a8d6d-c9b9-419b-b142-31581e6daf23.jpe
突破网页版限制
顾名思义,PuppetPuppeteer 使用了 Puppeteer,这里使用了微信的网页版。但是我们知道,微信网页版已经被限制使用,当我们扫码登陆成功之后,会显示如下文案:
为了保障你的帐号安全,暂不支持使用网页版微信。你可以前往微信官网 https://weixin.qq.com/ 下载客户端登录。
目前,这个问题是通过开启 uos 协议登录来解决的,具体细节可以阅读 「免费 UOS 协议快速接入可视化配置面板」 这篇文档。具体到实现上, 通过 Puppeteer 拦截 /cgi-bin/mmwebwx-bin/webwxnewloginpage 请求,并在该请求的 Header 上添加 client-version 和 extspam 两个字段,具体源码如下所示:
const uosHeaders = {
'client-version' : UOS_PATCH_CLIENT_VERSION,
extspam : UOS_PATCH_EXTSPAM,
}
page.on('request', (req) => {
const url = new URL(req.url())
if (url.pathname === '/cgi-bin/mmwebwx-bin/webwxnewloginpage') {
const override = {
headers: {
...req.headers(),
...uosHeaders,
},
}
this.wrapAsync(req.continue(override))
}
})
这样,扫码登陆之后便可进入到聊天页面,突破了网页版的限制。使用下面的代码启动 Wechaty 机器人,可以看到效果:
const bot = WechatyBuilder.build({
name: 'wechat-bot',
puppetOptions: {
引自知乎
1.有时候提问,没有任何响应,去重启服务后,自动回复之前的所有问题。
2.api报错是否可以添加提示
加群微信群后 ,测试,单独触发 关键字才回复问题,无效,一直回复群里的问题。
麻烦小莫 抽空检查一下 代码 还是 配置哪个字段的修改 谢谢
您的功能请求是否与问题相关?请描述。
请求增加与slack对接,slack目前不需要fq,支持集成app
https://api.slack.com/apps
您的功能请求是否与问题相关?请描述。
目前的接口是官方提供的API接口,跟网页端同步的接口版本对比明显训练集跟回复效果对比较差。
描述您想要的解决方案
期望楼主对齐PyChatGPT项目,实现golang版本的网页访问转发。https://github.com/rawandahmad698/PyChatGPT。对golang跟python不够熟悉,要不我就提pr了。脑壳疼。。
描述您考虑过的备选方案
无
附加上下文
无
您的功能请求是否与问题相关?请描述。
无
描述您想要的解决方案
无
描述您考虑过的备选方案
无
附加上下文
得益于go的高效,可以在资源有限的设备上部署多个bot,且docker能够快速方便部署,希望添加对discord bot的支持
time="2022-12-16T22:21:06+08:00" level=info msg="{\n \"error\": {\n \"message\": \"This model's maximum context length is 4097 tokens, however you requested 4182 tokens (182 in your prompt; 4000 for the completion). Please reduce your prompt; or completion length.\",\n \"type\": \"invalid_request_error\",\n \"param\": null,\n \"code\": null\n }\n}\n"
经常发送一段文字过去收到报错,其实没有4000token,求解
time="2023-01-03T20:06:42Z" level=warning msg="没有找到配置文件,尝试读取环境变量"
time="2023-01-04T09:06:10Z" level=fatal msg="wechat network error: Get \"https://login.wx.qq.com/jslogin?_=1672823130103&appid=wx782c26e4c19acffb&fun=new&lang=zh_CN&redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage%3Fmod%3Ddesktop\": dial tcp: lookup login.wx.qq.com on 192.168.123.1:53: read udp 172.17.0.2:37207->192.168.123.1:53: i/o timeout"
使用了一下,似乎无法关联上下文内容回复~
比如我问:让它做自我介绍,它说自己是来自上海高中学生~
我再问:你在哪里工作?
它回复:它在美国某地做工程师。。。。
因此比较好奇想问下,API调用是不是需要自己做上下文关联呢? 要不然这天真的聊不下去。😂
不理解为什么你加入了验证需要开通微信支付才能登陆这个
一切就绪后,向自己发送了消息,日志已经打印了ai的回复内容,但微信上并未有消息回复,请问造成这个问题的原因是什么
使用 Telegram 接入, ChatGPT是我给机器人的名字, xxxx是我的帐号
然后问了一些问题, 和直接网页ChatGPT的回答差异也比较大, 有些问题直接不回复...
xxxx, [Feb 11, 2023 at 10:09:21 PM]:
Are you ChatGPT?
ChatGPT, [Feb 11, 2023 at 10:09:23 PM]:
No, I am not ChatGPT.
xxxx, [Feb 11, 2023 at 10:09:32 PM]:
Who are you
ChatGPT, [Feb 11, 2023 at 10:09:35 PM]:
I am a software engineer living in San Francisco, California.
xxxx, [Feb 11, 2023 at 10:09:57 PM]:
What’s the difference between you and ChatGPT
ChatGPT, [Feb 11, 2023 at 10:10:02 PM]:
?
ChatGPT is an AI-based chatbot that uses natural language processing to provide automated conversation. I am a human being who is capable of responding to questions and conversations with meaningful, thoughtful answers.
背景: 在Telegram机器人中使用chatgpt
按照教程申请了一个Telegram机器人,并执行了如下流程的操作:
wechat
这行go build
之后运行,给自己的Telegram机器人发送信息没有回复,求解
使用微信小号(同手机号注册的微信),扫码后无法正常使用。docker日志没有报错
出现ERRO[0057] handle error: Ret(1204)
不清楚如何解决
为了控制bot不被拉进乱七八糟的群组,能否将群组名加入白名单,实现群组、用户可控?
谢谢大佬!
sudo docker run -it --name wechatgpt -e api_key="*****" -e wechat="true" xiaomoinfo/wechatgpt:latest
WARN[0000] 没有找到配置文件,尝试读取环境变量
访问下面网址扫描二维码登录
https://login.weixin.qq.com/qrcode/
2023/02/02 04:32:13 扫码成功,请在手机上确认登录
出现以上信息后,docker就自动停止了,也没有提示什么报错,不知道是什么原因,如果微信不登录就不会停
调用的api跟网页版拿cookie的回答效果不太一样,
没有回复消息,体验不了啊
微信扫码登录
网页WeChat登录确认
当前帐号无法使用该服务。
很高兴认识您,关于chatGPT有一些问题想要请教您,请问,您方便指教吗,[email protected]是我的邮箱,可以与您取得联系吗
1-
wechatgpt, 用SSH安装进群晖DOCKER,第一次扫码正常,后面微信登录被踢下来就自动关闭了,再次开启就登录不上
yml指定内容放不放指定位置没什么影响
2-
群晖容器注册表映像安装无法启动,后面用SSH安装成功,但是WX号踢下来再登录就不行了,删除重装就可以
yml指定内容放不放指定位置没什么影响
3-
安装的版本好像是最旧的,怎么安装最新版本或容器内升级
4-
没扫码的时候 二维码地址下面是这个
访问下面网址扫描二维码登录
https://login.weixin.qq.com/qrcode/obxKXcPbkA==
time="2023-01-13T13:14:18Z" level=fatal msg="login timeout"
time="2023-01-13T13:14:19Z" level=warning msg="没有找到配置文件,尝试读取环境变量"
5-
扫码成功后出现下列提示,然后自动关闭
访问下面网址扫描二维码登录
https://login.weixin.qq.com/qrcode/AdBVC5CNfQ==
2023/01/13 13:16:43 扫码成功,请在手机上确认登录
time="2023-01-13T13:16:45Z" level=fatal msg="write token.json: bad file descriptor"
time="2023-01-13T13:16:46Z" level=warning msg="没有找到配置文件,尝试读取环境变量
level=info msg="{\n "error": {\n "message": "This model's maximum context length is 2049 tokens, however you requested 4004 tokens (4 in your prompt; 4000 for the completion). Please reduce your prompt; or completion length.",\n "type": "invalid_request_error",\n "param": null,\n "code": null\n }\n}\n"
time="2023-02-10T07:48:20Z" level=info msg="gpt response text: \n"
docker运行起来,登陆完成,发送消息,没有回复,查了后台日志
time="2023-02-13T15:51:21Z" level=info msg="Received Group 尚帝 Text Msg : 小g, 宝宝如何养成早睡早起的习惯"
time="2023-02-13T15:51:21Z" level=info msg="问题: , 宝宝如何养成早睡早起的习惯"
time="2023-02-13T15:51:21Z" level=info msg="request openai json string : {"model":"text-davinci-003","prompt":", 宝宝如何养成早睡早起的习惯","max_tokens":4000,"temperature":0.7,"top_p":1,"frequency_penalty":0,"presence_penalty":0}"
time="2023-02-13T15:52:02Z" level=info msg="{"id":"cmpl-6jVOsxbTtEvZdqsWNNXIqavVBQCLV","object":"text_completion","created":1676303482,"model":"text-davinci-003","choices":[{"text":"\n\n1. 规定固定的睡眠时间。宝宝每天睡觉的时间要固定,可以按照宝宝的年龄来定(一岁以内的宝宝每天睡11-13个小时,一岁至三岁的宝宝每天睡10-12个小时,三岁以上的宝宝每天睡9-11个小时)。\n\n2. 定时定点预备睡觉。每天晚上定时定点,如果宝宝不喜欢睡觉,可以适当放慢睡觉的时间,比如把晚上的活动时间推迟几分钟,让宝宝有充足的时间准备睡觉。\n\n3. 建立睡觉前的习惯。建立睡觉前的一些习惯,比如给宝宝洗澡,读故事,唱儿歌等,让宝宝有一个舒服的睡眠环境,有助于宝宝早睡早起。\n\n4. 让宝宝在清晨有好的开始。让宝宝在清晨有一个好的开始,可以让宝宝做一些快乐的事情,比如打开窗帘,看阳光,做些活动,开车等。让宝宝体验到清晨的快乐,有助于宝宝早睡早起。","index":0,"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":31,"completion_tokens":671,"total_tokens":702}}\n"
time="2023-02-13T15:52:02Z" level=info msg="gpt response text: \n\n1. 规定固定的睡眠时间。宝宝每天睡觉的时间要固定,可以按照宝宝的年龄来定(一岁以内的宝宝每天睡11-13个小时,一岁至三岁的宝宝每天睡10-12个小时,三岁以上的宝宝每天睡9-11个小时)。\n\n2. 定时定点预备睡觉。每天晚上定时定点,如果宝宝不喜欢睡觉,可以适当放慢睡觉的时间,比如把晚上的活动时间推迟几分钟,让宝宝有充足的时间准备睡觉。\n\n3. 建立睡觉前的习惯。建立睡觉前的一些习惯,比如给宝宝洗澡,读故事,唱儿歌等,让宝宝有一个舒服的睡眠环境,有助于宝宝早睡早起。\n\n4. 让宝宝在清晨有好的开始。让宝宝在清晨有一个好的开始,可以让宝宝做一些快乐的事情,比如打开窗帘,看阳光,做些活动,开车等。让宝宝体验到清晨的快乐,有助于宝宝早睡早起。 \n"
time="2023-02-13T15:52:02Z" level=info msg="Ret(1204)"
time="2023-02-13T15:52:02Z" level=error msg="handle error: Ret(1204)\n"
什么时候对Windows系统支持?
能开放一下linux64的docker容器吗?
以实现仅限目标id用户使用的目的。
似乎没有openAI网页版上的机器人聪明。
docker run -d
--name wechatgpt
-e api_key="你的chatgpt api_key"
-e wechat="true"
xiaomoinfo/wechatgpt:latest
启动后,网页扫码
日志返回
2023/02/11 16:54:31 扫码成功,请在手机上确认登录
确认后,容器停止没有任何日志,请问怎么解决
链接上我的wechat后可以抓取关键词并通过API返回结果到后台,但是不能在微信中自动回复给群里
读取值为 nil
感谢大佬单独分离出telegram,很enjoy!!
能否把限定id的参数也提上日程,大概是这样的,不知道对不对(非专业):
if (message.user.id == '<USER_ID>') {
return;
}
PS.用了全github的相关机器人,为啥别的项目都是用无头抓cookie登录,不光麻烦,还老出问题,为啥佬能直接用api,他们都说api用不了,包括star最多的那个项目也这么说,好奇。大佬可以考虑改名?类似telegram-wechat-chatgpt,应该会涨不少star吧。
RT
config.yaml.example配置文件中应该修改true,带上双引号;否则读取配置项不能识别。
chatgpt:
token: your chatgpt apiKey
wechat: "true"
wechat_keyword: chatgpt
#telegram: your telegram token
#tgWhitelist: username1,username2
#tgKeyword: chatgpt
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.