o
    g
                     @   s|   d Z ddlmZ ddlmZmZ G dd deZG dd deZG dd	 d	e	eZ
G d
d deZdededefddZdS )z$Custom **exceptions** for LangChain.    )Enum)AnyOptionalc                   @      e Zd ZdZdS )LangChainExceptionzGeneral LangChain exception.N__name__
__module____qualname____doc__ r   r   U/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/langchain_core/exceptions.pyr          r   c                   @   r   )TracerExceptionz,Base class for exceptions in tracers module.Nr   r   r   r   r   r      r   r   c                	       sB   e Zd ZdZ			d
dedee dee def fdd	Z  Z	S )OutputParserExceptiona  Exception that output parsers should raise to signify a parsing error.

    This exists to differentiate parsing errors from other code or execution errors
    that also may arise inside the output parser. OutputParserExceptions will be
    available to catch and handle in ways to fix the parsing error, while other
    errors will be raised.

    Parameters:
        error: The error that's being re-raised or an error message.
        observation: String explanation of error which can be passed to a
            model to try and remediate the issue. Defaults to None.
        llm_output: String model output which is error-ing.
            Defaults to None.
        send_to_llm: Whether to send the observation and llm_output back to an Agent
            after an OutputParserException has been raised. This gives the underlying
            model driving the agent the context that the previous output was improperly
            structured, in the hopes that it will update the output to the correct
            format. Defaults to False.
    NFerrorobservation
llm_outputsend_to_llmc                    sZ   t |trt|tjd}t | |r"|d u s|d u r"d}t||| _|| _	|| _
d S )Nmessage
error_codezLArguments 'observation' & 'llm_output' are required if 'send_to_llm' is True)
isinstancestrcreate_message	ErrorCodeOUTPUT_PARSING_FAILUREsuper__init__
ValueErrorr   r   r   )selfr   r   r   r   msg	__class__r   r   r   $   s   

zOutputParserException.__init__)NNF)
r   r	   r
   r   r   r   r   boolr   __classcell__r   r   r"   r   r      s    r   c                   @   s(   e Zd ZdZdZdZdZdZdZdZ	dS )	r   INVALID_PROMPT_INPUTINVALID_TOOL_RESULTSMESSAGE_COERCION_FAILUREMODEL_AUTHENTICATIONMODEL_NOT_FOUNDMODEL_RATE_LIMITr   N)
r   r	   r
   r&   r'   r(   r)   r*   r+   r   r   r   r   r   r   ;   s    r   r   r   returnc                 C   s   |  d|j  dS )NzV
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/ )valuer   r   r   r   r   E   s   r   N)r   enumr   typingr   r   	Exceptionr   r   r   r   r   r   r   r   r   r   r   <module>   s    ,
