Browse Source

调整一些内容

eryajf 2 years ago
parent
commit
e39c339975
3 changed files with 31 additions and 8 deletions
  1. 16 0
      Makefile
  2. 15 5
      README.md
  3. 0 3
      gtp/gtp.go

+ 16 - 0
Makefile

@@ -0,0 +1,16 @@
+default: build
+
+run:
+	GIN_MODE=release go run main.go
+
+build:
+	go build -o chatgpt-dingtalk main.go
+
+build-linux:
+	CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o chatgpt-dingtalk main.go
+
+build-linux-arm:
+	CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -o chatgpt-dingtalk main.go
+
+lint:
+	env GOGC=25 golangci-lint run --fix -j 8 -v ./...

+ 15 - 5
README.md

@@ -22,7 +22,7 @@
 
 `感谢:`这个项目借鉴了[wechatbot](https://github.com/869413421/wechatbot.git),wechatbot是一个能够集成到个人微信的GPT机器人,如果需要,可以前去体验。
 
-### 功能简介
+## 功能简介
 
 * 支持在钉钉群聊中添加机器人,通过@机器人进行聊天交互。
 * 提问增加上下文(可能不太理想),更接近官网效果。
@@ -82,6 +82,8 @@ $ docker run -itd --name chatgpt -p 8090:8090  -v `pwd`/config.json:/app/config.
 
 其中配置文件参考下边的配置文件说明。
 
+注意,不论通过上边哪种docker方式部署,都需要配置Nginx代理,当然你直接通过服务器外网IP也可以。
+
 部署完成之后,通过Nginx代理本服务:
 
 ```nginx
@@ -164,7 +166,7 @@ $ tail -f run.log
 
 ## 本地开发
 
-````sh
+```sh
 # 获取项目
 $ git clone https://github.com/eryajf/chatgpt-dingtalk.git
 
@@ -176,10 +178,11 @@ $ cp config.dev.json config.json
 
 # 启动项目
 $ go run main.go
-````
+```
 
 ## 配置文件说明
-````json
+
+```json
 {
     "api_key": "xxxxxxxxx",  // openai api_key
     "session_timeout": 60,   // 会话超时时间,默认60秒,在会话时间内所有发送给机器人的信息会作为上下文
@@ -188,4 +191,11 @@ $ go run main.go
     "temperature": 0.9, // GPT热度,0到1,默认0.9。数字越大创造力越强,但更偏离训练事实,越低越接近训练事实
     "session_clear_token": "清空会话" // 会话清空口令,默认`清空会话`
 }
-````
+```
+
+## 常见问题
+
+- Q: 钉钉群聊艾特机器人之后,没有回应,应用也没有任何输出
+  - A: 注意钉钉艾特群聊之后,会通过上文配置的回调IP与域名把请求发过来,如果这个环节有问题,那么是接收不到请求的,因此配置完成之后,建议通过curl验证下自己的服务。
+- Q: 一切配置完毕之后,群聊艾特机器人没有反应,看应用输出内容为:回调参数为空,以至于无法正常解析,请检查原因
+  - A: 可能是创建的机器人有问题,建议重新走一遍创建机器人的流程,创建一个新的机器人再试试。

+ 0 - 3
gtp/gtp.go

@@ -6,7 +6,6 @@ import (
 	"errors"
 	"fmt"
 	"io/ioutil"
-	"log"
 	"net/http"
 	"time"
 
@@ -90,7 +89,6 @@ func Completions(msg string) (string, error) {
 	logger.Info(fmt.Sprintf("response gtp json string : %v", string(body)))
 
 	gptResponseBody := &ChatGPTResponseBody{}
-	log.Println(string(body))
 	err = json.Unmarshal(body, gptResponseBody)
 	if err != nil {
 		return "", err
@@ -100,6 +98,5 @@ func Completions(msg string) (string, error) {
 	if len(gptResponseBody.Choices) > 0 {
 		reply = gptResponseBody.Choices[0].Text
 	}
-	logger.Info(fmt.Sprintf("gpt response text: %s ", reply))
 	return reply, nil
 }