langchain_experimental.tot.memory.ToTDFSMemory¶

class langchain_experimental.tot.memory.ToTDFSMemory(stack: Optional[List[Thought]] = None)[source]¶

Memory for the Tree of Thought (ToT) chain.

It is implemented as a stack of thoughts. This allows for a depth first search (DFS) of the ToT.

Attributes

level

Return the current level of the stack.

Methods

__init__([stack])

current_path()

Return the thoughts path.

pop([n])

Pop the top n elements of the stack and return the last one.

store(node)

Add a node on the top of the stack.

top()

Get the top of the stack without popping it.

top_parent()

Get the parent of the top of the stack without popping it.

Parameters

stack (Optional[List[Thought]]) –

__init__(stack: Optional[List[Thought]] = None)[source]¶
Parameters

stack (Optional[List[Thought]]) –

current_path() List[Thought][source]¶

Return the thoughts path.

Return type

List[Thought]

pop(n: int = 1) Optional[Thought][source]¶

Pop the top n elements of the stack and return the last one.

Parameters

n (int) –

Return type

Optional[Thought]

store(node: Thought) None[source]¶

Add a node on the top of the stack.

Parameters

node (Thought) –

Return type

None

top() Optional[Thought][source]¶

Get the top of the stack without popping it.

Return type

Optional[Thought]

top_parent() Optional[Thought][source]¶

Get the parent of the top of the stack without popping it.

Return type

Optional[Thought]