소스 검색

wip:语义分析调整

wangkaiyue 2 년 전
부모
커밋
c638c47df3
2개의 변경된 파일8개의 추가작업 그리고 9개의 파일을 삭제
  1. 8 8
      internal/model/question.go
  2. 0 1
      internal/model/ws.go

+ 8 - 8
internal/model/question.go

@@ -100,18 +100,18 @@ func (q *cQuestion) DetailQuestion(ctx context.Context, qRes *QuestionReq) (repl
 	if err != nil {
 		return "", 0, err
 	}
-	if sRes.Result.Answer != "" {
-		return sRes.Result.Answer, Answer_ChatGPT, nil
+	if sRes.Result.Answer == "" {
+		cRes, err := ChatGpt.GPTDo(ctx, qRes)
+		if err != nil {
+			return "", 0, err
+		}
+		return fsw.Repl(cRes.Response), Answer_ChatGPT, nil
 	}
 
-	cRes, err := ChatGpt.GPTDo(ctx, qRes)
-	if err != nil {
-		return "", 0, err
-	}
 	// 校验是否有业务逻辑
-	matchArr := regExpSmart.FindStringSubmatch(cRes.Response)
+	matchArr := regExpSmart.FindStringSubmatch(sRes.Result.Answer)
 	if len(matchArr) == 0 {
-		return fsw.Repl(cRes.Response), Answer_ChatGPT, nil
+		return fsw.Repl(sRes.Result.Answer), Answer_UsuallyProblem, nil
 	}
 	// 查询业务逻辑
 	var bRes = &BusinessRes{}

+ 0 - 1
internal/model/ws.go

@@ -35,7 +35,6 @@ func (m *WsChat) Handle(ws *ghttp.WebSocket, msg []byte) {
 		glog.Errorf(m.Ctx, "%d 接收消息Unmarshal出错:%v", jSession.PositionId, err)
 		return
 	}
-
 	reply, replyId, errMsg := func() (string, int64, error) {
 		questionId := ChatHistory.Save(m.Ctx, &ChatRecord{
 			Content:    req.Prompt,