feat: 同步知识库与工作台相关改动
This commit is contained in:
@@ -50,18 +50,19 @@ func KnowledgeScan(c *gin.Context) {
|
||||
continue
|
||||
}
|
||||
src := model.KnowledgeSource{
|
||||
Title: parseTitle(string(data)),
|
||||
FilePath: e.Name(),
|
||||
Category: fm["category"],
|
||||
Domain: orDefault(fm["domain"], "product"),
|
||||
SourceVersion: fm["version"],
|
||||
AuditStatus: "pending",
|
||||
Title: parseTitle(string(data)),
|
||||
FilePath: e.Name(),
|
||||
Category: fm["category"],
|
||||
Domain: orDefault(fm["domain"], "product"),
|
||||
SourceVersion: fm["version"],
|
||||
AuditStatus: "pending",
|
||||
KnowledgeSpaceKey: ensureKnowledgeSpaceKeyOrDefault(orDefault(fm["knowledge_space_key"], inferKnowledgeSpaceKey(parseTitle(string(data)), fm["domain"], fm["category"]+" "+e.Name()))),
|
||||
}
|
||||
if err := store.DB.Create(&src).Error; err != nil {
|
||||
results = append(results, gin.H{"file_path": e.Name(), "status": "error", "title": src.Title})
|
||||
continue
|
||||
}
|
||||
results = append(results, gin.H{"file_path": e.Name(), "status": "created", "title": src.Title})
|
||||
results = append(results, gin.H{"file_path": e.Name(), "status": "created", "title": src.Title, "knowledge_space_key": src.KnowledgeSpaceKey})
|
||||
}
|
||||
web.OK(c, gin.H{"results": results})
|
||||
}
|
||||
@@ -72,6 +73,9 @@ func KnowledgeAuditList(c *gin.Context) {
|
||||
if s := c.Query("status"); s != "" {
|
||||
q = q.Where("audit_status = ?", s)
|
||||
}
|
||||
if key := sanitizeSpaceKey(c.Query("knowledge_space_key")); key != "" {
|
||||
q = q.Where("knowledge_space_key = ?", key)
|
||||
}
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
size, _ := strconv.Atoi(c.DefaultQuery("size", "20"))
|
||||
if page < 1 {
|
||||
@@ -129,6 +133,7 @@ func KnowledgeAudit(c *gin.Context) {
|
||||
web.Fail(c, web.NewBadRequest("审批失败"))
|
||||
return
|
||||
}
|
||||
triggerKnowledgeIndexRebuild()
|
||||
web.OK(c, gin.H{
|
||||
"status": "approved", "source_id": src.ID,
|
||||
"products": counts[0], "chunks": counts[1], "questions": counts[2],
|
||||
@@ -164,9 +169,10 @@ func KnowledgeStatus(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
web.OK(c, gin.H{
|
||||
"audit_status": src.AuditStatus,
|
||||
"ingested": src.Ingested,
|
||||
"reject_reason": src.RejectReason,
|
||||
"audit_status": src.AuditStatus,
|
||||
"ingested": src.Ingested,
|
||||
"reject_reason": src.RejectReason,
|
||||
"knowledge_space_key": resolveKnowledgeSourceSpaceKey(src),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -349,6 +355,7 @@ func ingestSource(src *model.KnowledgeSource) ([3]int, error) {
|
||||
KnowledgeSourceID: &src.ID,
|
||||
SourceType: "md",
|
||||
SourceID: strconv.FormatUint(uint64(src.ID), 10),
|
||||
KnowledgeSpaceKey: resolveKnowledgeSourceSpaceKey(*src),
|
||||
ChunkIndex: i,
|
||||
Content: text,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user