§
    æ˜ºhs  ã                   óš   — 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dS )é    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d
S )Ú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    úh/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/langchain_community/llms/baseten.pyÚ_identifying_paramszBaseten._identifying_params>   s   € ð
Ø˜tÔ0Ð1ð
ð 	
ó    c                 ó   — dS )zReturn type of model.Úbaseten© r   s    r   Ú	_llm_typezBaseten._llm_typeE   s	   € ð ˆyr   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|¥¬¦  «        }|                     ¦   «         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Ò*Ð*ØU¨ÐUÐUÐUˆIˆIØŒ_ Ò-Ð-ØV¨ÐVÐVÐVˆIˆIàg¨ÐgÐgÈdÌoÐgÐgÐgˆIÝ”=ØØ$Ð&B°Ð&BÐ&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      s4  € € € € € € ð)ð )ðV €J€J�JØ€O€O�OØ!˜E°$Ð7Ñ7Ô7€Eˆ4��S�Œ>Ð7Ð7Ñ7Ø#( 5¸Ð#>Ñ#>Ô#>€L�$�s˜C�x”.Ð>Ð>Ñ>àð
 W¨S°#¨XÔ%6ð 
ð 
ð 
ñ „Xð
ð ð˜3ð ð ð ñ „Xðð %)Ø:>ð	ð àðð �t˜C”yÔ!ðð Ð6Ô7ð	ð
 ðð 
ðð ð ð ð ð r   r   )Úloggingr(   Útypingr   r   r   r   r   r*   Úlangchain_core.callbacksr   Ú#langchain_core.language_models.llmsr	   Úlangchain_core.pydantic_v1r
   Ú	getLoggerr1   Úloggerr   r   r   r   ú<module>r@      sÐ   ðØ €€€Ø 	€	€	€	Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5à €€€Ø =Ð =Ð =Ð =Ð =Ð =Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,à	ˆÔ	˜8Ñ	$Ô	$€ðQð Qð Qð Qð Qˆcñ Qô Qð Qð Qð Qr   