fix:会话历史
This commit is contained in:
parent
7ac61893f5
commit
2c9874a180
|
|
@ -4,6 +4,7 @@ import (
|
|||
"ai_scheduler/internal/data/constants"
|
||||
"ai_scheduler/internal/data/model"
|
||||
"encoding/json"
|
||||
"log"
|
||||
)
|
||||
|
||||
type ChatHistory struct {
|
||||
|
|
@ -33,7 +34,7 @@ type ChatHisQueryResponse struct {
|
|||
CreateAt string `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
|
||||
TaskID int32 `gorm:"column:task_id;not null" json:"task_id"` // 任务ID
|
||||
TaskName string `gorm:"column:task_name;not null" json:"task_name"` // 任务名称
|
||||
Content []string `gorm:"column:content" json:"content"` // 前端回传数据
|
||||
Contents []string `gorm:"column:contents" json:"contents"` // 前端回传数据
|
||||
}
|
||||
|
||||
func (c *ChatHisQueryResponse) FromModel(chat model.AiChatHi, task model.AiTask) {
|
||||
|
|
@ -46,15 +47,15 @@ func (c *ChatHisQueryResponse) FromModel(chat model.AiChatHi, task model.AiTask)
|
|||
c.CreateAt = chat.CreateAt.Format("2006-01-02 15:04:05")
|
||||
c.TaskID = chat.TaskID
|
||||
c.TaskName = task.Name
|
||||
c.Content = make([]string, 0)
|
||||
c.Contents = make([]string, 0)
|
||||
|
||||
// 解析Content
|
||||
if "" != chat.Content {
|
||||
var contents []string
|
||||
if err := json.Unmarshal([]byte(chat.Content), &contents); err != nil {
|
||||
c.Content = contents
|
||||
err := json.Unmarshal([]byte(chat.Content), &c.Contents)
|
||||
if err != nil {
|
||||
c.Contents = append(c.Contents, chat.Content)
|
||||
log.Println("解析Content失败 error: ", err)
|
||||
}
|
||||
c.Content = append(c.Content, chat.Content)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue