o
    Æ°iû  ã                   @   s<   d dl mZmZ d dlmZ ddlmZ G dd„ deƒZdS )é    )ÚOptionalÚTuple©Úget_secret_stré   )ÚOpenAIGPTConfigc                	   @   sz   e Zd ZdZeddee defdd„ƒZeddee dee fdd	„ƒZdee dee de	ee ee f fd
d„Z
dS )ÚLlamafileChatConfigzRLlamafileChatConfig is used to provide configuration for the LlamaFile's chat API.NÚapi_keyÚreturnc                 C   ó   | pt dƒpdS )zÈAttempt to ensure that the API key is set, preferring the user-provided key
        over the secret manager key (``LLAMAFILE_API_KEY``).

        If both are None, a fake API key is returned.
        ZLLAMAFILE_API_KEYzfake-api-keyr   )r	   © r   úa/home/app/Keep/.python/lib/python3.10/site-packages/litellm/llms/llamafile/chat/transformation.pyÚ_resolve_api_key   s   z$LlamafileChatConfig._resolve_api_keyÚapi_basec                 C   r   )aM  Attempt to ensure that the API base is set, preferring the user-provided key
        over the secret manager key (``LLAMAFILE_API_BASE``).

        If both are None, a default Llamafile server URL is returned.
        See: https://github.com/Mozilla-Ocho/llamafile/blob/bd1bbe9aabb1ee12dbdcafa8936db443c571eb9d/README.md#L61
        ZLLAMAFILE_API_BASEzhttp://127.0.0.1:8080/v1r   )r   r   r   r   Ú_resolve_api_base   s   z%LlamafileChatConfig._resolve_api_basec                 C   s   t  |¡}t  |¡}||fS )aš  Attempts to ensure that the API base and key are set, preferring user-provided values,
        before falling back to secret manager values (``LLAMAFILE_API_BASE`` and ``LLAMAFILE_API_KEY``
        respectively).

        If an API key cannot be resolved via either method, a fake key is returned. Llamafile
        does not require an API key, but the underlying OpenAI library may expect one anyway.
        )r   r   r   )Úselfr   r	   Zdynamic_api_keyr   r   r   Ú$_get_openai_compatible_provider_info   s   

z8LlamafileChatConfig._get_openai_compatible_provider_info)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr   Ústrr   r   r   r   r   r   r   r   r      s    
þýür   N)Útypingr   r   Zlitellm.secret_managers.mainr   Zopenai.chat.gpt_transformationr   r   r   r   r   r   Ú<module>   s    