#![allow(unused_imports)]
use crate::config::Config;
use crate::core::{
ChunkId, Document, DocumentId, Entity, EntityId, GraphRAGError, KnowledgeGraph, Relationship,
Result, TextChunk,
};
use crate::{critic, ollama, persistence, query, retrieval};
#[cfg(feature = "parallel-processing")]
#[allow(unused_imports)]
use crate::parallel;
mod ask;
mod build;
mod documents;
mod factory;
mod lifecycle;
mod stats;
pub struct GraphRAG {
config: Config,
knowledge_graph: Option<KnowledgeGraph>,
retrieval_system: Option<retrieval::RetrievalSystem>,
query_planner: Option<query::planner::QueryPlanner>,
#[cfg_attr(not(feature = "async"), allow(dead_code))]
critic: Option<critic::Critic>,
#[cfg(feature = "parallel-processing")]
#[allow(dead_code)]
parallel_processor: Option<parallel::ParallelProcessor>,
}
impl GraphRAG {
pub(super) fn ensure_initialized(&mut self) -> Result<()> {
if !self.is_initialized() {
self.initialize()
} else {
Ok(())
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_builder_pattern() {
let graphrag = GraphRAG::builder()
.with_output_dir("./test_output")
.with_chunk_size(512)
.with_top_k(10)
.build();
assert!(graphrag.is_ok());
}
}