Skip to main content

GraphRAGBuilder

Struct GraphRAGBuilder 

Source
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

Source

pub fn new() -> Self

Create a new builder with default configuration

§Example
use graphrag_core::builder::GraphRAGBuilder;

let builder = GraphRAGBuilder::new();
Source

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");
Source

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);
Source

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);
Source

pub fn with_embedding_dimension(self, dimension: usize) -> Self

Set the embedding dimension

§Example
let builder = GraphRAGBuilder::new()
    .with_embedding_dimension(384);
Source

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");
Source

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");
Source

pub fn with_ollama_host(self, host: &str) -> Self

Set the Ollama host

§Example
let builder = GraphRAGBuilder::new()
    .with_ollama_host("localhost");
Source

pub fn with_ollama_port(self, port: u16) -> Self

Set the Ollama port

§Example
let builder = GraphRAGBuilder::new()
    .with_ollama_port(11434);
Source

pub fn with_ollama_enabled(self, enabled: bool) -> Self

Enable Ollama integration

§Example
let builder = GraphRAGBuilder::new()
    .with_ollama_enabled(true);
Source

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");
Source

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");
Source

pub fn with_top_k(self, k: usize) -> Self

Set the top-k results for retrieval

§Example
let builder = GraphRAGBuilder::new()
    .with_top_k(10);
Source

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);
Source

pub fn with_approach(self, approach: &str) -> Self

Set the pipeline approach (“semantic”, “algorithmic”, or “hybrid”)

§Example
let builder = GraphRAGBuilder::new()
    .with_approach("hybrid");
Source

pub fn with_parallel_processing(self, enabled: bool) -> Self

Enable or disable parallel processing

§Example
let builder = GraphRAGBuilder::new()
    .with_parallel_processing(true);
Source

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);
Source

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 minutes
Source

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");
Source

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();
Source

pub fn build(self) -> Result<GraphRAG>

Build the GraphRAG instance with the configured settings

§Errors

Returns an error if the GraphRAG initialization fails

§Example
let graphrag = GraphRAGBuilder::new()
    .with_output_dir("./workspace")
    .build()?;
Source

pub fn config(&self) -> &Config

Get a reference to the current configuration

Useful for inspecting the configuration before building

Source

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

Source§

fn clone(&self) -> GraphRAGBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GraphRAGBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GraphRAGBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,