本项目旨在通过不到 100 行的 Golang 代码搭建一个微信公众号 ChatGPT,实现基本的智能聊天功能。
wget https://github.com/crazyStrongboy/official_account_gpt/releases/download/v0.0.1/official_account_gpt-linux-amd64.tar.gz
tar -zxvf official_account_gpt-linux-amd64.tar.gz
./offical_account_gpt --wx_app_id=xx --wx_ori_id=yy --wx_token=zz --wx_aes_key=kk --token=tt
其中,wx_app_id
、wx_ori_id
、wx_token
、wx_aes_key
分别为微信公众号的开发者ID、原始ID、令牌和消息加解密密钥,token
为 ChatGpt API token。
在微信公众平台中,进入“设置与开发/基本配置”页面,启用服务器配置:
- URL:
http://yourserver.com/wechat
- Token:
your_wechat_token
- 消息加解密模式:安全模式
将 yourserver.com
替换为你的服务器域名或 IP 地址,将 your_wechat_token
替换为你自己定义的 Token。
现在,你可以在微信公众号中向 ChatGPT 发送消息,ChatGPT 将会自动回复你的消息。