
    dh                         S SK Jr  S SKJr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  S SKJrJr  S SKJr   " S S	\5      rg
)    )partial)AnyDictListMappingOptionalSet)CallbackManagerForLLMRun)LLM)pre_init)
ConfigDictField)enforce_stop_tokensc                   "   \ rS rSr% Sr\\S'    \" SSS9r\	\   \S'   \" SSS9r
\\S'    \" S	S
S9r\\S
'    \" SSS9r\\S'    \" SSS9r\\S'    \" SSS9r\\S'    \" SSS9r\\S'    \" SSS9r\\S'    \" SSS9r\\S'    \" SSS9r\	\   \S'    Sr\	\   \S'    Sr\	\   \S'    Sr\	\   \S'    Sr\	\   \S'    Sr\	\   \S'    / r\	\\      \S'    Sr\	\   \S '    S!r\	\   \S"'    \" S#S$S9r\\S$'    Sr \\S%'    Sr!\\S&'    \" S'S(S9r"\	\   \S('    Sr#\$\S)'   \%" S*S+9r&\'S,\(\   4S- j5       r)S,\*\\$4   4S. jr+\,S/\*S,\*4S0 j5       r-\.S,\/\\$4   4S1 j5       r0\.S,\4S2 j5       r1  S8S3\S\	\\      S4\	\2   S5\$S,\4
S6 jjr3S7r4g)9GPT4All   a  GPT4All language models.

To use, you should have the ``gpt4all`` python package installed, the
pre-trained model file, and the model's config information.

Example:
    .. code-block:: python

        from langchain_community.llms import GPT4All
        model = GPT4All(model="./models/gpt4all-model.bin", n_threads=8)

        # Simplest invocation
        response = model.invoke("Once upon a time, ")
modelNbackend)alias   
max_tokensn_partsr   seedFf16_kv
logits_all
vocab_only	use_mlock	embedding   	n_threads   	n_predictgffffff?tempg?top_p(   top_kechostop@   repeat_last_ngzG?repeat_penalty   n_batch	streamingallow_downloadcpudeviceclientforbid)extrareturnc                  
    1 Sk$ )N>	   r$   r'   r%   r.   r#   r/   r   r+   r,    r8       X/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/llms/gpt4all.py_model_param_namesGPT4All._model_param_namesg   s    

 
	
r9   c           
          U R                   U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  S.	$ )N	r   r#   r'   r%   r$   r.   r,   r+   r/   r>   selfs    r:   _default_paramsGPT4All._default_paramsu   sO    //ZZZZII||"11!//

 
	
r9   valuesc                     SSK Jn  US   nUR                  S5      u  pEnXE-  nU" UU=(       d    SUS   US   US	   S
9US'   US   b!  US   R                  R                  US   5         US   R                  US'   U$ ! [         a    [        S5      ef = f! [         a     US   R                  R                  US'    U$ f = f)z;Validate that the python package exists in the environment.r   )r   zVCould not import gpt4all python package. Please install it with `pip install gpt4all`.r   /Nr   r0   r2   )
model_path
model_typer0   r2   r3   r!   )gpt4allr   ImportError
rpartitionr   set_thread_countrG   AttributeError)clsrC   GPT4AllModel	full_pathrF   	delimiter
model_names          r:   validate_environmentGPT4All.validate_environment   s   	7 7O	,5,@,@,E)
z
'!)Ti(!"23(#
x +*8""33F;4GH	B &x 0 ; ;F9
 7  	@ 	.  	B &x 0 6 6 A AF9		Bs   B  ,B  B&CCc                     SU R                   0U R                  5       EU R                  R                  5        VVs0 sH  u  pXR	                  5       ;   d  M  X_M     snnE$ s  snnf )zGet the identifying parameters.r   )r   rA   __dict__itemsr;   )r@   kvs      r:   _identifying_paramsGPT4All._identifying_params   sm     TZZ
""$
 "&!4!4!6!6!?V?V?X:X!6
 	
s   A"A"c                     g)zReturn the type of llm.rH   r8   r?   s    r:   	_llm_typeGPT4All._llm_type   s     r9   promptrun_managerkwargsc                 
   SnU(       a  [        UR                  U R                  S9nSn0 U R                  5       EUEnU R                  R
                  " U40 UD6 H  nU(       a  U" U5        Xh-  nM     Ub  [        Xb5      nU$ )aQ  Call out to GPT4All's generate method.

Args:
    prompt: The prompt to pass into the model.
    stop: A list of strings to stop generation when encountered.

Returns:
    The string generated by the model.

Example:
    .. code-block:: python

        prompt = "Once upon a time, "
        response = model.invoke(prompt, n_predict=55)
N)verbose )r   on_llm_new_tokenrb   rA   r3   generater   )	r@   r^   r)   r_   r`   text_callbacktextparamstokens	            r:   _callGPT4All._call   s    , #K$@$@$,,WM5D((*5f5[[))&;F;Ee$MD < &t2Dr9   r8   )NN)5__name__
__module____qualname____firstlineno____doc__str__annotations__r   r   r   r   intr   r   r   boolr   r   r   r   r!   r#   r$   floatr%   r'   r(   r)   r   r+   r,   r.   r/   r0   r2   r3   r   r   model_configstaticmethodr	   r;   r   rA   r   rR   propertyr   rY   r\   r
   rj   __static_attributes__r8   r9   r:   r   r      s    J5"4y9GXc]9C|4J49-GS-? av&D#&-h/FD/1U,7J7@U,7J7/E5It5,E5It5"$Qk:Ix}:#"Ix}"3D(5/. E8E? .E8C=. D(4. % "D(49
"@#%M8C=%&*NHUO*2),GS,+It/ ND D!%x8FHSM8BFCL 
C 
 

c3h 
 $ 4  B 
WS#X%6 
 
 3   %):>	!! tCy!! 67	!
 ! 
! !r9   r   N)	functoolsr   typingr   r   r   r   r   r	   langchain_core.callbacksr
   #langchain_core.language_models.llmsr   langchain_core.utilsr   pydanticr   r   langchain_community.llms.utilsr   r   r8   r9   r:   <module>r      s+     : : = 3 ) & >Ic Ir9   