o
    ưir	                     @   sJ   d Z ddlmZ ddlmZ ddlmZ dededeeef fdd	Z	d
S )zb
Helper util for handling databricks-specific cost calculation
- e.g.: handling 'dbrx-instruct-*'
    )Tuple)Usage)get_model_infomodelusagereturnc                 C   s  | }|  ds|  drd}nZ|  ds|  drd}nM|  ds&|  dr)d	}n@|  d
s3|  dr6d}n3|  d
s@|  drCd}n&|  dsM|  drPd}n|  dsZ|  dr]d}n|  dsg|  drid}t|dd}|d |d  }|d |d  }||fS )aO  
    Calculates the cost per token for a given model, prompt tokens, and completion tokens.

    Input:
        - model: str, the model name without provider prefix
        - usage: LiteLLM Usage block, containing anthropic caching information

    Returns:
        Tuple[float, float] - prompt_cost_in_usd, completion_cost_in_usd
    zdatabricks/dbrx-instructzdbrx-instructzdatabricks-dbrx-instructz&databricks/meta-llama-3.1-70b-instructzmeta-llama-3.1-70b-instructz&databricks-meta-llama-3-1-70b-instructz'databricks/meta-llama-3.1-405b-instructzmeta-llama-3.1-405b-instructz'databricks-meta-llama-3-1-405b-instructz%databricks/mixtral-8x7b-instruct-v0.1zmixtral-8x7b-instruct-v0.1z databricks-mixtral-8x7b-instructzdatabricks/bge-large-enzbge-large-enzdatabricks-bge-large-enzdatabricks/gte-large-enzgte-large-enzdatabricks-gte-large-enzdatabricks/llama-2-70b-chatzllama-2-70b-chatzdatabricks-llama-2-70b-chatZ
databricks)r   Zcustom_llm_providerZprompt_tokensZinput_cost_per_tokenZcompletion_tokensZoutput_cost_per_token)
startswithr   )r   r   Z
base_modelZ
model_infoZprompt_costZcompletion_cost r	   ^/home/app/Keep/.python/lib/python3.10/site-packages/litellm/llms/databricks/cost_calculator.pycost_per_token   sN   r   N)
__doc__typingr   Zlitellm.types.utilsr   Zlitellm.utilsr   strfloatr   r	   r	   r	   r
   <module>   s
    "