§
    æ˜ºh9!  ã                   ó(  — d dl Z d dlmZ d dlmZmZmZmZmZ defd„Z	defd„Z
defd„Z	 dd
eeef         dededeeeef                  fd„Z	 dd
eeef         dededeeef         fd„Zdedefd„Zdeeef         defd„Z G d„ d¦  «        ZdS )é    N)ÚPath)ÚAnyÚDictÚIterableÚTupleÚUnionÚreturnc                  óL   — 	 ddl } n# t          $ r t          d¦  «        ‚w xY w| S )zJImport the spacy python package and raise an error if it is not installed.r   NzoThis callback manager requires the `spacy` python package installed. Please install it with `pip install spacy`)ÚspacyÚImportError)r   s    úk/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/langchain_community/callbacks/utils.pyÚimport_spacyr      sL   € ð
ØˆˆˆˆøÝð 
ð 
ð 
ÝðLñ
ô 
ð 	
ð
øøøð
 €Ló   ‚ ‡!c                  óL   — 	 ddl } n# t          $ r t          d¦  «        ‚w xY w| S )zKImport the pandas python package and raise an error if it is not installed.r   NzqThis callback manager requires the `pandas` python package installed. Please install it with `pip install pandas`)Úpandasr   )r   s    r   Úimport_pandasr      sL   € ð
ØˆˆˆˆøÝð 
ð 
ð 
ÝðMñ
ô 
ð 	
ð
øøøð
 €Mr   c                  óL   — 	 ddl } n# t          $ r t          d¦  «        ‚w xY w| S )zMImport the textstat python package and raise an error if it is not installed.r   NzuThis callback manager requires the `textstat` python package installed. Please install it with `pip install textstat`)Útextstatr   )r   s    r   Úimport_textstatr      sL   € ð
ØˆˆˆˆøÝð 
ð 
ð 
ÝðOñ
ô 
ð 	
ð
øøøð
 €Or   Ú Ú_Únested_dictÚ
parent_keyÚsepc              #   ó¼   K  — |                       ¦   «         D ]D\  }}|r||z   |z   n|}t          |t          ¦  «        rt          |||¦  «        E d{V —† Œ>||fV — ŒEdS )aÀ  
    Generator that yields flattened items from a nested dictionary for a flat dict.

    Parameters:
        nested_dict (dict): The nested dictionary to flatten.
        parent_key (str): The prefix to prepend to the keys of the flattened dict.
        sep (str): The separator to use between the parent key and the key of the
            flattened dictionary.

    Yields:
        (str, any): A key-value pair from the flattened dictionary.
    N)ÚitemsÚ
isinstanceÚdictÚ_flatten_dict)r   r   r   ÚkeyÚvalueÚnew_keys         r   r   r   *   s–   è è € ð "×'Ò'Ñ)Ô)ð !ð !‰
ˆˆUØ,6Ð?�*˜sÑ" SÑ(Ð(¸CˆÝ�e�TÑ"Ô"ð 	!Ý$ U¨G°SÑ9Ô9Ð9Ð9Ð9Ð9Ð9Ð9Ð9Ð9à˜5�.Ð Ð Ð Ð ð!ð !ó    c                 ó<   — d„ t          | ||¦  «        D ¦   «         }|S )a�  Flattens a nested dictionary into a flat dictionary.

    Parameters:
        nested_dict (dict): The nested dictionary to flatten.
        parent_key (str): The prefix to prepend to the keys of the flattened dict.
        sep (str): The separator to use between the parent key and the key of the
            flattened dictionary.

    Returns:
        (dict): A flat dictionary.

    c                 ó   — i | ]\  }}||“Œ	S © r&   )Ú.0ÚkÚvs      r   ú
