-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加makefile,docker-compose自动build MySQL等 #14
Changes from 7 commits
9a6b4d3
b50f0f6
d512edf
591f076
3725181
bd69697
71a0bf4
a1ede6d
51336ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
GOCMD=go | ||
GOBUILD=$(GOCMD) build | ||
GOCLEAN=$(GOCMD) clean | ||
VERSION=0.1.1 | ||
BINARY_NAME=chatgpt-wecom | ||
|
||
all: amd64 arm64 win64 mac | ||
|
||
dockerenv: | ||
docker build -t ${BINARY_NAME}:${VERSION} -f $(shell pwd)/docker/callback.Dockerfile . | ||
|
||
mac: | ||
GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags "-s -w " -o $(BINARY_NAME).$(VERSION).amd64-darwin ./cmd/app | ||
|
||
amd64: | ||
GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags "-s -w " -o $(BINARY_NAME).$(VERSION).amd64-linux ./cmd/app | ||
|
||
arm64: | ||
GOOS=linux GOARCH=arm64 $(GOBUILD) -ldflags "-s -w " -o $(BINARY_NAME).$(VERSION).arm64-linux ./cmd/app | ||
|
||
win64: | ||
GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags "-s -w -H windowsgui" -o $(BINARY_NAME).$(VERSION).exe ./cmd/app | ||
|
||
clean: | ||
$(GOCLEAN) | ||
rm -f $(BINARY_NAME).$(VERSION).amd64-linux $(BINARY_NAME).$(VERSION).amd64-darwin $(BINARY_NAME).$(VERSION).arm64-linux $(BINARY_NAME).$(VERSION).exe |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,53 +4,59 @@ | |
|
||
相较于官方提供的 `CreateCompletion` 接口,该项目增加了会话管理功能,能够较好地提供多轮对话能力。 | ||
|
||
## 快速开始 | ||
## 快速安装 | ||
|
||
1. 修改配置 | ||
### 0. 前置步骤 | ||
* 登录企业微信的[管理后台](https://work.weixin.qq.com/wework_admin/loginpage_wx)创建机器人,名字随意取 | ||
* 点击【应用管理】-【创建应用】,填写完毕保存。 | ||
|
||
修改 `conf/online.conf` 文件,主要涉及企业微信应用配置、GPT3 API Key、会话管理数据库配置等。 | ||
### 1. 配置 | ||
|
||
修改 `conf/chatgpt.conf` 文件,主要涉及企业微信应用配置、GPT3 API Key、会话管理数据库配置等。 | ||
|
||
- 企业微信应用配置 | ||
- corp_id:在企业微信后台【我的企业】-【企业信息】处获取【企业ID】 | ||
- corp_secret:在企业微信后台【应用管理】处获取【Secret】 | ||
- agent_id:在企业微信后台【应用管理】处获取【AgentId】 | ||
- encoding_aes_key:企业微信后台 【接收消息】- 【API 接收消息】获取【EncodingAESKey】,可以随机生成 | ||
- token:企业微信后台 【接收消息】- 【API 接收消息】获取【Token】,可以随机生成 | ||
- Open AI Key | ||
- OpenAI Key | ||
- 需要自行申请 | ||
- 数据库 | ||
- ~数据库需要自行创建,数据表的创建可以通过命令行方式执行。~ | ||
- 数据库支持 sqlite3,可以通过修改配置使用。如果使用 MySQL,需要自行创建数据库。 | ||
- **数据表在程序启动时自动创建。** | ||
|
||
2. `Docker` 运行 | ||
### 2. 运行 | ||
* **选择1:Docker运行(推荐)** | ||
|
||
```shell | ||
docker-compose up -d | ||
git clone https://github.com/yijia2413/chatgpt-wecom.git | ||
cd chatgpt-wecom | ||
# 构建镜像 | ||
make dockerenv | ||
# 运行带sqlite的镜像,运行前确认chatgpt.conf修改完毕 | ||
docker run -it -d --name chatgpt --restart=always \ | ||
-v $(pwd)/conf/chatgpt.conf:/home/works/program/chatgpt.conf chatgpt-wecom:0.1.1 | ||
``` | ||
|
||
3. ~初始化数据表~ | ||
|
||
数据表在程序启动时自动创建。 | ||
|
||
* **选择2:本地运行** | ||
* 下载对应的二进制,[chatgpt-wecom](https://github.com/yijia2413/chatgpt-wecom/releases) | ||
* 执行命令 `./chatgpt-wecom -conf=conf/chatgpt.conf` 即可,同理需要确认`chatgpt.conf`配置完毕 | ||
|
||
4. 配置企业微信应用。在企业微信后台 【接收消息】- 【API 接收消息】配置接收消息服务器配置。 | ||
### 3. 配置企业微信 | ||
|
||
- URL 配置格式:`http[s]://ip:port/wecom/receive` | ||
* URL 配置格式:`http://ip:port/wecom/receive` | ||
* 在企业微信后台,添加可信IP地址 | ||
|
||
## FAQ | ||
|
||
**怎么创建数据库** | ||
|
||
- v0.1.1 版本中支持 sqlite3 数据库,只需要修改配置文件的配置,程序启动后便会初始化数据库和数据表,不需要额外的操作。 | ||
|
||
- 如果使用的是 MySQL,则需要自行创建数据库,建库 SQL 可以参考下面的命令: | ||
|
||
```sql | ||
CREATE DATABASE chatgpt DEFAULT CHARACTER SET utf8mb4 | ||
``` | ||
- 如果使用的是 MySQL,则需要自行创建数据库,建库 SQL 可以参考下面的命令:[init.sql](/init.sql) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MySQL 只需要建库 SQL 即可,程序启动后便可以自动生成数据库表。保留 init.sql 可以的,也可以不使用初始化脚本。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 删除了建表语句,docker compose 版本会自动建库,手动创建可参考init.sql即可 |
||
|
||
之后程序启动后,便可以自动创建数据表。 | ||
|
||
**数据库连接失败** | ||
|
||
|
@@ -79,9 +85,6 @@ driver="sqlite3" | |
dataSource="file:chatgpt?_fk=1&parseTime=True" | ||
``` | ||
|
||
|
||
|
||
|
||
## Changelog | ||
|
||
### v0.1.1 | ||
|
@@ -94,4 +97,7 @@ dataSource="file:chatgpt?_fk=1&parseTime=True" | |
|
||
### v0.1.0 | ||
|
||
- 项目初始化 | ||
- 项目初始化 | ||
|
||
### Happy Chatting | ||
![img](/png/example.jpg) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,18 @@ version = "0.1.1" | |
port = 8000 | ||
|
||
[logger] | ||
level = "debug" | ||
level = "info" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我觉得可以默认 debug,用户试用阶段有一些日志也好排查问题。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修正 |
||
console_enabled = true | ||
file_enabled = true | ||
filename = "logs/chatgpt-wecom.log" | ||
|
||
[gpt] | ||
api_key = "" | ||
api_key = "sk-" | ||
|
||
[wecom] | ||
corp_id="" | ||
corp_secret="" | ||
agent_id=0 | ||
agent_id= | ||
encoding_aes_key="" | ||
token="" | ||
url="https://qyapi.weixin.qq.com" | ||
|
@@ -34,4 +34,4 @@ dataSource="file:chatgpt?_fk=1&parseTime=True" | |
closeSessionFlag="/restart" | ||
closeSessionReply="会话已重启。" | ||
enableEnterEvent=true | ||
enterEventReply="欢迎来到 ChatGPT,在这里您可以和我对话,我将尽我所能回答您的问题。如果想关闭会话,请回复“/restart”。" | ||
enterEventReply="欢迎来到 ChatGPT,在这里您可以和我对话,我将尽我所能回答您的问题。如果想关闭会话,请回复“/restart”。" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mac 上应该有 amd64 和 arm64 两个版本
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done by 51336ba