
    h                     B    d dl mZmZ d dlmZ ddlmZ  G d de      Zy)    )OptionalTupleget_secret_str   )OpenAIGPTConfigc            	           e Zd ZdZed	dee   defd       Zed	dee   dee   fd       Zdee   dee   de	ee   ee   f   fdZ
y)
LlamafileChatConfigzRLlamafileChatConfig is used to provide configuration for the LlamaFile's chat API.Napi_keyreturnc                 (    | xs t        d      xs dS )zAttempt 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.
        LLAMAFILE_API_KEYzfake-api-keyr   )r   s    f/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/llms/llamafile/chat/transformation.py_resolve_api_keyz$LlamafileChatConfig._resolve_api_key   s     O.)<=OO    api_basec                 (    | xs t        d      xs dS )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
        LLAMAFILE_API_BASEzhttp://127.0.0.1:8080/v1r   )r   s    r   _resolve_api_basez%LlamafileChatConfig._resolve_api_base   s     ]>*>?]C]]r   c                 ^    t         j                  |      }t         j                  |      }||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   dynamic_api_keys       r   $_get_openai_compatible_provider_infoz8LlamafileChatConfig._get_openai_compatible_provider_info   s/     '88B->>wG((r   )N)__name__
__module____qualname____doc__staticmethodr   strr   r   r   r    r   r   r
   r
      s    \P(3- P3 P P ^HSM ^Xc] ^ ^)3-) #) 
x}hsm+	,	)r   r
   N)typingr   r   litellm.secret_managers.mainr   openai.chat.gpt_transformationr   r
   r    r   r   <module>r$      s    " 7 =&)/ &)r   