pub struct GraphRAG<M: BaseChatModel> { /* private fields */ }Expand description
GraphRAG: Knowledge Graph-based Retrieval Augmented Generation.
Wraps an LLM for entity/relation extraction and community summarization,
and an in-memory GraphStore for graph operations.
Implementations§
Source§impl<M: BaseChatModel> GraphRAG<M>
impl<M: BaseChatModel> GraphRAG<M>
Sourcepub fn with_config(self, config: GraphRAGConfig) -> Self
pub fn with_config(self, config: GraphRAGConfig) -> Self
Sets a custom configuration.
Sourcepub async fn add_documents(
&self,
docs: &[Document],
) -> Result<(), GraphRAGError>
pub async fn add_documents( &self, docs: &[Document], ) -> Result<(), GraphRAGError>
Adds documents to the knowledge graph by extracting entities and relations from each document via the LLM.
Sourcepub async fn build_communities(&self) -> Result<(), GraphRAGError>
pub async fn build_communities(&self) -> Result<(), GraphRAGError>
Runs community detection and generates community summaries via the LLM.
Sourcepub async fn query(
&self,
q: &str,
mode: QueryMode,
) -> Result<GraphRAGResult, GraphRAGError>
pub async fn query( &self, q: &str, mode: QueryMode, ) -> Result<GraphRAGResult, GraphRAGError>
Queries the knowledge graph using the specified mode.
Sourcepub async fn entity_count(&self) -> usize
pub async fn entity_count(&self) -> usize
Returns the number of entities in the graph.
Sourcepub async fn relation_count(&self) -> usize
pub async fn relation_count(&self) -> usize
Returns the number of relations in the graph.
Sourcepub async fn community_count(&self) -> usize
pub async fn community_count(&self) -> usize
Returns the number of communities.
Auto Trait Implementations§
impl<M> !Freeze for GraphRAG<M>
impl<M> !RefUnwindSafe for GraphRAG<M>
impl<M> !UnwindSafe for GraphRAG<M>
impl<M> Send for GraphRAG<M>
impl<M> Sync for GraphRAG<M>
impl<M> Unpin for GraphRAG<M>where
M: Unpin,
impl<M> UnsafeUnpin for GraphRAG<M>where
M: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more