Ë
    ¼vëjM  ã                  óp   — d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	m
Z
 d
d„Zd
d„Zddedf	 	 	 	 	 	 	 dd	„Zy)zYAround one model call: ask, run, report. The call's own usage report is what gets priced.é    )ÚannotationsN)ÚCallableÚOptionalÚTupleé   )ÚCreditsÚRefusedc           	     óÚ   — t        | dd«      }|€yt        |dd«      }t        |dd«      xs d}t        t        |dd«      xs d«      t        |«      t        t        |dd«      xs d«      fS )	zC(input, cached input, output) from an OpenAI-style chat completion.ÚusageN)r   r   r   Úprompt_tokens_detailsÚcached_tokensr   Úprompt_tokensÚcompletion_tokens)ÚgetattrÚint)Úrespr   ÚdetailsÚcacheds       úa/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/galaxiq_utils/ai_credits/metered.pyÚusage_of_completionr   
   su   € ä�D˜' 4Ó(€EØ€}ØÜ�eÐ4°dÓ;€GÜ�W˜o¨qÓ1Ò6°Q€FÜŒw�u˜o¨qÓ1Ò6°QÓ7¼¸V»ÄcÌ'ÐRWÐYlÐnoÓJpÒJuÐtuÓFvÐvÐvó    c           	     ó<   — ddt        t        | dd«      xs g «      fS )z3(0, 0, images) from an OpenAI-style image response.r   ÚdataN)Úlenr   )r   s    r   Úusage_of_imagesr      s"   € àˆa””W˜T 6¨4Ó0Ò6°BÓ7Ð7Ð7r   c
                óL  — | j                  ||||||«      }
|
st        |
«      ‚	  |«       } ||«      \  }}}| j                  |
j                  |	xs t        t        j                  «       «      |||||||«	       |S # t        $ r | j                  ||
j                  «       ‚ w xY w)z°Runs `call()` if the pool allows and records what it used. Raises Refused when the pool cannot cover it;
    any other billing trouble lets the call go ahead and settles later.)	Ú	may_spendr	   Ú	ExceptionÚreleaseÚreservation_idÚrecordÚstrÚuuidÚuuid4)ÚcreditsÚ	tenant_idÚfeatureÚtypeÚ	model_keyÚcallÚinput_estimateÚoutput_estimateÚusage_ofÚcall_idÚdecisionr   Úinput_unitsr   Úoutput_unitss                  r   Úmeteredr2      s°   € ð × Ñ  ¨G°T¸9ÀnÐVeÓf€HÙÜ�hÓÐðÙ‹vˆñ )1°«Ñ%€K�˜Ø‡N�N�8×*Ñ*¨GÒ,H´s¼4¿:¹:»<Ó7HÈ)ÐU\Ð^bÐdmØ ¨ô6à€Køô ò Ø�‰˜	 8×#:Ñ#:Ô;Øðús   ¥A< Á<'B#)ÚreturnzTuple[int, int, int])r%   r   r&   r"   r'   r"   r(   r"   r)   r"   r*   zCallable[[], object]r+   r   r,   r   r-   z(Callable[[object], Tuple[int, int, int]]r.   zOptional[str])Ú__doc__Ú
__future__r   r#   Útypingr   r   r   Úclientr   r	   r   r   r2   © r   r   ú<module>r9      sV   ðÙ _Ý "ã ß ,Ñ ,ç $ówó8ð #$¸AØATØ%)ðØðØ69ðà>ðð #ôr   