HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/langchain/chains/router/__pycache__/base.cpython-310.pyc
o

���g��@s�dZddlmZddlmZddlmZmZmZm	Z	m
Z
mZddlm
Z
mZmZddlmZddlmZGdd	�d	e
�ZGd
d�dee�ZGdd
�d
e�ZdS)zBase classes for chain routing.�)�annotations)�ABC)�Any�Dict�List�Mapping�
NamedTuple�Optional)�AsyncCallbackManagerForChainRun�CallbackManagerForChainRun�	Callbacks)�
ConfigDict)�Chainc@seZdZUded<ded<dS)�Routez
Optional[str]�destination�Dict[str, Any]�next_inputsN)�__name__�
__module__�__qualname__�__annotations__�rr�G/usr/local/lib/python3.10/dist-packages/langchain/chains/router/base.pyrs
rc@s8eZdZdZeddd��Zdddd
�Z	dddd�ZdS)�RouterChainzHChain that outputs the name of a destination chain and the inputs to it.�return�	List[str]cCsddgS)Nrrr��selfrrr�output_keysszRouterChain.output_keysN�inputsr�	callbacksrrcCs|||d�}t|d|d�S)z�
        Route inputs to a destination chain.

        Args:
            inputs: inputs to the chain
            callbacks: callbacks to use for the chain

        Returns:
            a Route object
        �r rr)r�rrr �resultrrr�routeszRouterChain.routec�s(�|j||d�IdH}t|d|d�S)Nr!rr)�acallrr"rrr�aroute,s�zRouterChain.aroute�rr�N)rrr rrr)rrr�__doc__�propertyrr$r&rrrrrs�rc@s�eZdZUdZded<	ded<	ded<	dZd	ed
<	eddd
�Zeddd��Z	eddd��Z
	dd dd�Z	dd!dd�ZdS)"�MultiRouteChainzIUse a single chain to route an input to one of multiple candidate chains.r�router_chainzMapping[str, Chain]�destination_chainsr�
default_chainF�bool�
silent_errorsT�forbid)�arbitrary_types_allowed�extrarrcCs|jjS)zWWill be whatever keys the router chain prompt expects.

        :meta private:
        )r,�
input_keysrrrrr4EszMultiRouteChain.input_keyscCsgS)z=Will always return text key.

        :meta private:
        rrrrrrMszMultiRouteChain.output_keysNrr�run_manager�$Optional[CallbackManagerForChainRun]cCs�|pt��}|��}|jj||d�}|jt|j�dt|j�|j	d�|js/|j
|j|d�S|j|jvr@|j|j|j|d�S|jrK|j
|j|d�St
d|j�d����Nr!z: )�verbosez)Received invalid destination chain name '�')r�get_noop_manager�	get_childr,r$�on_text�strrrr8r.r-r0�
ValueError�rrr5�_run_managerr r$rrr�_callUs"�
��zMultiRouteChain._call�)Optional[AsyncCallbackManagerForChainRun]c�s��|pt��}|��}|jj||d�IdH}|jt|j�dt|j�|j	d�IdH|js:|j
j|j|d�IdHS|j|jvrO|j|jj|j|d�IdHS|j
r^|j
j|j|d�IdHStd|j�d���r7)r
r:r;r,r&r<r=rrr8r.r%r-r0r>r?rrr�_acallns,������zMultiRouteChain._acallr'r()rrr5r6rr)rrr5rBrr)
rrrr)rr0r
�model_configr*r4rrArCrrrrr+3s,
�
��r+N)r)�
__future__r�abcr�typingrrrrrr	�langchain_core.callbacksr
rr�pydanticr
�langchain.chains.baserrrr+rrrr�<module>s