a
    dŠÝg‚  ã                   @   s6   d dl mZ d dlmZ d dlmZ G dd„ dƒZdS )é    )ÚTuple)ÚToTDFSMemory)ÚThoughtValidityc                   @   s8   e Zd ZdZdedœdd„Zeeedf dœdd	„Z	d
S )ÚToTControllerzè
    Tree of Thought (ToT) controller.

    This is a version of a ToT controller, dubbed in the paper as a "Simple
    Controller".

    It has one parameter `c` which is the number of children to explore for each
    thought.
    é   ©Úcc                 C   s
   || _ dS )zz
        Initialize the controller.

        Args:
            c: The number of children to explore at each node.
        Nr   )Úselfr   © r
   ús/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_experimental/tot/controller.pyÚ__init__   s    zToTController.__init__.)ÚmemoryÚreturnc                 C   sš   |  ¡ }| ¡ }|d u rtjn|j}|tjkr\| ¡  |  ¡ }|r„t|jƒ| j	kr„| ¡  n(|tjkr„|r„t|jƒ| j	kr„| d¡ t
dd„ | ¡ D ƒƒS )Né   c                 s   s   | ]}|j V  qd S )N)Útext)Ú.0Zthoughtr
   r
   r   Ú	<genexpr>6   ó    z)ToTController.__call__.<locals>.<genexpr>)ÚtopZ
top_parentr   ZVALID_INTERMEDIATEÚvalidityÚINVALIDÚpopÚlenÚchildrenr   ÚtupleÚcurrent_path)r	   r   Znext_thoughtZparent_thoughtr   r
   r
   r   Ú__call__   s&    ÿý

ÿþý
zToTController.__call__N)r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úintr   r   r   Ústrr   r
   r
   r
   r   r      s   
	r   N)Útypingr   Z!langchain_experimental.tot.memoryr   Z"langchain_experimental.tot.thoughtr   r   r
   r
   r
   r   Ú<module>   s   