
    dha                         S SK r S SKrS SKJrJrJrJrJr  S SKrS SK	J
r
  S SKJr  S SKJr  \ R                  " \5      r " S S\5      rg)    N)AnyDictListMappingOptional)CallbackManagerForLLMRun)LLM)Fieldc                       \ rS rSr% Sr\\S'   \\S'   \" \S9r	\
\\4   \S'   \" \S9r\
\\4   \S'   \S\\\4   4S	 j5       r\S\4S
 j5       r  SS\S\\\      S\\   S\S\4
S jjrSrg)Baseten   ae  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                 "    0 SU R                   0E$ )zGet the identifying parameters.r   )r   selfs    X/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/baseten.py_identifying_paramsBaseten._identifying_params>   s    
t001
 	
    c                     g)zReturn type of model.baseten r   s    r   	_llm_typeBaseten._llm_typeE   s     r   Npromptstoprun_managerkwargsc                     [         R                  S   nU R                  nU R                  S:X  a  SU S3nO*U R                  S:X  a  SU S3nOSU SU R                   S3n[        R
                  " US	S
U 30SU0UES9nUR                  5       $ )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   _callBaseten._callJ   s     **%67::??l*(
2TUI__-(
2UVI(
2MdooM^^fgI==$0A&BCF-f-

 }}r   r   )NN)__name__
__module____qualname____firstlineno____doc__str__annotations__r
   dictr   r   r   r   propertyr   r   r   r   r   r   r3   __static_attributes__r   r   r   r   r      s    )V JO!$7E4S>7#(#>L$sCx.>
WS#X%6 
 
 3   %):>	 tCy! 67	
  
 r   r   )loggingr+   typingr   r   r   r   r   r-   langchain_core.callbacksr   #langchain_core.language_models.llmsr	   pydanticr
   	getLoggerr5   loggerr   r   r   r   <module>rF      s;     	 5 5  = 3 			8	$Qc Qr   