mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-17 13:58:25 +08:00
Port dataset nav and structure graph fixes to Go, merge agents list (#18183)
Fix compilation template config validation for JSONMap; merge template groups into agents list ordered by category/name; install nav service in ingestor; write readable nav cluster/doc names and emit nav_doc leaves; port tree-to-graph projection and full document structure graph endpoint parity.
This commit is contained in:
@@ -393,9 +393,12 @@ func setupAgentRouter(svc agentServiceIface) *gin.Engine {
|
||||
|
||||
func TestListAgents_Success(t *testing.T) {
|
||||
title := "My Agent"
|
||||
agentJSON, _ := json.Marshal(service.AgentItem{
|
||||
ID: "canvas-1", Title: &title, Permission: "me", CanvasCategory: "agent_canvas",
|
||||
})
|
||||
svc := &fakeAgentService{
|
||||
result: &service.ListAgentsResponse{
|
||||
Canvas: []*service.AgentItem{{ID: "canvas-1", Title: &title, Permission: "me", CanvasCategory: "agent_canvas"}},
|
||||
Canvas: []json.RawMessage{agentJSON},
|
||||
Total: 1,
|
||||
},
|
||||
code: common.CodeSuccess,
|
||||
|
||||
@@ -339,7 +339,9 @@ func (h *DatasetArtifactHandler) ListNavigation(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeDataError, err.Error())
|
||||
return
|
||||
}
|
||||
common.SuccessWithData(c, gin.H{"total": total, "nav": items}, "success")
|
||||
// Response key is "items" (not "nav") — the frontend DatasetNavList reads
|
||||
// data.items and Python list_nav_clusters/_nav_search return {"total","items"}.
|
||||
common.SuccessWithData(c, gin.H{"total": total, "items": items}, "success")
|
||||
}
|
||||
|
||||
// DeleteNavigation handles DELETE /navigation — delete all navigation clusters.
|
||||
@@ -381,7 +383,9 @@ func (h *DatasetArtifactHandler) ListNavigationChildren(c *gin.Context) {
|
||||
common.ErrorWithCode(c, common.CodeDataError, err.Error())
|
||||
return
|
||||
}
|
||||
common.SuccessWithData(c, gin.H{"total": total, "children": items}, "success")
|
||||
// Same contract as the top-level nav list: Python list_nav_children returns
|
||||
// {"total","items"} and the frontend reads data.items for child expansion.
|
||||
common.SuccessWithData(c, gin.H{"total": total, "items": items}, "success")
|
||||
}
|
||||
|
||||
// GetSkillTree handles GET /skills — skill tree.
|
||||
@@ -453,13 +457,20 @@ func (h *DatasetArtifactHandler) GetDocumentGraph(c *gin.Context) {
|
||||
}
|
||||
datasetID := c.Param("dataset_id")
|
||||
documentID := c.Param("document_id")
|
||||
graphType := c.Query("graph_type")
|
||||
items, total, err := h.svc.GetDocumentGraph(c.Request.Context(), tenantID, datasetID, documentID, graphType)
|
||||
resp, err := h.svc.GetDocumentGraph(c.Request.Context(), service.DocumentStructureGraphInput{
|
||||
TenantID: tenantID,
|
||||
DatasetID: datasetID,
|
||||
DocumentID: documentID,
|
||||
Keywords: c.Query("keywords"),
|
||||
})
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeDataError, err.Error())
|
||||
return
|
||||
}
|
||||
common.SuccessWithData(c, gin.H{"total": total, "graph": items}, "success")
|
||||
if resp == nil {
|
||||
resp = &service.DocumentStructureGraphResponse{Templates: []service.DocumentStructureGraphTemplate{}}
|
||||
}
|
||||
common.SuccessWithData(c, resp, "success")
|
||||
}
|
||||
|
||||
// DeleteDocumentGraph handles DELETE /documents/<document_id>/structure/graph — delete document structure graph.
|
||||
|
||||
Reference in New Issue
Block a user