
    dh                         S SK r S SKJrJrJrJrJr  S SKJr  S SK	J
r
  S SKJrJrJr  S SKJrJrJrJr  \ R(                  " \5      r " S S\
5      rg)	    N)AnyDictListMappingOptional)CallbackManagerForLLMRun)LLM)convert_to_secret_strget_from_dict_or_envget_pydantic_field_names)
ConfigDictField	SecretStrmodel_validatorc                      \ 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r\\S'    Sr\\S'    Sr\\S'    \" \S9r\\	\4   \S'    \" \S9r\\\	\4      \S'    Sr\\   \S'   \" SS9r\" SS9\S\\	\4   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)'GooseAI   a  GooseAI large language models.

To use, you should have the ``openai`` python package installed, and the
environment variable ``GOOSEAI_API_KEY`` set with your API key.

Any parameters that are valid to be passed to the openai.create call can be passed
in, even if not explicitly saved on this class.

Example:
    .. code-block:: python

        from langchain_community.llms import GooseAI
        gooseai = GooseAI(model_name="gpt-neo-20b")

Nclientzgpt-neo-20b
model_namegffffff?temperature   
max_tokens   top_p
min_tokensr   frequency_penaltypresence_penaltyn)default_factorymodel_kwargs
logit_biasgooseai_api_keyignore)extrabefore)modevaluesreturnc           
         [        U 5      nUR                  S0 5      n[        U5       HP  nXB;  d  M
  XC;   a  [        SU S35      e[        R                  SU SU SU S35        UR                  U5      X4'   MR     X1S'   [        [        USS	5      5      nXQS'    S
SK	nUR                  5       Ul        SUl        UR                  US'   U$ ! [         a    [        S5      ef = f)z>Build extra kwargs from additional params that were passed in.r    zFound z supplied twice.z	WARNING! z/ is not default parameter.
                    zJ was transferred to model_kwargs.
                    Please confirm that z is what you intended.r"   GOOSEAI_API_KEYr   Nzhttps://api.goose.ai/v1r   zTCould not import openai python package. Please install it with `pip install openai`.)r   getlist
ValueErrorloggerwarningpopr
   r   openaiget_secret_valueapi_keyapi_base
CompletionImportError)clsr'   all_required_field_namesr$   
field_namer"   r1   s          X/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/gooseai.pybuild_extraGooseAI.build_extraI   s    $<C#@ 

>2.v,J9&$vj\9I%JKK!* .L !))34JN
 %+JJz$:! ' "'~/ ):<MN
 %4 !
	,==?FN7FO%00F8   	? 	s   /C C#c           	          U R                   U R                  U R                  U R                  U R                  U R
                  U R                  U R                  S.n0 UEU R                  E$ )z3Get the default parameters for calling GooseAI API.)r   r   r   r   r   r   r   r!   )	r   r   r   r   r   r   r   r!   r    )selfnormal_paramss     r:   _default_paramsGooseAI._default_paramsm   sa      ++//ZZ//!%!7!7 $ 5 5//	
 6-54#4#455    c                 :    0 SU R                   0EU R                  E$ )zGet the identifying parameters.r   )r   r@   r>   s    r:   _identifying_paramsGooseAI._identifying_params|   s$     K<1JT5I5IJJrB   c                     g)zReturn type of llm.gooseai rD   s    r:   	_llm_typeGooseAI._llm_type   s     rB   promptstoprun_managerkwargsc                     U R                   nUb  SU;   a  [        S5      eX%S'   0 UEUEnU R                  R                  " SU R                  US.UD6nUR
                  S   R                  nU$ )zCall the GooseAI API.rM   z2`stop` found in both the input and default params.)enginerL   r   rI   )r@   r-   r   creater   choicestext)r>   rL   rM   rN   rO   paramsresponserT   s           r:   _callGooseAI._call   s|     %% !UVV!6N%F%f%;;%%VT__VVvV"''rB   rI   )NN))__name__
__module____qualname____firstlineno____doc__r   r   __annotations__r   strr   floatr   intr   r   r   r   r   r   dictr    r   r!   r   r"   r   r   model_configr   classmethodr;   propertyr@   r   rE   rJ   r   r   rW   __static_attributes__rI   rB   r:   r   r      s     FC#J#K*J( E5DJE u ;e$AsJ;#(#>L$sCx.>V-24-HJc5j)*HD+/OXi(/L (# c3h  C    $ D 6c3h 6 6 KWS#X%6 K K 3   %):>	 tCy! 67	
  
 rB   r   )loggingtypingr   r   r   r   r   langchain_core.callbacksr   #langchain_core.language_models.llmsr	   langchain_core.utilsr
   r   r   pydanticr   r   r   r   	getLoggerrY   r.   r   rI   rB   r:   <module>rn      sE     5 5 = 3 
 C B			8	$Hc HrB   