o
    ZhL                     @   sJ   d dl mZmZ defddZdedefddZdedee fdd	Zd
S )    )AnyListreturnc                  C   s*   z	dd l } W |  S  ty   tdw )Nr   zCould not import anthropic python package. This is needed in order to accurately tokenize the text for anthropic models. Please install it with `pip install anthropic`.)	anthropicImportErrorZ	Anthropic)r    r   ^/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/utilities/anthropic.py_get_anthropic_client   s   
r	   textc                 C   s   t  }|j| dS )z-Get the number of tokens in a string of text.)r
   )r	   Zcount_tokens)r
   clientr   r   r   get_num_tokens_anthropic   s   r   c                 C   s   t  }| }|| }|jS )z'Get the token ids for a string of text.)r	   Zget_tokenizerencodeZids)r
   r   Z	tokenizerZencoded_textr   r   r   get_token_ids_anthropic   s   
r   N)typingr   r   r	   strintr   r   r   r   r   r   <module>   s    