Ë
    Ýªg÷  ã                   ó:   — d Z ddlmZmZ ddlmZ  G d„ de«      Zy)zä
Nvidia NIM endpoint: https://docs.api.nvidia.com/nim/reference/databricks-dbrx-instruct-infer 

This is OpenAI compatible 

This file only contains param mapping logic

API calling is done using the OpenAI SDK with an api_base
é    )ÚOptionalÚUnion)ÚOpenAIGPTConfigc                   ó<  ‡ — e Zd ZU dZdZee   ed<   dZee   ed<   dZ	ee   ed<   dZ
ee   ed<   dZee   ed<   dZeeeef      ed<   	 	 	 	 	 	 ddee   dee   dee   dee   dee   deeeef      d	dfd
„Zeˆ fd„«       Zded	efd„Zdedededed	ef
d„Zˆ xZS )ÚNvidiaNimConfigzä
    Reference: https://docs.api.nvidia.com/nim/reference/databricks-dbrx-instruct-infer

    The class `NvidiaNimConfig` provides configuration for the Nvidia NIM's Chat Completions API interface. Below are the parameters:
    NÚtemperatureÚtop_pÚfrequency_penaltyÚpresence_penaltyÚ
max_tokensÚstopÚreturnc                 ó¤   — t        «       j                  «       }|j                  «       D ]%  \  }}	|dk7  sŒ|	€Œt        | j                  ||	«       Œ' y )NÚself)ÚlocalsÚcopyÚitemsÚsetattrÚ	__class__)
r   r   r	   r
   r   r   r   Úlocals_ÚkeyÚvalues
             úQ/var/www/openai/venv/lib/python3.12/site-packages/litellm/llms/nvidia_nim/chat.pyÚ__init__zNvidiaNimConfig.__init__   sA   € ô “(—-‘-“/ˆØ!Ÿ-™-ž/‰JˆCØf‹} Ñ!2Ü˜Ÿ™¨¨UÕ3ñ *ó    c                 ó    •— t         ‰|   «       S )N)ÚsuperÚ
get_config)Úclsr   s    €r   r   zNvidiaNimConfig.get_config,   s   ø€ ä‰wÑ!Ó#Ð#r   Úmodelc                 óL   — |dv rg d¢S |dk(  rg d¢S |dk(  rdgS |dv rg d¢S g d	¢S )
zž
        Get the supported OpenAI params for the given model


        Updated on July 5th, 2024 - based on https://docs.api.nvidia.com/nim/reference
        )zgoogle/recurrentgemma-2bzgoogle/gemma-2-27b-itzgoogle/gemma-2-9b-itzgemma-2-9b-it)Ústreamr   r	   r   r   Úseedznvidia/nemotron-4-340b-instruct)r"   r   r	   r   Úmax_completion_tokensznvidia/nemotron-4-340b-rewardr"   )zgoogle/codegemma-1.1-7b)r"   r   r	   r
   r   r   r$   r   )	r"   r   r	   r
   r   r   r$   r   r#   © )r   r    s     r   Úget_supported_openai_paramsz+NvidiaNimConfig.get_supported_openai_params0   se   € ð ð 
ñ 
ò TÐSØÐ7Ò7òð ð Ð5Ò5àðð ð Ð1Ñ1ò	ð 	òB
ð 
r   Únon_default_paramsÚoptional_paramsÚdrop_paramsc                 ó„   — | j                  |¬«      }|j                  «       D ]  \  }}|dk(  r||d<   Œ||v sŒ|||<   Œ |S )N)r    r$   r   )r&   r   )r   r'   r(   r    r)   Úsupported_openai_paramsÚparamr   s           r   Úmap_openai_paramsz!NvidiaNimConfig.map_openai_paramsy   s]   € ð #'×"BÑ"BÈÐ"BÓ"OÐØ.×4Ñ4Ö6‰LˆE5ØÐ/Ò/Ø05 Ò-ØÐ1Ò1Ø). Ò&ð	 7ð
 Ðr   )NNNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚintÚ__annotations__r	   r
   r   r   r   r   ÚstrÚlistr   Úclassmethodr   r&   ÚdictÚboolr-   Ú__classcell__)r   s   @r   r   r      sI  ø… ñð "&€K˜#‘Ó%Ø€Eˆ8C‰=ÓØ'+Ðx ‘}Ó+Ø&*Ðh˜s‘mÓ*Ø $€J˜‘Ó$Ø'+€Dˆ(5˜˜d˜Ñ#Ñ
$Ó+ð &*Ø#Ø+/Ø*.Ø$(Ø+/ñ4à˜c‘]ð4ð ˜‰}ð4ð $ C™=ð	4ð
 # 3™-ð4ð ˜S‘Mð4ð u˜S $˜YÑ'Ñ(ð4ð 
ó4ð ó$ó ð$ðG°ð G¸ó GðRà ðð ðð ð	ð
 ðð 
÷r   r   N)r1   Útypingr   r   Ú+litellm.llms.openai.chat.gpt_transformationr   r   r%   r   r   Ú<module>r<      s    ðñ÷ #å Gôvoõ vr   