o
    §iÅ  ã                   @  sð   d dl mZ d dlmZ d dlmZ d dlmZm	Z	 ddl
mZmZ ddlmZ ddlmZmZmZ ed	ƒZd
Ze	dddœd+dd„ƒZe	dddœd,dd„ƒZddddœd-dd„Ze	dd œd.d&d'„ƒZe	dd œd/d(d'„ƒZdddd)œd0d*d'„ZdS )1é    )Úannotations)Údatetime)Úversion)ÚAnyÚoverloadé   )Údata_snapshotÚtypes)ÚUsage)ÚUpdatePricesÚwait_prices_updated_asyncÚwait_prices_updated_syncÚgenai_prices)r
   Ú
calc_pricer   r   r   Ú__version__N)Úprovider_idÚgenai_request_timestampÚusageútypes.AbstractUsageÚ	model_refÚstrr   útypes.ProviderID | str | Noner   údatetime | NoneÚreturnútypes.PriceCalculationc                C  ó   d S ©N© )r   r   r   r   r   r   ú[/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/genai_prices/__init__.pyr      ó   r   )Úprovider_api_urlr   r    ú
str | Nonec                C  r   r   r   )r   r   r    r   r   r   r   r      r   )r   r    r   c                C  s   t  ¡  | ||||¡S )aÔ  Calculate the price of an LLM API call.

    Either `provider_id` or `provider_api_url` should be provided, but not both. If neither are provided,
    we try to find the most suitable provider based on the model reference.

    Args:
        usage: The usage to calculate the price for.
        model_ref: A reference to the model used, this method will try to match this to a specific model.
        provider_id: The ID of the provider to calculate the price for.
        provider_api_url: The API URL of the provider to calculate the price for.
        genai_request_timestamp: The timestamp of the request to the GenAI service, use `None` to use the current time.

    Returns:
        The price calculation details.
    )r   Úget_snapshotÚcalc)r   r   r   r    r   r   r   r   r   #   s   Údefault)Ú
api_flavorÚresponse_datar   útypes.ProviderID | strr%   útypes.ExtractedUsagec                C  r   r   r   )r&   r   r%   r   r   r   Úextract_usage=   ó   r)   c                C  r   r   r   )r&   r    r%   r   r   r   r)   C   r*   )r   r    r%   c                C  s   t  ¡  | |||¡S )aS  Extract usage information from a response.

    One of `provider_id` or `provider_api_url` is required.

    Args:
        response_data: The response data to extract usage information from.
        provider: The provider to extract usage information for.
        provider_id: The ID of the provider to extract usage information for.
        provider_api_url: The API URL of the provider to extract usage information for.
        api_flavor: The API flavor of the provider to extract usage information for.

    Returns:
        The extracted usage information, model ref and provider used.
    )r   r"   r)   )r&   r   r    r%   r   r   r   r)   I   s   )
r   r   r   r   r   r   r   r   r   r   )
r   r   r   r   r    r!   r   r   r   r   )r   r   r   r   r   r   r    r!   r   r   r   r   )r&   r   r   r'   r%   r   r   r(   )r&   r   r    r   r%   r   r   r(   )
r&   r   r   r   r    r!   r%   r   r   r(   )Ú
__future__r   Ú_annotationsr   Úimportlib.metadatar   Ú_metadata_versionÚtypingr   r   Ú r   r	   r
   Úupdate_pricesr   r   r   r   Ú__all__r   r)   r   r   r   r   Ú<module>   s>    û	ûúÿÿû