o
    {qiZ                     @  sT   d dl mZ d dlmZ d dlmZ d dlmZ dZG dd dee	e
ef  ZdS )	    )annotations)Any)BaseOutputParser)pre_init   c                   @  sX   e Zd ZU dZded< edddZedd
dZe	dddZ
dddZdddZdS )CombiningOutputParserz)Combine multiple output parsers into one.zlist[BaseOutputParser]parsersreturnboolc                 C     dS )NT )clsr   r   i/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/langchain/output_parsers/combining.pyis_lc_serializable   s   z(CombiningOutputParser.is_lc_serializablevaluesdict[str, Any]c                 C  sZ   |d }t |tk rd}t||D ]}|jdkrd}t||jdkr*d}t|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_MIN_PARSERS
ValueError_type)r   r   r   msgparserr   r   r   validate_parsers   s   

z&CombiningOutputParser.validate_parsersstrc                 C  r   )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textc                 C  s<   | d}i }t|| jD ]\}}|||  q|S )z Parse the output of an LLM call.z

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