MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / execute_graph_rag_fusion

Method execute_graph_rag_fusion

nodedb/src/data/executor/handlers/graph_rag.rs:49–127  ·  view source on GitHub ↗
(
        &self,
        task: &ExecutionTask,
        tenant_id: u64,
        collection: &str,
        query_vector: &[f32],
        vector_top_k: usize,
        edge_label: &Option<String>,
       

Source from the content-addressed store, hash-verified

47impl CoreLoop {
48 #[allow(clippy::too_many_arguments)]
49 pub(in crate::data::executor) fn execute_graph_rag_fusion(
50 &self,
51 task: &ExecutionTask,
52 tenant_id: u64,
53 collection: &str,
54 query_vector: &[f32],
55 vector_top_k: usize,
56 edge_label: &Option<String>,
57 direction: Direction,
58 expansion_depth: usize,
59 final_top_k: usize,
60 rrf_k: (f64, f64),
61 vector_field: &str,
62 max_visited: usize,
63 ) -> Response {
64 debug!(
65 core = self.core_id,
66 %collection,
67 vector_top_k,
68 expansion_depth,
69 final_top_k,
70 "graph rag fusion"
71 );
72
73 let (vector_results, vector_scores) = match self.vector_search_to_node_scores(
74 task,
75 tenant_id,
76 collection,
77 query_vector,
78 vector_top_k,
79 vector_field,
80 ) {
81 Ok(r) => r,
82 Err(resp) => return resp,
83 };
84
85 let start_ids: Vec<&str> = vector_scores.keys().map(String::as_str).collect();
86 let (expanded_nodes, hop_distances, bfs_truncated) = self.bfs_with_distances(
87 tenant_id,
88 &start_ids,
89 edge_label.as_deref(),
90 direction,
91 expansion_depth,
92 max_visited,
93 );
94
95 let (vector_k, graph_k) = rrf_k;
96
97 let vector_list: Vec<RankedResult> = vector_scores
98 .iter()
99 .map(|(node_id, (rank, dist))| RankedResult {
100 document_id: node_id.clone(),
101 rank: *rank,
102 score: *dist,
103 source: "vector",
104 })
105 .collect();
106

Callers 1

dispatch_graphMethod · 0.80

Calls 9

collectMethod · 0.80
bfs_with_distancesMethod · 0.80
build_rag_responseMethod · 0.80
iterMethod · 0.45
cloneMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected