Skip to content

实现ChatGPT qq机器人聊天功能,使用gpt-3.5-turbo基于go-cqhttp+golang, 支持联系上下文对话, 关键词触发, 多平台使用

License

Notifications You must be signed in to change notification settings

SuInk/QQ-ChatGPT-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QQ-ChatGPT-Bot

实现openai qq对话功能

image.png

如何使用

前置工作

  1. 前往https://beta.openai.com/account/api-keys 获取api_key
  2. 大陆用户安装Clash Linux参照https://zhuanlan.zhihu.com/p/396272999

正式开始

  1. 下载go-cqhttp
  2. 下载QQ-ChatGPT-Bot

Windows

  • 双击go-cqhttp可执行文件,按照提示登录QQ,选择2正向WebSocket
  • 双击QQ-ChatGPT-Bot可执行文件,将openai的api_key 填入config.cfg中,再次运行
  • 如果要使用角色预设功能,则请在config.cfg中的identity下填写想要bot扮演的角色的信息。同时,请将openai配置下的model更换成“text-davinci-003”。
  • 如果要使用连续对话,请在config.cfg中的context下进行设置。如果要启用角色预设,则不支持连续对话。

Linux

./go-cqhttp*
# 按照提示操作,选择2正向websocket,将本地登录过的`sesssion.token`复制进服务器,防止tx风控
./QQ-ChatGPT*
# 在config.cfg填入openai的api_key
# 其它配置参考windows的说明
# 关掉窗口,运行:
nohup ./go-cqhttp* &
nohup ./QQ-ChatGPT* &

手动运行

先运行go-cqhttp
git clone git@github.com:SuInk/QQ-ChatGPT-Bot.git
cd QQ-ChatGPT-Bot
go run main.go
# 然后根据提示信息修改config.cfg文件
# 再次执行: 
go run main.go

配置文件

cq-http配置文件

# config.yaml cqhttp配置文件
servers:
  # 添加方式,同一连接方式可添加多个,具体配置说明请查看文档
  #- http: # http 通信
  #- ws:   # 正向 Websocket
  #- ws-reverse: # 反向 Websocket
  #- pprof: #性能分析服务器
  # 正向WS设置
  - ws:
      # 正向WS服务器监听地址
      address: 0.0.0.0:8080
      middlewares:
        <<: *default # 引用默认中间件

QQ-ChatGPT-Bot配置文件

...
[openai]
# 你的 OpenAI API Key, 可以在 https://beta.openai.com/account/api-keys 获取
api_key = "sk-xxxxxx" ## 必填
# openai是否走代理,默认关闭
use_proxy = false ## 中国大陆地区需开启
# Clash默认代理地址 Linux使用Clah参照https://zhuanlan.zhihu.com/p/396272999
proxy_url = "http://127.0.0.1:7890"
...

对话指令

  • 在启用连续对话的情景下,聊天中输入/clean将清除之前的对话记录。

About

实现ChatGPT qq机器人聊天功能,使用gpt-3.5-turbo基于go-cqhttp+golang, 支持联系上下文对话, 关键词触发, 多平台使用

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages