Package com.tnsai.reasoning
Class ThoughtNode
java.lang.Object
com.tnsai.reasoning.ThoughtNode
- All Implemented Interfaces:
Evaluable
Represents a node in a Tree of Thoughts exploration.
Each node contains a thought (reasoning step), its evaluation score, and references to parent and child nodes.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionCreates a child node.static ThoughtNode.Builderbuilder()Creates a new builder for ThoughtNode.doubleGets the average score along the path to this node.Gets the child nodes.doubleGets the cumulative score along the path to this node.intgetDepth()Gets the depth of this node (root = 0).Gets the final answer generated for this leaf node.getId()Gets the node identifier.Gets the parent node, if any.getPath()Gets the path from root to this node.doublegetScore()Gets the evaluation score.Gets the thought content at this node.Gets the combined thought chain from root to this node.booleanReturns true if this node has a final answer.booleanReturns true if this node has been evaluated.booleanisLeaf()Returns true if this is a leaf node.booleanisPruned()Returns true if this node has been pruned.booleanisRoot()Returns true if this is the root node.voidprune()Marks this node as pruned.static ThoughtNodeCreates a root node.voidsetFinalAnswer(String finalAnswer) Sets the final answer for this leaf node.voidsetScore(double score) Sets the evaluation score.toString()
-
Method Details
-
root
Creates a root node. -
addChild
Creates a child node. -
getId
Gets the node identifier. -
getThought
Gets the thought content at this node.- Specified by:
getThoughtin interfaceEvaluable
-
getDepth
public int getDepth()Gets the depth of this node (root = 0). -
getParent
Gets the parent node, if any. -
getChildren
Gets the child nodes. -
getScore
public double getScore()Gets the evaluation score. -
setScore
public void setScore(double score) Sets the evaluation score. -
isEvaluated
public boolean isEvaluated()Returns true if this node has been evaluated. -
isLeaf
public boolean isLeaf()Returns true if this is a leaf node. -
isRoot
public boolean isRoot()Returns true if this is the root node. -
isPruned
public boolean isPruned()Returns true if this node has been pruned. -
prune
public void prune()Marks this node as pruned. -
getFinalAnswer
Gets the final answer generated for this leaf node. -
setFinalAnswer
Sets the final answer for this leaf node. -
hasFinalAnswer
public boolean hasFinalAnswer()Returns true if this node has a final answer. -
getPath
Gets the path from root to this node. -
getThoughtChain
Gets the combined thought chain from root to this node.- Specified by:
getThoughtChainin interfaceEvaluable
-
getCumulativeScore
public double getCumulativeScore()Gets the cumulative score along the path to this node. -
getAverageScore
public double getAverageScore()Gets the average score along the path to this node. -
builder
Creates a new builder for ThoughtNode. -
toString
-