|
@@ -29,7 +29,7 @@ func (l *cAnswer) FindAnswer(ctx context.Context, answerReq *v1.FindAnswerReq) (
|
|
|
jSession := SessionCtx.Get(ctx).JSession
|
|
|
second := g.Cfg().MustGet(ctx, "history.time").Int()
|
|
|
limit := g.Cfg().MustGet(ctx, "history.limit").Int()
|
|
|
- historyData := getHistory(jSession.PositionId, second, limit)
|
|
|
+ historyData := getHistory(ctx, jSession.PositionId, second, limit)
|
|
|
// 查一分钟内的10条 历史信息
|
|
|
req, from := &QuestionReq{
|
|
|
Href: answerReq.Href,
|
|
@@ -148,7 +148,7 @@ type historyData struct {
|
|
|
Answer string
|
|
|
}
|
|
|
|
|
|
-func getHistory(personId int64, second, limit int) [][]string {
|
|
|
+func getHistory(ctx context.Context, personId int64, second, limit int) [][]string {
|
|
|
qStr := `SELECT a. content as question,b.content as answer FROM base_service.ai_message_history a, ai_message_history b where a.person_id=%d and a.create_time>"%s" and b.question_id = a.id order by a.create_time desc limit %d`
|
|
|
st, _ := time.ParseDuration(fmt.Sprintf("-%ds", second))
|
|
|
rs_ := []historyData{}
|
|
@@ -157,12 +157,11 @@ func getHistory(personId int64, second, limit int) [][]string {
|
|
|
query := fmt.Sprintf(qStr, personId, createTime, limit)
|
|
|
err := g.Model("ai_message_history").Raw(query).Scan(&rs_)
|
|
|
if err != nil {
|
|
|
- fmt.Println(err)
|
|
|
+ g.Log().Errorf(ctx, "获取历史记录失败:%v", err)
|
|
|
}
|
|
|
rs := [][]string{}
|
|
|
for i := 0; i < len(rs_); i++ {
|
|
|
rs = append(rs, []string{rs_[i].Question, rs_[i].Answer})
|
|
|
}
|
|
|
- fmt.Println(rs)
|
|
|
return rs
|
|
|
}
|