這些天,ChatGPT可以說(shuō)火爆全網(wǎng),各種玩法層出不窮。前兩天還看到不少人討論,要是ChatGPT接入微信是啥感覺(jué)?
這不,Github開(kāi)源項(xiàng)目都已經(jīng)來(lái)了,Github Trending上就有推薦~
![ab298458-7a8a-11ed-8abf-dac502259ad0.png](https://file1.elecfans.com//web2/M00/9D/F1/wKgZomToDaeAVGYIAAF43sGby10366.png)
來(lái)看效果,ChatGPT就出現(xiàn)在普通的微信對(duì)話框里,有問(wèn)必答:
![ab446750-7a8a-11ed-8abf-dac502259ad0.png](https://file1.elecfans.com//web2/M00/9D/F1/wKgZomToDaeADsSWAAdTNmlPoOY360.png)
具體怎么實(shí)現(xiàn)的?接下來(lái)一起來(lái)看看~
ChatGPT-wechat-bot
該方法需要用到Docker,而且也要有注冊(cè)好的OpenAI賬號(hào),下面簡(jiǎn)單介紹下。
基于NodeJS環(huán)境和聊天機(jī)器人開(kāi)源項(xiàng)目webchaty,AI可在群里回復(fù)消息。
配置Docker文件:
//build
dockerbuild--pull--rm-f"Dockerfile"-twechatbot:latest"."
//run,andthenyouwillseesomelogs
dockerrun--namewechatbotwechatbot:latest
從OpenAI處獲取session-token。
方法為登錄ChatGPT網(wǎng)頁(yè),點(diǎn)擊“開(kāi)發(fā)者工具”,進(jìn)入Application欄,在Cookie下拉菜單找到chat.openai.com,就能看到Secure-next-auth.session-token的值:
![ab6951a0-7a8a-11ed-8abf-dac502259ad0.png](https://file1.elecfans.com//web2/M00/9D/F1/wKgZomToDaeAVE47AAXGXmk2qEM595.png)
將Token值替換src/index.js內(nèi)的“ChatGPTSessionToken”,然后,在本地運(yùn)行下面的代碼:
//installdependencies
npmi
//start:
//dev
npmrundev
//or
//build
npmrunbuild
//runlib
nodelib/bundle.esm.js
這樣,就能看到其正在運(yùn)行,再通過(guò)掃描二維碼,登錄你的微信。
如此一來(lái),向你的微信發(fā)送信息,就能收到回復(fù)。
![ab970dd4-7a8a-11ed-8abf-dac502259ad0.png](https://file1.elecfans.com//web2/M00/9D/F1/wKgZomToDaeAZmwPAAF0VeRp3hU152.png)
作者展示,其回復(fù)表現(xiàn)如下,目前已獲 600+ Star。
![aba83136-7a8a-11ed-8abf-dac502259ad0.png](https://file1.elecfans.com//web2/M00/9D/F1/wKgZomToDaeAWzIyAAIctqpa2k0893.png)
項(xiàng)目地址:https://github.com/AutumnWhj/ChatGPT-wechat-bot
基于 Spring Boot + MyBatis Plus + Vue & Element 實(shí)現(xiàn)的后臺(tái)管理系統(tǒng) + 用戶小程序,支持 RBAC 動(dòng)態(tài)權(quán)限、多租戶、數(shù)據(jù)權(quán)限、工作流、三方登錄、支付、短信、商城等功能
- 項(xiàng)目地址:https://github.com/YunaiV/ruoyi-vue-pro
- 視頻教程:https://doc.iocoder.cn/video/
wechat-chatgpt
該方法同樣基于wechaty需與Docker一同“食用”,不過(guò)獲贊更多。
老樣子,配置Docker。
cpconfig.yaml.exampleconfig.yaml
>基于SpringCloudAlibaba+Gateway+Nacos+RocketMQ+Vue&Element實(shí)現(xiàn)的后臺(tái)管理系統(tǒng)+用戶小程序,支持RBAC動(dòng)態(tài)權(quán)限、多租戶、數(shù)據(jù)權(quán)限、工作流、三方登錄、支付、短信、商城等功能
>
>*項(xiàng)目地址://github.com/YunaiV/yudao-cloud>
>*視頻教程://doc.iocoder.cn/video/>
#ChangeConfig.yaml
dockerrun-d--namewechat-chatgpt-v$(pwd)/config.yaml:/app/config.yamlholegots/wechat-chatgpt:latest
#loginwithqrcode
dockerlogs-fwechat-chatgpt
從GitHub下載文件包后進(jìn)行安裝:
npminstall&&poetryinstall
然后復(fù)制配置文件設(shè)置項(xiàng)目。
cpconfig.yaml.exampleconfig.yaml
配置OpenAI賬密:
chatGPTAccountPool:
-email:
password:
#ifyouhopeonlysomekeywordscantriggerchatgptonprivatechat,youcansetitlikethis:
chatPrivateTiggerKeyword:""
然后啟動(dòng)項(xiàng)目即可,如第一次登錄,需掃描二維碼。
npmrundev
目前,該方式在GitHub上獲星已超2k。
項(xiàng)目地址:https://github.com/fuergaosi233/wechat-chatgpt
wechat-chatGPT
這是一個(gè)具有微信公眾號(hào)被動(dòng)回復(fù)用戶消息功能的 ChatGPTBot 實(shí)現(xiàn)
配置方法
- 在 main.go 文件中填入,微信公眾平臺(tái)中設(shè)置的 Token
- 在 sessionToken 文件中填入chat.openai.com 里 Cookie 中的 __Secure-next-auth.session-token
- 編譯項(xiàng)目,并部署到服務(wù)器中 默認(rèn)監(jiān)聽(tīng)本機(jī) 127.0.0.1:7458, 請(qǐng)自行通過(guò) Nginx 或 Caddy 等反向代理工具進(jìn)行轉(zhuǎn)發(fā)
- 在微信公眾平臺(tái)中設(shè)置服務(wù)器地址為你的服務(wù)器地址。
Session 獲取方法
這個(gè)上面也提到過(guò),從OpenAI處獲取session-token。
方法為登錄ChatGPT網(wǎng)頁(yè),點(diǎn)擊“開(kāi)發(fā)者工具”,進(jìn)入Application欄,在Cookie下拉菜單找到chat.openai.com,就能看到Secure-next-auth.session-token的值:
![ab6951a0-7a8a-11ed-8abf-dac502259ad0.png](https://file1.elecfans.com//web2/M00/9D/F1/wKgZomToDaeAVE47AAXGXmk2qEM595.png)
編譯命令
GOOS=linuxGOARCH=amd64GOARM=GOMIPS=
CGO_ENABLED=0
gobuild-trimpath-o./dist/weChatGPT
-ldflags"-w-s-buildid="
注意:sessionToken 文件請(qǐng)放置與可執(zhí)行文件同一目錄下,并且只保留__Secure-next-auth.session-token的內(nèi)容。
效果
![abe90ec2-7a8a-11ed-8abf-dac502259ad0.png](https://file1.elecfans.com//web2/M00/9D/F1/wKgZomToDaeATH85AAaU8asIWAI986.png)
項(xiàng)目地址:https://github.com/gtoxlili/wechat-chatGPT
后 記
最后,再聊聊上述實(shí)現(xiàn)方法的注意事項(xiàng):
1、還是需要有OpenAI的賬號(hào),要先完成注冊(cè)。
2、將用到Docker、Go等,且需要獲取token,完全小白嘗試起來(lái)可能有點(diǎn)難度。
3、文中,基于NodeJS和webchaty的方式如若無(wú)法登錄微信,請(qǐng)檢查項(xiàng)目根目錄是否有文件—— wechaty-puppet-wechat.memory-card.json,如果有,請(qǐng)刪除后重試。
4、最后一種方法,如無(wú)法通過(guò)上述配置登錄OpenAI,也可手動(dòng)登錄獲取session token,保存至config.yaml的方式。(獲取方式前文已呈現(xiàn))
5、目前ChatGPT使用者過(guò)多,一時(shí)難以登錄,不妨過(guò)幾個(gè)小時(shí)再試試。
審核編輯 :李倩
-
GitHub
+關(guān)注
關(guān)注
3文章
474瀏覽量
16614 -
OpenAI
+關(guān)注
關(guān)注
9文章
1157瀏覽量
6747 -
ChatGPT
+關(guān)注
關(guān)注
29文章
1570瀏覽量
8108
原文標(biāo)題:ChatGPT能接入微信了!
文章出處:【微信號(hào):芋道源碼,微信公眾號(hào):芋道源碼】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論