o
    ȳgL                     @   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ImportError	Anthropic)r    r   c/var/www/html/chatdoc2/venv/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
   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
   get_tokenizerencodeids)r   r   	tokenizerencoded_textr   r   r	   get_token_ids_anthropic   s   
r   N)typingr   r   r
   strintr   r   r   r   r   r	   <module>   s    