| |
| |
| |
|
|
| use quantarion::prelude::*; |
| use tokio::runtime::Runtime; |
| use federation::OSGClient; |
|
|
| #[tokio::main] |
| async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| |
| let config = QuantarionConfig { |
| edge_count: 27_841, |
| phi43_threshold: 0.998, |
| ghr_threads: 8, |
| federation_sites: 264, |
| unity_port: 8080, |
| }; |
|
|
| |
| let mut rag = QuantarionHyperRAG::new(config).await?; |
| |
| |
| let osg_client = OSGClient::connect(264).await?; |
| rag.sync_federation(&osg_client).await?; |
|
|
| |
| let rt = Runtime::new()?; |
| rt.block_on(rag.serve_production(8000)).await?; |
|
|
| Ok(()) |
| } |
|
|
| #[derive(Clone)] |
| pub struct QuantarionHyperRAG { |
| edges: Vec<QuaternionEdge>, |
| lut_norm: LUTTable<65_536>, |
| lut_phi43: LUTTable<524_288>, |
| phi43_global: f32, |
| } |
|
|
| impl QuantarionHyperRAG { |
| pub async fn query(&mut self, q: &str) -> ProductionResponse { |
| |
| let q_query = self.encode_lut(q); |
| |
| |
| let top_edges = self.traverse_hypergraph(&q_query, 5); |
| |
| |
| let context = self.ghr_reasoning(top_edges.clone()); |
| |
| |
| self.update_phi43(top_edges)?; |
| |
| ProductionResponse { |
| phi43: self.phi43_global, |
| fresh_edges: top_edges.iter().filter(|e| e.is_fresh()).count(), |
| edges_used: top_edges.iter().map(|e| e.edge_id).collect(), |
| context, |
| } |
| } |
| } |