- 重构了 rag_controller.go 中的逻辑,使用新的 DocumentHub 结构 - 修改了 encounter.go 中的 Encounter 结构,增加了 explain 标签 - 重写了 rag_websocket.go 中的逻辑,使用新的 DocumentHub 结构 - 新增了 curd_es/encounter_es_curd.go 文件,实现了 Encounter 的 CURD 操作 - 更新了 nlp/func.go 中的 ChatRAG 函数,使用新的 DocumentHub 结构 - 新增了 curd/docs_hub.go 文件,实现了 DocumentHub 的 TopK 方法 - 新增了 utils/data_explain/data_explain_rag.go 文件,实现了结构体到解释字符串的转换
30 lines
837 B
Go
30 lines
837 B
Go
package model_res
|
||
|
||
import (
|
||
"catface/app/model"
|
||
"catface/app/model_es"
|
||
"fmt"
|
||
"time"
|
||
)
|
||
|
||
func NewEncounterResult(encounter *model.Encounter, encounter_es *model_es.Encounter) *EncounterResult {
|
||
return &EncounterResult{
|
||
DocBase: DocBase{Type: "encounter"},
|
||
Id: encounter.Id,
|
||
Title: encounter.Title,
|
||
Content: encounter.Content,
|
||
UpdatedAt: encounter.UpdatedAt}
|
||
}
|
||
|
||
type EncounterResult struct {
|
||
DocBase
|
||
Id int64 `json:"id"`
|
||
Title string `json:"title" explain:"路遇笔记标题"`
|
||
Content string `json:"content" explain:"内容"`
|
||
UpdatedAt *time.Time `json:"updated_at" explain:"最后更新时间"`
|
||
}
|
||
|
||
func (e EncounterResult) ToString() string {
|
||
return fmt.Sprintf(`路遇笔记标题:%s;路遇笔记内容:%s;最后更新时间:%v`, e.Title, e.Content, e.UpdatedAt)
|
||
}
|