pub struct TreeOfThoughts {
pub config: ToTConfig,
/* private fields */
}Expand description
The Tree-of-Thoughts engine
Fields§
§config: ToTConfigImplementations§
Source§impl TreeOfThoughts
impl TreeOfThoughts
pub fn new(config: ToTConfig) -> Self
Sourcepub fn create_root(&mut self, problem: &str) -> usize
pub fn create_root(&mut self, problem: &str) -> usize
Create a new root node
Sourcepub fn add_child(
&mut self,
parent_id: usize,
thought: String,
score: f32,
state: ThoughtState,
) -> usize
pub fn add_child( &mut self, parent_id: usize, thought: String, score: f32, state: ThoughtState, ) -> usize
Add a child thought to a node
Sourcepub fn get_node(&self, id: usize) -> Option<&ThoughtNode>
pub fn get_node(&self, id: usize) -> Option<&ThoughtNode>
Get a node by ID
Sourcepub fn get_node_mut(&mut self, id: usize) -> Option<&mut ThoughtNode>
pub fn get_node_mut(&mut self, id: usize) -> Option<&mut ThoughtNode>
Get mutable node by ID
Sourcepub fn get_path(&self, node_id: usize) -> Vec<&ThoughtNode>
pub fn get_path(&self, node_id: usize) -> Vec<&ThoughtNode>
Get path from root to node
Sourcepub fn get_frontier(&self) -> Vec<usize>
pub fn get_frontier(&self) -> Vec<usize>
Get frontier nodes (expandable leaves)
Sourcepub fn best_first_step(&self) -> Vec<usize>
pub fn best_first_step(&self) -> Vec<usize>
Best-first step
Sourcepub fn get_expansion_candidates(&self) -> Vec<usize>
pub fn get_expansion_candidates(&self) -> Vec<usize>
Get nodes to expand based on search strategy
Sourcepub fn find_best_solution(&self) -> Option<&ThoughtNode>
pub fn find_best_solution(&self) -> Option<&ThoughtNode>
Find the best terminal node (solution)
Sourcepub fn build_result(&self) -> ToTResult
pub fn build_result(&self) -> ToTResult
Build result from current tree state
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TreeOfThoughts
impl RefUnwindSafe for TreeOfThoughts
impl Send for TreeOfThoughts
impl Sync for TreeOfThoughts
impl Unpin for TreeOfThoughts
impl UnwindSafe for TreeOfThoughts
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