Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
test(agent): expand graph query regression fixture
ce938f1c6ae61
diff --git a/internal/agent/tools/query_knowledge_graph_test.go b/internal/agent/tools/query_knowledge_graph_test.goindex fa8239d18..4807b62c5 100644--- a/internal/agent/tools/query_knowledge_graph_test.go+++ b/internal/agent/tools/query_knowledge_graph_test.go@@ -99,28 +99,53 @@ func TestQueryKnowledgeGraph_ReportsConfiguredEntityAndRelationTypes(t *testing.Enabled: true,Nodes: []*types.GraphNode{{Name: "合同"},- {Name: "部门"},+ {Name: "法务部门"},+ {Name: "审批流程"},+ {Name: "合同"},+ nil,+ {Name: ""},},Relations: []*types.GraphRelation{{Type: "属于"},{Type: "管理"},+ {Type: "审批"},+ {Type: "管理"},+ {Type: ""},+ nil,},},},results: []*types.SearchResult{{- ID: "chunk-1",- Content: "合同管理流程由法务部门负责。",- KnowledgeID: "doc-1",- KnowledgeTitle: "合同管理制度",- Score: 0.91,+ ID: "chunk-approval-1",+ Content: "合同审批流程由法务部门与采购部门共同维护,法务部门负责合规审查。",+ KnowledgeID: "doc-approval",+ KnowledgeTitle: "合同审批管理制度",+ Score: 0.97,+ MatchType: types.MatchTypeEmbedding,+ },+ {+ ID: "chunk-approval-2",+ Content: "采购申请提交后进入合同审批流程,审批完成后归档到合同台账。",+ KnowledgeID: "doc-procurement",+ KnowledgeTitle: "采购与合同协作规范",+ Score: 0.89,+ MatchType: types.MatchTypeKeywords,+ },+ {+ ID: "chunk-approval-3",+ Content: "法务部门管理标准合同模板,并维护合同风险审查清单。",+ KnowledgeID: "doc-legal",+ KnowledgeTitle: "法务部职责说明",+ Score: 0.84,+ MatchType: types.MatchTypeEmbedding,},},})args, err := json.Marshal(QueryKnowledgeGraphInput{KnowledgeBaseIDs: []string{"kb-1"},- Query: "合同管理",+ Query: "合同审批与法务协作",})require.NoError(t, err)@@ -130,15 +155,23 @@ func TestQueryKnowledgeGraph_ReportsConfiguredEntityAndRelationTypes(t *testing.require.True(t, result.Success)t.Logf("tool output:\n%s", result.Output)- assert.Contains(t, result.Output, "Entity Types (2)")- assert.Contains(t, result.Output, "Relationship Types (2)")+ assert.Contains(t, result.Output, "Entity Types (3)")+ assert.Contains(t, result.Output, "Relationship Types (3)")assert.NotContains(t, result.Output, "No entity types configured")assert.NotContains(t, result.Output, "No relationship types configured")assert.Contains(t, result.Output, "合同")+ assert.Contains(t, result.Output, "法务部门")+ assert.Contains(t, result.Output, "审批流程")assert.Contains(t, result.Output, "管理")+ assert.Contains(t, result.Output, "审批")+ assert.Contains(t, result.Output, "✓ Found 3 relevant results (deduplicated)")+ assert.Contains(t, result.Output, "Result #1:")+ assert.Contains(t, result.Output, "Result #2:")+ assert.Contains(t, result.Output, "Result #3:")+ assert.Contains(t, result.Output, "合同审批管理制度")graphConfig, ok := result.Data["graph_config"].(map[string]interface{})require.True(t, ok)- assert.ElementsMatch(t, []string{"合同", "部门"}, graphConfig["nodes"])- assert.ElementsMatch(t, []string{"属于", "管理"}, graphConfig["relations"])+ assert.ElementsMatch(t, []string{"合同", "审批流程", "法务部门"}, graphConfig["nodes"])+ assert.ElementsMatch(t, []string{"属于", "审批", "管理"}, graphConfig["relations"])}