Ë
    µŒjÇ  ã                   ó  — d dl Z d dlmZ d dlmZmZmZmZmZ d dl	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y)é    N)ÚPath)ÚAnyÚDictÚIterableÚTupleÚUnion©Úguard_importÚreturnc                  ó   — t        d«      S )zJImport the spacy python package and raise an error if it is not installed.Úspacyr	   © ó    úm/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/callbacks/utils.pyÚimport_spacyr      s   € ä˜Ó Ð r   c                  ó   — t        d«      S )zKImport the pandas python package and raise an error if it is not installed.Úpandasr	   r   r   r   Úimport_pandasr      s   € ä˜Ó!Ð!r   c                  ó   — t        d«      S )zMImport the textstat python package and raise an error if it is not installed.Útextstatr	   r   r   r   Úimport_textstatr      s   € ä˜
Ó#Ð#r   Únested_dictÚ
parent_keyÚsepc              #   ó°   K  — | j                  «       D ]=  \  }}|r||z   |z   n|}t        |t        «      rt        |||«      E d{  –—†  Œ8||f–— Œ? y7 Œ­w)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à˜5�.Ó ñ *ð :ús   ‚AAÁAÁAc                 óR   — t        | ||«      D ��ci c]  \  }}||“Œ
 }}}|S c c}}w )a€  Flatten 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.

    )r   )r   r   r   ÚkÚvÚ	flat_dicts         r   Úflatten_dictr'   .   s7   € ô #0°¸ZÈÔ"MÔNÑ"M™$˜!˜Q��A‘Ð"M€IÑNØÐùó Os   ‘#Úsc                 óf   — t        j                  | j                  d«      «      j                  «       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_stringr.   A   s%   € ô �<‰<˜Ÿ™ Ó)Ó*×4Ñ4Ó6Ð6r   Ú	json_pathc                 ój   — t        | d«      5 }|j                  «       }ddd«       |S # 1 sw Y   S xY w)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)r/   ÚfÚdatas      r   Ú	load_jsonr6   M   s0   € ô 
ˆi˜Ô	 Ø�v‰v‹xˆ÷ 
à€K÷ 
à€Kús   �(¨2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y)ÚBaseMetadataCallbackHandlera'  Handle 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 | _        y )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.)rC   rV   s    r   Úalways_verbosez*BaseMetadataCallbackHandler.always_verbose£   s   € ð ×#Ñ#Ð#r   c                 ó   — | j                   S )z Whether to ignore LLM callbacks.)r?   rV   s    r   Ú
ignore_llmz&BaseMetadataCallbackHandler.ignore_llm¨   s   € ð ×ÑÐr   c                 ó   — | j                   S )z"Whether to ignore chain callbacks.)r@   rV   s    r   Úignore_chainz(BaseMetadataCallbackHandler.ignore_chain­   ó   € ð ×!Ñ!Ð!r   c                 ó   — | j                   S )z"Whether to ignore agent callbacks.)rA   rV   s    r   Úignore_agentz(BaseMetadataCallbackHandler.ignore_agent²   r_   r   c                 ó&  — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  dœS )N©r:   r;   r<   r=   r>   rD   rE   rF   rG   rH   rI   rJ   rK   rc   rV   s    r   Úget_custom_callback_metaz4BaseMetadataCallbackHandler.get_custom_callback_meta·   sm   € à—I‘IØ—k‘kØ—I‘IØ—k‘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 | _        y)zReset the callback metadata.r   FN)r:   r;   r<   r=   r>   r?   r@   rA   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   s    r   Úreset_callback_metaz/BaseMetadataCallbackHandler.reset_callback_metaÈ   sÓ   € àˆŒ	àˆŒØˆŒ	ØˆŒØˆŒà ˆÔØ"ˆÔØ"ˆÔØ$ˆÔàˆÔØˆŒàˆŒØˆŒØˆÔàˆÔØˆŒàˆŒà$&ˆÔ!Ø$&ˆÔ!Ø"$ˆÔà&(ˆÔ#Ø$&ˆÔ!à%'ˆÔ"Ø#%ˆÔ à!ˆÔØ')ˆÔ$Ø')ˆÔ$Ør   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rX   ÚpropertyÚboolrZ   r\   r^   ra   r   Ústrr   rd   rf   r   r   r   r8   r8   [   s’   „ ñó>&0ðP ð$ ò $ó ð$ð ð ˜Dò  ó ð ð ð"˜dò "ó ð"ð ð"˜dò "ó ð"ð
¨$¨s°C¨x©.ó 
ô"'r   r8   )Ú Ú_)r*   Úpathlibr   Útypingr   r   r   r   r   Úlangchain_core.utilsr
   r   r   r   rm   r   r'   r.   r6   r8   r   r   r   Ú<module>rs      sð   ðÛ Ý ß 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ð˜˜s D˜yÑ)ð ¨có ÷Tò Tr   