pub struct DocumentTree { /* private fields */ }Expand description
Hierarchical document tree for multi-level summarization
Implementations§
Source§impl DocumentTree
impl DocumentTree
Sourcepub fn new(document_id: DocumentId, config: HierarchicalConfig) -> Result<Self>
pub fn new(document_id: DocumentId, config: HierarchicalConfig) -> Result<Self>
Create a new document tree
Sourcepub fn with_llm_client(
document_id: DocumentId,
config: HierarchicalConfig,
llm_client: Arc<dyn LLMClient>,
) -> Result<Self>
pub fn with_llm_client( document_id: DocumentId, config: HierarchicalConfig, llm_client: Arc<dyn LLMClient>, ) -> Result<Self>
Create a new document tree with LLM client
Sourcepub fn set_llm_client(&mut self, llm_client: Option<Arc<dyn LLMClient>>)
pub fn set_llm_client(&mut self, llm_client: Option<Arc<dyn LLMClient>>)
Set LLM client for the tree
Sourcepub fn with_parallel_processing(
document_id: DocumentId,
config: HierarchicalConfig,
_parallel_processor: ParallelProcessor,
) -> Result<Self>
pub fn with_parallel_processing( document_id: DocumentId, config: HierarchicalConfig, _parallel_processor: ParallelProcessor, ) -> Result<Self>
Create a new document tree with parallel processing support
Sourcepub fn with_parallel_and_llm(
document_id: DocumentId,
config: HierarchicalConfig,
_parallel_processor: ParallelProcessor,
llm_client: Arc<dyn LLMClient>,
) -> Result<Self>
pub fn with_parallel_and_llm( document_id: DocumentId, config: HierarchicalConfig, _parallel_processor: ParallelProcessor, llm_client: Arc<dyn LLMClient>, ) -> Result<Self>
Create a new document tree with both parallel processing and LLM client
Sourcepub async fn build_from_chunks(&mut self, chunks: Vec<TextChunk>) -> Result<()>
pub async fn build_from_chunks(&mut self, chunks: Vec<TextChunk>) -> Result<()>
Build the hierarchical tree from text chunks
Sourcepub async fn generate_llm_summary(
&self,
text: &str,
level: usize,
context: &str,
) -> Result<String>
pub async fn generate_llm_summary( &self, text: &str, level: usize, context: &str, ) -> Result<String>
Generate summary suitable for parallel processing Generate summary using LLM for the given text and level
Sourcepub async fn generate_llm_summaries_batch(
&self,
texts: &[(&str, usize, &str)],
) -> Result<Vec<String>>
pub async fn generate_llm_summaries_batch( &self, texts: &[(&str, usize, &str)], ) -> Result<Vec<String>>
Generate summaries in batch for multiple texts
Sourcepub fn query(&self, query: &str, max_results: usize) -> Result<Vec<QueryResult>>
pub fn query(&self, query: &str, max_results: usize) -> Result<Vec<QueryResult>>
Query the tree for relevant nodes at different levels
Sourcepub fn get_ancestors(&self, node_id: &NodeId) -> Vec<&TreeNode>
pub fn get_ancestors(&self, node_id: &NodeId) -> Vec<&TreeNode>
Get ancestors of a node (path to root)
Sourcepub fn get_descendants(&self, node_id: &NodeId) -> Vec<&TreeNode>
pub fn get_descendants(&self, node_id: &NodeId) -> Vec<&TreeNode>
Get descendants of a node (all children recursively)
Sourcepub fn get_level_nodes(&self, level: usize) -> Vec<&TreeNode>
pub fn get_level_nodes(&self, level: usize) -> Vec<&TreeNode>
Get all nodes at a specific level
Sourcepub fn get_root_nodes(&self) -> Vec<&TreeNode>
pub fn get_root_nodes(&self) -> Vec<&TreeNode>
Get the root nodes of the tree
Sourcepub fn document_id(&self) -> &DocumentId
pub fn document_id(&self) -> &DocumentId
Get the document ID
Sourcepub fn get_statistics(&self) -> TreeStatistics
pub fn get_statistics(&self) -> TreeStatistics
Get tree statistics
Auto Trait Implementations§
impl Freeze for DocumentTree
impl !RefUnwindSafe for DocumentTree
impl Send for DocumentTree
impl Sync for DocumentTree
impl Unpin for DocumentTree
impl UnsafeUnpin for DocumentTree
impl !UnwindSafe for DocumentTree
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
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>
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 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>
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