From 2645d4265ac611e333787759e1234ba5a284b529 Mon Sep 17 00:00:00 2001 From: Havoc412 <2993167370@qq.com> Date: Wed, 20 Nov 2024 03:28:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(model=5Fres):=20=E4=B8=BA=20DocResult=20?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=93=E6=B7=BB=E5=8A=A0=20UpdatedAt=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 DocResult 结构体中添加 UpdatedAt 字段,类型为 *time.Time - 更新 NewDocResult 函数,包含 UpdatedAt 字段 - 修改 DocCurd 服务,获取文档时包含 updated_at 字段 - 启动 ElasticSearch 服务 --- app/model_res/doc.go | 19 +++++++++++-------- app/service/rag/curd/doc_curd.go | 2 +- config/config.yml | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/model_res/doc.go b/app/model_res/doc.go index 565b0a1..00845f9 100644 --- a/app/model_res/doc.go +++ b/app/model_res/doc.go @@ -3,21 +3,24 @@ package model_res import ( "catface/app/model" "catface/app/model_es" + "time" ) // BUG 存在 依賴循環 func NewDocResult(doc *model.Doc, doc_es *model_es.Doc) *DocResult { return &DocResult{ - Type: "doc", - Id: doc.Id, - Name: doc.Name, - Content: doc_es.Content, + Type: "doc", + Id: doc.Id, + Name: doc.Name, + Content: doc_es.Content, + UpdatedAt: doc.UpdatedAt, } } type DocResult struct { - Type string `json:"type"` - Id int64 `json:"id"` - Name string `json:"name"` - Content string `json:"content"` + Type string `json:"type"` + Id int64 `json:"id"` + Name string `json:"name"` + Content string `json:"content"` + UpdatedAt *time.Time `json:"updated_at"` } diff --git a/app/service/rag/curd/doc_curd.go b/app/service/rag/curd/doc_curd.go index 1c3be36..b9a6bce 100644 --- a/app/service/rag/curd/doc_curd.go +++ b/app/service/rag/curd/doc_curd.go @@ -29,7 +29,7 @@ func (d *DocCurd) TopK(embedding []float64, k int) (temp []model_res.DocResult, for _, doc := range docs_es { ids = append(ids, doc.Id) } - docs := d.doc.ShowByIds(ids, "id", "name") + docs := d.doc.ShowByIds(ids, "id", "name", "updated_at") // 装载 for _, doc := range docs { diff --git a/config/config.yml b/config/config.yml index 2455305..c8fd995 100644 --- a/config/config.yml +++ b/config/config.yml @@ -173,7 +173,7 @@ QiNiu: SecretKey: "UP5-GmSmAYNbMlSb6LYLuKZ-fT35nlEzGvOKKm9S" ElasticSearch: - Start: 0 # 0 不启动;1 启动 + Start: 1 # 0 不启动;1 启动 Addr: "http://localhost:9200" UserName: "elastic" Password: ""