pub struct GraphRAGBuilder { /* private fields */ }Expand description
Builder for GraphRAG instances
Provides a fluent API for configuring GraphRAG with various options.
Implementations§
Source§impl GraphRAGBuilder
impl GraphRAGBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with default configuration
§Example
use graphrag_core::builder::GraphRAGBuilder;
let builder = GraphRAGBuilder::new();Sourcepub fn with_output_dir(self, dir: &str) -> Self
pub fn with_output_dir(self, dir: &str) -> Self
Set the output directory for storing graphs and data
§Example
let builder = GraphRAGBuilder::new()
.with_output_dir("./my_workspace");Sourcepub fn with_chunk_size(self, size: usize) -> Self
pub fn with_chunk_size(self, size: usize) -> Self
Set the chunk size for text processing
§Example
let builder = GraphRAGBuilder::new()
.with_chunk_size(512);Sourcepub fn with_chunk_overlap(self, overlap: usize) -> Self
pub fn with_chunk_overlap(self, overlap: usize) -> Self
Set the chunk overlap for text processing
§Example
let builder = GraphRAGBuilder::new()
.with_chunk_overlap(50);Sourcepub fn with_embedding_dimension(self, dimension: usize) -> Self
pub fn with_embedding_dimension(self, dimension: usize) -> Self
Set the embedding dimension
§Example
let builder = GraphRAGBuilder::new()
.with_embedding_dimension(384);Sourcepub fn with_embedding_model(self, model: &str) -> Self
pub fn with_embedding_model(self, model: &str) -> Self
Set the embedding model name
§Example
let builder = GraphRAGBuilder::new()
.with_embedding_model("nomic-embed-text:latest");Sourcepub fn with_embedding_backend(self, backend: &str) -> Self
pub fn with_embedding_backend(self, backend: &str) -> Self
Set the embedding backend (“candle”, “fastembed”, “api”, “hash”)
§Example
let builder = GraphRAGBuilder::new()
.with_embedding_backend("candle");Sourcepub fn with_ollama_host(self, host: &str) -> Self
pub fn with_ollama_host(self, host: &str) -> Self
Sourcepub fn with_ollama_port(self, port: u16) -> Self
pub fn with_ollama_port(self, port: u16) -> Self
Sourcepub fn with_ollama_enabled(self, enabled: bool) -> Self
pub fn with_ollama_enabled(self, enabled: bool) -> Self
Sourcepub fn with_chat_model(self, model: &str) -> Self
pub fn with_chat_model(self, model: &str) -> Self
Set the Ollama chat/generation model
§Example
let builder = GraphRAGBuilder::new()
.with_chat_model("llama3.2:latest");Sourcepub fn with_ollama_embedding_model(self, model: &str) -> Self
pub fn with_ollama_embedding_model(self, model: &str) -> Self
Set the Ollama embedding model
§Example
let builder = GraphRAGBuilder::new()
.with_ollama_embedding_model("nomic-embed-text:latest");Sourcepub fn with_top_k(self, k: usize) -> Self
pub fn with_top_k(self, k: usize) -> Self
Sourcepub fn with_similarity_threshold(self, threshold: f32) -> Self
pub fn with_similarity_threshold(self, threshold: f32) -> Self
Set the similarity threshold for retrieval
§Example
let builder = GraphRAGBuilder::new()
.with_similarity_threshold(0.7);Sourcepub fn with_approach(self, approach: &str) -> Self
pub fn with_approach(self, approach: &str) -> Self
Set the pipeline approach (“semantic”, “algorithmic”, or “hybrid”)
§Example
let builder = GraphRAGBuilder::new()
.with_approach("hybrid");Sourcepub fn with_parallel_processing(self, enabled: bool) -> Self
pub fn with_parallel_processing(self, enabled: bool) -> Self
Enable or disable parallel processing
§Example
let builder = GraphRAGBuilder::new()
.with_parallel_processing(true);Sourcepub fn with_num_threads(self, num_threads: usize) -> Self
pub fn with_num_threads(self, num_threads: usize) -> Self
Set the number of parallel threads
§Example
let builder = GraphRAGBuilder::new()
.with_num_threads(4);Sourcepub fn with_auto_save(self, enabled: bool, interval_seconds: u64) -> Self
pub fn with_auto_save(self, enabled: bool, interval_seconds: u64) -> Self
Enable or disable auto-save functionality
§Example
let builder = GraphRAGBuilder::new()
.with_auto_save(true, 300); // Save every 5 minutesSourcepub fn with_auto_save_workspace(self, name: &str) -> Self
pub fn with_auto_save_workspace(self, name: &str) -> Self
Set the auto-save workspace name
§Example
let builder = GraphRAGBuilder::new()
.with_auto_save_workspace("my_project");Sourcepub fn with_local_defaults(self) -> Self
pub fn with_local_defaults(self) -> Self
Configure for local zero-config setup using Ollama
Sets up:
- Ollama enabled with localhost:11434
- Default models (nomic-embed-text for embeddings, llama3.2 for chat)
- Candle backend for local embeddings
§Example
let builder = GraphRAGBuilder::new()
.with_local_defaults();Sourcepub fn config(&self) -> &Config
pub fn config(&self) -> &Config
Get a reference to the current configuration
Useful for inspecting the configuration before building
Sourcepub fn config_mut(&mut self) -> &mut Config
pub fn config_mut(&mut self) -> &mut Config
Get a mutable reference to the current configuration
Allows direct manipulation of the config for advanced use cases
Trait Implementations§
Source§impl Clone for GraphRAGBuilder
impl Clone for GraphRAGBuilder
Source§fn clone(&self) -> GraphRAGBuilder
fn clone(&self) -> GraphRAGBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GraphRAGBuilder
impl Debug for GraphRAGBuilder
Auto Trait Implementations§
impl Freeze for GraphRAGBuilder
impl RefUnwindSafe for GraphRAGBuilder
impl Send for GraphRAGBuilder
impl Sync for GraphRAGBuilder
impl Unpin for GraphRAGBuilder
impl UnsafeUnpin for GraphRAGBuilder
impl UnwindSafe for GraphRAGBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more