a
    •˜ëj�  ã                   @   s\   d dl mZmZ d dlmZ eedœdd„Zddœeeeef  eed  edœd	d
„Z	dS )é    )ÚLiteralÚOptional)ÚAgentAction)ÚxmlÚreturnc                 C   s4   dddddddœ}|  ¡ D ]\}}|  ||¡} q| S )z-Replace XML tags with custom safe delimiters.z[[tool]]z	[[/tool]]z[[tool_input]]z[[/tool_input]]z[[observation]]z[[/observation]])ú<tool>z</tool>z<tool_input>z</tool_input>z<observation>ú</observation>)ÚitemsÚreplace)r   ÚreplacementsÚorigÚrepl© r   úe/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/langchain/agents/format_scratchpad/xml.pyÚ_escape   s    úr   Úminimal)Úescape_format)Úintermediate_stepsr   r   c             	   C   sx   d}| D ]j\}}|dkr>t |jƒ}t t|jƒƒ}t t|ƒƒ}n|j}t|jƒ}t|ƒ}|d|› d|› d|› d�7 }q|S )aU  Format the intermediate steps as XML.

    Args:
        intermediate_steps: The intermediate steps.
        escape_format: The escaping format to use. Currently only 'minimal' is
            supported, which replaces XML tags with custom delimiters to prevent
            conflicts.

    Returns:
        The intermediate steps as XML.
    Ú r   r   z</tool><tool_input>z</tool_input><observation>r   )r   ÚtoolÚstrÚ
tool_input)r   r   ÚlogÚactionZobservationr   r   Zobservation_r   r   r   Ú
format_xml   s    

ÿÿr   N)
Útypingr   r   Zlangchain_core.agentsr   r   r   ÚlistÚtupler   r   r   r   r   Ú<module>   s   ý
ü