o
    D2h                     @  s   U d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm	Z	 d dl
Z
d dlZd dlmZ e Zi Zded< daded< ejdddZdddZdddZdddZdS )    )annotationsN)AnyCallableSequence)Encodingzdict[str, Encoding]	ENCODINGSz.dict[str, Callable[[], dict[str, Any]]] | NoneENCODING_CONSTRUCTORSreturnSequence[str]c                  C  s6   g } t tjtjd }|D ]
\}}}| | q| S )N.)pkgutiliter_modulestiktoken_ext__path____name__append)modsplugin_mods_mod_name r   e/var/www/html/alexa/alex_system/speach-to-text/venv/lib/python3.10/site-packages/tiktoken/registry.py_available_plugin_modules   s
   r   Nonec                  C  s   t f td ur	 W d    d S i azCt D ]=} t| }z|j}W n ty7 } z	td|  d|d }~ww | D ]\}}|tv rNtd| d|  |t|< q<qW n
 ty_   d a w W d    d S 1 skw   Y  d S )Nztiktoken plugin z& does not define ENCODING_CONSTRUCTORSzDuplicate encoding name z in tiktoken plugin )	_lockr   r   	importlibimport_moduleAttributeError
ValueErroritems	Exception)r   modconstructorseenc_nameconstructorr   r   r   _find_constructors!   s@   




"r&   encoding_namestrr   c              	   C  s   t | tstdt|  | tv rt|  S tJ | tv r(t|  W  d    S td u r5t  td us5J | tvrItd|  dt  dt	j
 dt|  }tdi | }|t| < |W  d    S 1 sew   Y  d S )Nz'Expected a string in get_encoding, got zUnknown encoding z.
Plugins found: z
tiktoken version: z (are you on latest?)r   )
isinstancer(   r   typer   r   r   r&   r   tiktoken__version__r   )r'   r%   encr   r   r   get_encoding?   s0   
$r.   	list[str]c                   C  sJ   t  td u rt  td usJ ttW  d    S 1 sw   Y  d S )N)r   r   r&   listr   r   r   r   list_encoding_names[   s   $r1   )r	   r
   )r	   r   )r'   r(   r	   r   )r	   r/   )
__future__r   	functoolsr   r   	threadingtypingr   r   r   r   r+   tiktoken.corer   RLockr   r   __annotations__r   	lru_cacher   r&   r.   r1   r   r   r   r   <module>   s"    

