Ë
    µŒja  ã                   ó–   — d dl Z d dlZd dlmZmZmZmZmZ d dlZd dl	m
Z
 d dlmZ d dlmZ  e j                  e«      Z G d„ de«      Zy)é    N)ÚAnyÚDictÚListÚMappingÚOptional)ÚCallbackManagerForLLMRun)ÚLLM)ÚFieldc                   óÜ   — e Zd ZU dZeed<   eed<    ee¬«      Ze	ee
f   ed<    ee¬«      Ze	ee
f   ed<   edeee
f   fd„«       Zedefd	„«       Z	 	 ddedeee      dee   de
def
d„Zy
)ÚBasetenaÙ  Baseten model

    This module allows using LLMs hosted on Baseten.

    The LLM deployed on Baseten must have the following properties:

    * Must accept input as a dictionary with the key "prompt"
    * May accept other input in the dictionary passed through with kwargs
    * Must return a string with the model output

    To use this module, you must:

    * Export your Baseten API key as the environment variable `BASETEN_API_KEY`
    * Get the model ID for your model from your Baseten dashboard
    * Identify the model deployment ("production" for all model library models)

    These code samples use
    [Mistral 7B Instruct](https://app.baseten.co/explore/mistral_7b_instruct)
    from Baseten's model library.

    Examples:
        .. code-block:: python

            from langchain_community.llms import Baseten
            # Production deployment
            mistral = Baseten(model="MODEL_ID", deployment="production")
            mistral("What is the Mistral wind?")

        .. code-block:: python

            from langchain_community.llms import Baseten
            # Development deployment
            mistral = Baseten(model="MODEL_ID", deployment="development")
            mistral("What is the Mistral wind?")

        .. code-block:: python

            from langchain_community.llms import Baseten
            # Other published deployment
            mistral = Baseten(model="MODEL_ID", deployment="DEPLOYMENT_ID")
            mistral("What is the Mistral wind?")
    ÚmodelÚ
deployment)Údefault_factoryÚinputÚmodel_kwargsÚreturnc                 ó"   — i d| j                   i¥S )zGet the identifying parameters.r   )r   ©Úselfs    új/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/llms/baseten.pyÚ_identifying_paramszBaseten._identifying_params>   s   € ð
Ø˜t×0Ñ0Ð1ð
ð 	
ó    c                  ó   — y)zReturn type of model.Úbaseten© r   s    r   Ú	_llm_typezBaseten._llm_typeE   s   € ð r   NÚpromptÚstopÚrun_managerÚkwargsc                 ó   — t         j                  d   }| j                  }| j                  dk(  rd|› d�}n)| j                  dk(  rd|› d�}nd|› d| j                  › d�}t	        j
                  |d	d
|› �id|i|¥¬«      }|j                  «       S )NÚBASETEN_API_KEYÚ
productionzhttps://model-z".api.baseten.co/production/predictÚdevelopmentz#.api.baseten.co/development/predictz.api.baseten.co/deployment/z/predictÚAuthorizationzApi-Key r   )ÚheadersÚjson)ÚosÚenvironr   r   ÚrequestsÚpostr'   )	r   r   r   r   r    Úbaseten_api_keyÚmodel_idÚ	model_urlÚresponses	            r   Ú_callzBaseten._callJ   s©   € ô Ÿ*™*Ð%6Ñ7ˆØ—:‘:ˆØ�?‰?˜lÒ*Ø(¨¨
Ð2TÐU‰IØ�_‰_ Ò-Ø(¨¨
Ð2UÐV‰Ià(¨¨
Ð2MÈdÏoÉoÐM^Ð^fÐgˆIÜ—=‘=ØØ$¨°Ð0AÐ&BÐCØ˜FÐ- fÐ-ô
ˆð
 �}‰}‹Ðr   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r
   Údictr   r   r   r   Úpropertyr   r   r   r   r   r   r0   r   r   r   r   r      sË   … ñ)ðV ƒJØƒOÙ!°$Ô7€Eˆ4��S�‰>Ó7Ù#(¸Ô#>€L�$�s˜C�x‘.Ó>àð
 W¨S°#¨XÑ%6ò 
ó ð
ð ð˜3ò ó ðð %)Ø:>ñ	àðð �t˜C‘yÑ!ðð Ð6Ñ7ð	ð
 ðð 
ôr   r   )Úloggingr(   Útypingr   r   r   r   r   r*   Úlangchain_core.callbacksr   Ú#langchain_core.language_models.llmsr	   Úpydanticr
   Ú	getLoggerr1   Úloggerr   r   r   r   Ú<module>r@      s=   ðÛ Û 	ß 5Õ 5ã Ý =Ý 3Ý à	ˆ×	Ñ	˜8Ó	$€ôQˆcõ Qr   