o
    sâg  ã                   @   sB   d dl Z d dlZd dlmZ e d¡Ze d¡Zejfdd„ZdS )é    NÚcl100k_basezgpt-3.5-turboc                 C   s‚   t t | ¡ƒ}t || ¡}t|dƒ}g }tt | ƒ| ƒ}|dkr(| | ¡ |S td|ƒD ]}| | || |d | … ¡ q-|S )z<
    Checks the token limit compared to the config file
    é   r   )	ÚlenÚencodingÚencodeÚmathÚceilÚmaxÚintÚappendÚrange)Ú	page_textÚtoken_limitÚtoken_countÚtoken_counterÚnew_page_textÚpage_text_splitÚi© r   ú3/var/www/html/XCapMarket/utils/check_token_limit.pyÚcheck_token_limit   s   

÷ÿr   )	r   ÚtiktokenÚconfigs.configÚconfigÚget_encodingr   Úencoding_for_modelÚOPENAI_TOKEN_LIMITr   r   r   r   r   Ú<module>   s    

