a
    bgL                     @   sF   d dl mZmZ edddZeedddZeee ddd	Zd
S )    )AnyList)returnc                  C   s0   zdd l } W n ty&   tdY n0 |  S )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   u/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/utilities/anthropic.py_get_anthropic_client   s    
r	   )textr   c                 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   