
    5j$	                     p    d dl Z  e j                    Zi ZdefdZdedededefdZdedefd	Z	defd
Z
dS )    Nchat_idc                     t           5  dddddddddddddddddddddddddddddt          | <   d d d            d S # 1 swxY w Y   d S )Nr   )inputoutputcalls)classifyextractvalidate
exceptionsrcacapareport)_lock_session_tokensr   s    JC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\token_tracker.pyinit_sessionr      s    	 	
 	
$%Q??$%Q??$%Q??$%Q??$%Q??$%Q??$%Q??$
 $
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
s   /AAAstepinput_tokensoutput_tokensc                    t           5  | t          vrt          |            |t          |          v rt          |          |         dxx         |z  cc<   t          |          |         dxx         |z  cc<   t          |          |         dxx         dz  cc<   t          d| d| d| d||z               d d d            d S # 1 swxY w Y   d S )	Nr   r   r      z	[TOKENS] u    — input:z output:z total:)r   r   r   print)r   r   r   r   s       r   
add_tokensr      sV   	 { {/) 	"!!!?7++ 	{G$T*7333D333G$T*8444E444G$T*73339333ydyy|yy]yy[gjw[wyyzzz{ { { { { { { { { { { { { { { { { {s   B)B>>CCreturnc           
         t           5  | t          vri cd d d            S t          |          }i }dx}x}}|                                D ]S\  }}|d         |d         z   }|d         |d         ||d         d||<   ||d         z  }||d         z  }||d         z  }T||||z   |t          |dz  |dz  z   d          d	|d
<   |cd d d            S # 1 swxY w Y   d S )Nr   r   r   r   )r   r   total_tokens	llm_callsgh㈵>giUMu>   )r   r   r   r   estimated_cost_usdTOTAL)r   r   itemsround)	r   stepssummarygrand_inputgrand_outputgrand_callsr   datatotals	            r   get_summaryr+      s   	  /) 	         (3444l[++-- 
	* 
	*JD$MDN2E!%g!%h!&!%g	 GDM DM)KDN*LDM)KK ))(<7("'x)?LS[D[(\^_"`"`
 
 5                 s   CB#CCCc                 |    t           5  t                              | d            d d d            d S # 1 swxY w Y   d S )N)r   r   popr   s    r   clear_sessionr.   =   s    	 + +GT***+ + + + + + + + + + + + + + + + + +s   155)	threadingLockr   r   strr   intr   dictr+   r.        r   <module>r6      s       	

# 

 

 

 

{ {3 {c {# { { { {     <+3 + + + + + +r5   