
    dh                         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Jr  S SKJrJrJr  S SKJr   " S S	\
5      rg)
    )AnyDictListMappingOptionalN)CallbackManagerForLLMRun)LLMconvert_to_secret_strget_from_dict_or_env)
ConfigDict	SecretStrmodel_validator)enforce_stop_tokensc                   h   \ rS rSr% SrSr\\S'    Sr\	\S'    Sr
\\S'    S	r\	\S
'    Sr\\S'    Sr\\S'    \\S'   Sr\\   \S'    \" SS9r\" SS9\S\S\4S j5       5       r\S\\\4   4S j5       r\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)#ForefrontAI   a  ForefrontAI large language models.

To use, you should have the environment variable ``FOREFRONTAI_API_KEY``
set with your API key.

Example:
    .. code-block:: python

        from langchain_community.llms import ForefrontAI
        forefrontai = ForefrontAI(endpoint_url="")
 endpoint_urlgffffff?temperature   lengthg      ?top_p(   top_k   repetition_penaltyforefrontai_api_keyNbase_urlforbid)extrabefore)modevaluesreturnc                 8    [        [        USS5      5      US'   U$ )z,Validate that api key exists in environment.r   FOREFRONTAI_API_KEYr
   )clsr$   s     \/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/forefrontai.pyvalidate_environment ForefrontAI.validate_environment5   s)     )> )>@UV)
$%     c                 v    U R                   U R                  U R                  U R                  U R                  S.$ )z7Get the default parameters for calling ForefrontAI API.r   r   r   r   r   r.   selfs    r)   _default_paramsForefrontAI._default_params>   s5      ++kkZZZZ"&"9"9
 	
r,   c                 :    0 SU R                   0EU R                  E$ )zGet the identifying parameters.r   )r   r1   r/   s    r)   _identifying_paramsForefrontAI._identifying_paramsI   s&     O>4#4#45N9M9MNNr,   c                     g)zReturn type of llm.forefrontai r/   s    r)   	_llm_typeForefrontAI._llm_typeN   s     r,   promptstoprun_managerkwargsc                     SU R                   R                  5        3n[        R                  " U R                  USS.SU0U R
                  EUES9nUR                  5       nUS   S   S   nUb  [        X5      nU$ )	a*  Call out to ForefrontAI's complete endpoint.

Args:
    prompt: The prompt to pass into the model.
    stop: Optional list of stop words to use when generating.

Returns:
    The string generated by the model.

Example:
    .. code-block:: python

        response = ForefrontAI("Tell me a joke.")
zBearer zapplication/json)AuthorizationzContent-Typetext)urlheadersjsonresultr   
completion)r   get_secret_valuerequestspostr   r1   rD   r   )	r0   r;   r<   r=   r>   
auth_valueresponseresponse_jsonrA   s	            r)   _callForefrontAI._callS   s    * t77HHJKL
==!!!+ 2 &CD$8$8CFC
 !X&q),7 't2Dr,   r8   )NN)"__name__
__module____qualname____firstlineno____doc__r   str__annotations__r   floatr   intr   r   r   r   r   r   r   model_configr   classmethodr   r   r*   propertyr   r1   r4   r9   r   r   rM   __static_attributes__r8   r,   r)   r   r      se   
 L#K+FCEE5DE3O!  ;"""Hhsm"?L (#$ 3   $ 
c!2 
 
 OWS#X%6 O O 3   %):>	$$ tCy!$ 67	$
 $ 
$ $r,   r   )typingr   r   r   r   r   rH   langchain_core.callbacksr   #langchain_core.language_models.llmsr	   langchain_core.utilsr   r   pydanticr   r   r   langchain_community.llms.utilsr   r   r8   r,   r)   <module>rb      s.    5 5  = 3 L ; ; >k# kr,   