feat:1.历史记录存储任务索引 2.历史记录列表增加任务索引输出
This commit is contained in:
parent
bb33489c45
commit
a47758213c
|
|
@ -253,7 +253,11 @@ func (d *Do) startMessageHandler(
|
|||
requireData *entitys.RequireData,
|
||||
) <-chan struct{} {
|
||||
done := make(chan struct{})
|
||||
var chat []string
|
||||
type chatType struct {
|
||||
Ans string `json:"ans"`
|
||||
TaskIndex string `json:"task_index"`
|
||||
}
|
||||
var chat []chatType
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
|
|
@ -263,10 +267,15 @@ func (d *Do) startMessageHandler(
|
|||
hisLog = &entitys.ChatHisLog{}
|
||||
)
|
||||
if len(chat) > 0 {
|
||||
var ans strings.Builder
|
||||
for _, v := range chat {
|
||||
ans.WriteString(v.Ans)
|
||||
}
|
||||
AiRes := &model.AiChatHi{
|
||||
SessionID: requireData.Session,
|
||||
Ques: requireData.Req.Text,
|
||||
Ans: strings.Join(chat, ""),
|
||||
Ans: ans.String(), // 合并所有回答
|
||||
TaskIndex: chat[len(chat)-1].TaskIndex, // 取最后一个任务索引
|
||||
Files: requireData.Req.Img,
|
||||
TaskID: requireData.Task.TaskID,
|
||||
}
|
||||
|
|
@ -287,7 +296,10 @@ func (d *Do) startMessageHandler(
|
|||
return
|
||||
}
|
||||
if v.Type == entitys.ResponseText || v.Type == entitys.ResponseStream || v.Type == entitys.ResponseJson {
|
||||
chat = append(chat, v.Content)
|
||||
chat = append(chat, chatType{
|
||||
Ans: v.Content,
|
||||
TaskIndex: v.Index,
|
||||
})
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ type AiChatHi struct {
|
|||
Useful int32 `gorm:"column:useful;not null;comment:0不评价,1有用,其他为无用" json:"useful"` // 0不评价,1有用,其他为无用
|
||||
CreateAt time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
TaskID int32 `gorm:"column:task_id;not null" json:"task_id"` // 任务ID
|
||||
Content string `gorm:"column:content" json:"content"` // 前端回传数据
|
||||
TaskID int32 `gorm:"column:task_id;comment:任务id" json:"task_id"` // 任务id
|
||||
TaskIndex string `gorm:"column:task_index;comment:任务索引" json:"task_index"` // 任务索引
|
||||
Content string `gorm:"column:content;comment:前端回传数据" json:"content"` // 前端回传数据
|
||||
}
|
||||
|
||||
// TableName AiChatHi's table name
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ type ChatHisQueryResponse struct {
|
|||
TaskID int32 `gorm:"column:task_id;not null" json:"task_id"` // 任务ID
|
||||
TaskName string `gorm:"column:task_name;not null" json:"task_name"` // 任务名称
|
||||
Contents []string `gorm:"column:contents" json:"contents"` // 前端回传数据
|
||||
TaskIndex string `gorm:"column:task_index" json:"task_index"` // 任务索引
|
||||
}
|
||||
|
||||
func (c *ChatHisQueryResponse) FromModel(chat model.AiChatHi, task model.AiTask) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue