ó
    Ð]j¤  ã                  óZ   • S SK Jr  S SKJr  SSKJrJrJr   S             SS jjrg)	é    )Úannotations)ÚAnyé   )ÚINPUT_TOKENSÚOUTPUT_TOKENSÚ	USAGE_RAWNc                óü  • 0 n[        U[        5      (       a  X&[        '   [        U[        5      (       a  X6[        '    [	        US5      (       a  UR                  SS9U[        '    SSKJ	nJ
n  U R                  5       n	SU0n
Ub  XZS'   U" U	40 U
D6nUR                  b<  [        U" UR                  UR                  R                  US9R                  5      US	'   U$ ! [         a     N„f = f! [         a     U$ f = f)
us  Build usage attributes: INPUT_TOKENS, OUTPUT_TOKENS, USAGE_RAW, operation.cost.

Callers extract input/output tokens themselves (API-surface-specific).
response is the full API response object, passed to genai_prices for cost calculation
(genai_prices extracts both model and usage from it). usage is the usage sub-object,
used for USAGE_RAW. api_flavor is needed for OpenAI ('chat', 'responses', or 'embeddings').
Returns only attributes that have values.

Token/raw-usage and cost fail independently â€” a cost error does not prevent tokens
from being set. Cost errors are silently caught (expected for unknown models etc.).
Ú
model_dumpT)Úexclude_noner   )Ú
calc_priceÚextract_usageÚprovider_idÚ
api_flavor)Ú	model_refr   zoperation.cost)Ú
isinstanceÚintr   r   Úhasattrr
   r   Ú	ExceptionÚgenai_pricesr   r   ÚmodelÚfloatÚusageÚidÚtotal_price)Úresponser   Úinput_tokensÚoutput_tokensr   r   Úresultr   r   Úresponse_dataÚextract_kwargsÚ
usage_datas               Úo/home/mande/repo/quber/.venv/lib/python3.13/site-packages/logfire/_internal/integrations/llm_providers/usage.pyÚget_usage_attributesr#      s  € ð&  €Fä�,¤×$Ñ$Ø+Œ|ÑÜ�-¤×%Ñ%Ø -Œ}ÑðÜ�5˜,×'Ñ'Ø %× 0Ñ 0¸dÐ 0Ð CˆF”9Ñðß:à ×+Ñ+Ó-ˆØ*7¸Ð)EˆØÑ!Ø+5˜<Ñ(Ù" =ÑC°NÑCˆ
Ø×ÑÑ'Ü',Ù˜:×+Ñ+°z×7GÑ7G×7JÑ7JÐXcÑd×pÑpó(ˆFÐ#Ñ$ð €Møô% ó Ùðûô ó Øà€Mðús$   ¾'C Á&A5C- Ã
C*Ã)C*Ã-
C;Ã:C;)N)r   r   r   r   r   ú
int | Noner   r$   r   Ústrr   z
str | NoneÚreturnzdict[str, Any])	Ú
__future__r   Útypingr   Úsemconvr   r   r   r#   © ó    r"   Ú<module>r,      s]   ðÝ "å ç ;Ñ ;ð "ð.Øð.àð.ð ð.ð ð	.ð
 ð.ð ð.ð ö.r+   