a
    ag                     @  sX   d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 G dd deee
ef  ZdS )    )annotations)AnyDictList)BaseOutputParser)pre_initc                   @  sp   e Zd ZU dZded< eddddZeddd	d
dZe	ddddZ
ddddZdddddZdS )CombiningOutputParserz)Combine multiple output parsers into one.zList[BaseOutputParser]parsersbool)returnc                 C  s   dS )NT )clsr   r   p/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain/output_parsers/combining.pyis_lc_serializable   s    z(CombiningOutputParser.is_lc_serializablezDict[str, Any])valuesr   c                 C  sN   |d }t |dk rtd|D ](}|jdkr6td|jdkr tdq |S )zValidate the parsers.r	      zMust have at least two parsers	combiningzCannot nest combining parserslistzCannot combine list parsers)len
ValueError_type)r   r   r	   parserr   r   r   validate_parsers   s    


z&CombiningOutputParser.validate_parsersstrc                 C  s   dS )zReturn the type key.r   r   )selfr   r   r   r      s    zCombiningOutputParser._typec                 C  s@   d| j d   }ddd | j dd D }| d| S )z7Instructions on how the LLM output should be formatted.zFor your first output: r   
c                 s  s   | ]}d |   V  qdS )z^Complete that output fully. Then produce another output, separated by two newline characters: N)get_format_instructions).0pr   r   r   	<genexpr>(   s   z@CombiningOutputParser.get_format_instructions.<locals>.<genexpr>   N)r	   r   join)r   initialZ
subsequentr   r   r   r   $   s
    
z-CombiningOutputParser.get_format_instructions)textr   c                 C  s>   | d}t }t|| jD ]\}}|||  q|S )z Parse the output of an LLM call.z

)splitdictzipr	   updateparsestrip)r   r#   Ztextsoutputtxtr   r   r   r   r(   .   s
    
zCombiningOutputParser.parseN)__name__
__module____qualname____doc____annotations__classmethodr   r   r   propertyr   r   r(   r   r   r   r   r   	   s   

r   N)
__future__r   typingr   r   r   Zlangchain_core.output_parsersr   Zlangchain_core.utilsr   r   r   r   r   r   r   <module>   s   