浏览代码

wip:对接提交

wangkaiyue 2 年之前
父节点
当前提交
c8d5604a9a
共有 3 个文件被更改,包括 4 次插入12 次删除
  1. 0 8
      internal/model/chatApi.go
  2. 1 1
      internal/model/chatHistory.go
  3. 3 3
      internal/model/question.go

+ 0 - 8
internal/model/chatApi.go

@@ -6,7 +6,6 @@ import (
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/net/gclient"
 	"github.com/gogf/gf/v2/util/gconv"
-	"github.com/gogf/gf/v2/util/grand"
 )
 
 type GPTReq struct {
@@ -35,13 +34,6 @@ var (
 )
 
 func (c *cChatGpt) Do(ctx context.Context, qReq *QuestionReq) (res *GPTRes, err error) {
-	//模拟请求
-	return &GPTRes{
-		Status:   0,
-		Response: tmp[grand.Intn(len(tmp)-1)],
-		History:  nil,
-	}, nil
-	//
 	gReq := GPTReq{
 		BaseQuestion: qReq.BaseQuestion,
 		Identity:     g.Config().MustGet(ctx, "chat.api.identity", "剑鱼chat").String(),

+ 1 - 1
internal/model/chatHistory.go

@@ -81,7 +81,7 @@ func (m *cChatHistroy) Save(ctx context.Context, msgs ...*ChatRecord) (id int64)
 // GetMessage 查询聊天信息
 func (m *cChatHistroy) GetMessage(userId int64, pageNum, pageSize int, prevId string) (h []ResHistory, err error) {
 	if prevId != "" {
-		err = g.Model("ai_message_history").Where("person_id = ? and id > ? ", userId, prevId).OrderAsc("id").Limit(0, pageSize).Scan(&h)
+		err = g.Model("ai_message_history").Where("person_id = ? and id > ? ", userId, prevId).OrderDesc("id").Limit(0, pageSize).Scan(&h)
 	} else {
 		err = g.Model("ai_message_history").Where("person_id = ?", userId).OrderDesc("create_time").OrderDesc("id").Limit(pageNum*pageSize, (pageNum+1)*pageSize).Scan(&h)
 	}

+ 3 - 3
internal/model/question.go

@@ -26,8 +26,8 @@ type cQuestion struct {
 }
 
 type BaseQuestion struct {
-	Prompt  string                   `json:"prompt"`
-	History []map[string]interface{} `json:"history"`
+	Prompt  string     `json:"prompt"`
+	History [][]string `json:"history"`
 }
 
 type QuestionReq struct {
@@ -92,6 +92,7 @@ func (q *cQuestion) getIsbusinessData(ctx context.Context, code string) (bRes *B
 // DetailQuestion 问题处理
 func (q *cQuestion) DetailQuestion(ctx context.Context, qRes *QuestionReq) (reply string, from int, err error) {
 	cRes, err := ChatGpt.Do(ctx, qRes)
+	g.Dump(qRes.Prompt, "---", cRes)
 	if err != nil {
 		return "", 0, err
 	}
@@ -140,7 +141,6 @@ func (q *cQuestion) DetailQuestion(ctx context.Context, qRes *QuestionReq) (repl
 		UserId:     jSession.UserId,
 		Answer:     bRes.Answer,
 		BiddingId:  infoId,
-		IsEnt:      false,
 		BaseUserId: jSession.NewUid,
 	})
 	if err != nil {