<dictcomp>z flatten_dict.<locals>.<dictcomp>P   s   € ÐNÐNÐN™$˜!˜Q��AÐNÐNÐNr#   )r   )r   r   r   Ú	flat_dicts       r   Úflatten_dictr,   A   s*   € ð OÐN¥-°¸ZÈÑ"MÔ"MÐNÑNÔN€IØÐr#   Úsc                 ót   — t          j        |                      d¦  «        ¦  «                             ¦   «         S )z„Hash a string using sha1.

    Parameters:
        s (str): The string to hash.

    Returns:
        (str): The hashed string.
    zutf-8)ÚhashlibÚsha1ÚencodeÚ	hexdigest)r-   s    r   Úhash_stringr3   T   s,   € õ Œ<˜Ÿš Ñ)Ô)Ñ*Ô*×4Ò4Ñ6Ô6Ð6r#   Ú	json_pathc                 ó~   — t          | d¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   |S )z®Load json file to a string.

    Parameters:
        json_path (str): The path to the json file.

    Returns:
        (str): The string representation of the json file.
    ÚrN)ÚopenÚread)r4   ÚfÚdatas      r   Ú	load_jsonr;   `   sx   € õ 
ˆi˜Ñ	Ô	ð  Ø�vŠv‰xŒxˆðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð à€Ks   ‘2²6¹6c                   ó®   — e Zd ZdZdd„Zedefd„¦   «         Zedefd„¦   «         Zedefd„¦   «         Z	edefd„¦   «         Z
deeef         fd	„Zdd
„ZdS )ÚBaseMetadataCallbackHandlera3  This class handles the metadata and associated function states for callbacks.

    Attributes:
        step (int): The current step.
        starts (int): The number of times the start method has been called.
        ends (int): The number of times the end method has been called.
        errors (int): The number of times the error method has been called.
        text_ctr (int): The number of times the text method has been called.
        ignore_llm_ (bool): Whether to ignore llm callbacks.
        ignore_chain_ (bool): Whether to ignore chain callbacks.
        ignore_agent_ (bool): Whether to ignore agent callbacks.
        ignore_retriever_ (bool): Whether to ignore retriever callbacks.
        always_verbose_ (bool): Whether to always be verbose.
        chain_starts (int): The number of times the chain start method has been called.
        chain_ends (int): The number of times the chain end method has been called.
        llm_starts (int): The number of times the llm start method has been called.
        llm_ends (int): The number of times the llm end method has been called.
        llm_streams (int): The number of times the text method has been called.
        tool_starts (int): The number of times the tool start method has been called.
        tool_ends (int): The number of times the tool end method has been called.
        agent_ends (int): The number of times the agent end method has been called.
        on_llm_start_records (list): A list of records of the on_llm_start method.
        on_llm_token_records (list): A list of records of the on_llm_token method.
        on_llm_end_records (list): A list of records of the on_llm_end method.
        on_chain_start_records (list): A list of records of the on_chain_start method.
        on_chain_end_records (list): A list of records of the on_chain_end method.
        on_tool_start_records (list): A list of records of the on_tool_start method.
        on_tool_end_records (list): A list of records of the on_tool_end method.
        on_agent_finish_records (list): A list of records of the on_agent_end method.
    r	   Nc                 óŽ  — d| _         d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        d| _        d| _        d| _        d| _        d| _        d| _        d| _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        d S )Nr   F)ÚstepÚstartsÚendsÚerrorsÚtext_ctrÚignore_llm_Úignore_chain_Úignore_agent_Úignore_retriever_Úalways_verbose_Úchain_startsÚ
chain_endsÚ
llm_startsÚllm_endsÚllm_streamsÚtool_startsÚ	tool_endsÚ
agent_endsÚon_llm_start_recordsÚon_llm_token_recordsÚon_llm_end_recordsÚon_chain_start_recordsÚon_chain_end_recordsÚon_tool_start_recordsÚon_tool_end_recordsÚon_text_recordsÚon_agent_finish_recordsÚon_agent_action_records©Úselfs    r   Ú__init__z$BaseMetadataCallbackHandler.__init__Ž   sÞ   € ØˆŒ	àˆŒØˆŒ	ØˆŒØˆŒà ˆÔØ"ˆÔØ"ˆÔØ!&ˆÔØ$ˆÔàˆÔØˆŒàˆŒØˆŒØˆÔàˆÔØˆŒàˆŒà*,ˆÔ!Ø*,ˆÔ!Ø(*ˆÔà,.ˆÔ#Ø*,ˆÔ!à+-ˆÔ"Ø)+ˆÔ à%'ˆÔØ-/ˆÔ$Ø-/ˆÔ$Ð$Ð$r#   c                 ó   — | j         S )z;Whether to call verbose callbacks even if verbose is False.)rH   r[   s    r   Úalways_verbosez*BaseMetadataCallbackHandler.always_verbose¶   s   € ð Ô#Ð#r#   c                 ó   — | j         S )z Whether to ignore LLM callbacks.)rD   r[   s    r   Ú
ignore_llmz&BaseMetadataCallbackHandler.ignore_llm»   s   € ð ÔÐr#   c                 ó   — | j         S )z"Whether to ignore chain callbacks.)rE   r[   s    r   Úignore_chainz(BaseMetadataCallbackHandler.ignore_chainÀ   ó   € ð Ô!Ð!r#   c                 ó   — | j         S )z"Whether to ignore agent callbacks.)rF   r[   s    r   Úignore_agentz(BaseMetadataCallbackHandler.ignore_agentÅ   rd   r#   c                 ó¤   — | j         | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        | j        dœS )N©r?   r@   rA   rB   rC   rI   rJ   rK   rL   rM   rN   rO   rP   rh   r[   s    r   Úget_custom_callback_metaz4BaseMetadataCallbackHandler.get_custom_callback_metaÊ   sU   € à”IØ”kØ”IØ”kØœØ Ô-Øœ/Øœ/ØœØÔ+ØÔ+ØœØœ/ð
ð 
ð 	
r#   c                 ó€  — d| _         d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        d| _        d| _        d| _        d| _        d| _        d| _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        g | _        dS )zReset the callback metadata.r   FN)r?   r@   rA   rB   rC   rD   rE   rF   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   s    r   Úreset_callback_metaz/BaseMetadataCallbackHandler.reset_callback_metaÛ   sÕ   € àˆŒ	àˆŒØˆŒ	ØˆŒØˆŒà ˆÔØ"ˆÔØ"ˆÔØ$ˆÔàˆÔØˆŒàˆŒØˆŒØˆÔàˆÔØˆŒàˆŒà$&ˆÔ!Ø$&ˆÔ!Ø"$ˆÔà&(ˆÔ#Ø$&ˆÔ!à%'ˆÔ"Ø#%ˆÔ à!ˆÔØ')ˆÔ$Ø')ˆÔ$Øˆtr#   )r	   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r]   ÚpropertyÚboolr_   ra   rc   rf   r   Ústrr   ri   rk   r&   r#   r   r=   r=   n   s  € € € € € ðð ð>&0ð &0ð &0ð &0ðP ð$ ð $ð $ð $ñ „Xð$ð ð ˜Dð  ð  ð  ñ „Xð ð ð"˜dð "ð "ð "ñ „Xð"ð ð"˜dð "ð "ð "ñ „Xð"ð
¨$¨s°C¨x¬.ð 
ð 
ð 
ð 
ð"'ð 'ð 'ð 'ð 'ð 'r#   r=   )r   r   )r/   Úpathlibr   Útypingr   r   r   r   r   r   r   r   rr   r   r,   r3   r;   r=   r&   r#   r   ú<module>ru      sÉ  ðØ €€€Ø Ð Ð Ð Ð Ð Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4ð	�cð 	ð 	ð 	ð 	ð	�sð 	ð 	ð 	ð 	ð	˜ð 	ð 	ð 	ð 	ð CFð!ð !Ø�c˜3�h”ð!Ø-0ð!Ø<?ð!àˆe�C˜�HŒoÔð!ð !ð !ð !ð0 CFðð Ø�c˜3�h”ðØ-0ðØ<?ðà	ˆ#ˆsˆ(„^ðð ð ð ð&	7�3ð 	7˜3ð 	7ð 	7ð 	7ð 	7ð˜˜s D˜yÔ)ð ¨cð ð ð ð ðTð Tð Tð Tð Tñ Tô Tð Tð Tð Tr#   