
    <hz                     R   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKJ	r	J
r
  S SKJrJr  S SKJr  S SKJrJr  S SKrS SKJrJr  S SKJrJrJr  S SKJr  S S	KJrJr  S S
K J!r!J"r"  \RF                  " 5       S:w  a  S SK$r$\!" 5       (       a  S SK%J&r&  S SK'J(r(  S SK)J*r*  \"" 5       (       a  S SK+r+S SKJ,r,JrJ-r-Jr  \." \R^                  \R`                  -   5      r1\." \R^                  \Rd                  -   \R`                  -   S-   5      r3SS0SS0SS0SS0SS0SS0SS0S.r4Sr5SSRm                  \4Ro                  5       5       S3r8 " S S5      r9\ " S  S!5      5       r:S"\
4S# jr; " S$ S%\5      r<\=S&:X  a.  \:" 5       r>S'\>l?        S(\>l?        \<" \>5      r@\@R                  5         gg))    N)ArgumentParser	Namespace)	dataclassfield)Thread)AsyncIteratorOptional)AsyncInferenceClientChatCompletionStreamOutput)AutoTokenizerGenerationConfigPreTrainedTokenizer)BaseTransformersCLICommand)ServeArgumentsServeCommand)is_rich_availableis_torch_availableWindows)Console)Live)Markdown)AutoModelForCausalLMr   BitsAndBytesConfigr   z .!\"#$%&'()*+,\-/:<=>?@[]^_`{|}~textz5There is a Llama in my lawn, how can I get rid of it?zyWrite a Python function that integrates any Python function f(x) numerically over an arbitrary interval [x_start, x_end].z4How many helicopters can a human eat in one sitting?z4Count to 10 but skip every number ending with an 'e'zWhy aren't birds real?z2Why is it important to eat socks after meditating?z$Which number is larger, 9.9 or 9.11?)llamacode
helicopternumbersbirdssocksnumbers2a  

**TRANSFORMERS CHAT INTERFACE**

Chat interface to try out a model. Besides chatting with the model, here are some basic commands:
- **!help**: shows all available commands (set generation settings, save chat, etc.)
- **!status**: shows the current status of the model and generation settings
- **!clear**: clears the current conversation and starts a new one
- **!exit**: closes the interface
am  

**TRANSFORMERS CHAT INTERFACE HELP**

Full command list:
- **!help**: shows this help message
- **!clear**: clears the current conversation and starts a new one
- **!status**: shows the current status of the model and generation settings
- **!example {NAME}**: loads example named `{NAME}` from the config and uses it as the user input.
Available example names: `z`, `a%  `
- **!set {ARG_1}={VALUE_1} {ARG_2}={VALUE_2}** ...: changes the system prompt or generation settings (multiple
settings are separated by a space). Accepts the same flags and format as the `generate_flags` CLI argument.
If you're a new user, check this basic flag guide: https://huggingface.co/docs/transformers/llm_tutorial#common-options
- **!save {SAVE_NAME} (optional)**: saves the current chat and settings to file by default to
`./chat_history/{MODEL_NAME}/chat_{DATETIME}.yaml` or `{SAVE_NAME}` if provided
- **!exit**: closes the interface
c                       \ rS rSrSS\\   S\\   4S jjrS\\   S\	\\
4   4S jrS\4S	 jrS
 rS\4S jrS\S\4S jrSS\4S jjrS\S\S\4S jrSrg)RichInterfaceq   N
model_name	user_namec                 f    [        5       U l        Uc  SU l        OXl        Uc  SU l        g X l        g )N	assistantuser)r   _consoler%   r&   )selfr%   r&   s      R/var/www/html/shao/venv/lib/python3.13/site-packages/transformers/commands/chat.py__init__RichInterface.__init__r   s/    	)DO(O#DN&N    streamreturnc                   #    U R                   R                  SU R                   S35        [        U R                   SS9 nSnUI S h  vN   S h  vN nUR                  S   R
                  R                  nUR                  nU(       d  MA  [        R                  " SSU5      nX5-  n/ nUR                  5        HN  nUR                  U5        UR                  S	5      (       a  UR                  S
5        M=  UR                  S5        MP     [        SR                  U5      R                  5       SS9n	UR!                  U	SS9  M   N N
 S S S 5        O! , (       d  f       O= fU R                   R                  5         WW4$ 7f)Nz[bold blue]<z>:   )consolerefresh_per_second r   z<(/*)(\w*)>z\<\1\2\>z```
z  
zgithub-dark)
code_themeT)refresh)r*   printr%   r   choicesdeltacontentidresub
splitlinesappend
startswithr   joinstripupdate)
r+   r0   liver   tokenoutputs
request_idlineslinemarkdowns
             r,   stream_outputRichInterface.stream_output}   sA    l4??*;2>?$--A>$D%+|| %4e--*0088"XX
 &&gF  OO-DLL&u-- T*V, . $BGGEN$8$8$:}U Hd3K  , %4| ?>>R 	ZsN   >F EE	EEE	EC3E	EE	F
E#%Fc                     U R                   R                  SU R                   S35      nU R                   R                  5         U$ )z!Gets user input from the console.[bold red]<z>:
)r*   inputr&   r:   )r+   rR   s     r,   rR   RichInterface.input   s9    ##k$..1A$FGr/   c                 8    U R                   R                  5         g)zClears the console.N)r*   clearr+   s    r,   rU   RichInterface.clear   s    r/   r   c                     U R                   R                  SU R                   SU 35        U R                   R                  5         g)z%Prints a user message to the console.rQ   z>:[/ bold red]
N)r*   r:   r&   )r+   r   s     r,   print_user_message RichInterface.print_user_message   s7    k$..)99I$PQr/   colorc                 z    U R                   R                  SU SU 35        U R                   R                  5         g)z,Prints text in a given color to the console.z[bold ]Nr*   r:   )r+   r   r[   s      r,   print_colorRichInterface.print_color   s1    fUG1TF34r/   minimalc                     U R                   R                  [        U(       a  [        O[        5      5        U R                   R                  5         g)z'Prints the help message to the console.N)r*   r:   r   HELP_STRING_MINIMALHELP_STRING)r+   ra   s     r,   
print_helpRichInterface.print_help   s.    HG%8UVr/   generation_configmodel_kwargsc                     U R                   R                  SU S35        U(       a  U R                   R                  SU 35        U R                   R                  SU 35        U R                   R                  5         g)zFPrints the status of the model and generation settings to the console.z[bold blue]Model: r7   z[bold blue]Model kwargs: z[bold blue]Nr^   )r+   r%   rg   rh   s       r,   print_statusRichInterface.print_status   sf    0B?@MM";L> JKk*;)<=>r/   )r*   r%   r&   )NN)F)__name__
__module____qualname____firstlineno__r	   strr-   r   r   tupleintrN   rR   rU   rY   r_   boolre   r   dictrj   __static_attributes__ r/   r,   r#   r#   q   s    	'8C= 	'HSM 	'- -8R*S - X]^acf^fXg - ^s s 
 C 
$ 
s ?O _c r/   r#   c                   H   \ rS rSr% Sr\" SSS0S9r\\   \	S'   \" SSS0S9r
\\   \	S	'   \" SSS
0S9r\\   \	S'   \" SSS0S9r\\	S'   \" SSS0S9r\\   \	S'   \" SSS0S9r\\	S'   \" SSS0S9r\\   \	S'   \" SSS0S9r\\	S'   \" SSS0S9r\\	S'   \" SS/ SQS.S9r\\   \	S '   \" SSS!0S9r\\	S"'   \" SSS#0S9r\\   \	S$'   \" SSS%0S9r\\	S&'   \" SSS'0S9r\\	S('   \" S)S*S+S)/S.S9r\\	S,'   \" SSS-0S9r\\	S.'   \" S/SS00S9r\\	S1'   \" S2SS30S9r\\	S4'   S5rg)6ChatArguments   z
Arguments for the chat CLI.

See the metadata arg for each argument's description -- the medatata will be printed with
`transformers chat --help`
Nhelpz_Name of the pre-trained model. The positional argument will take precedence if both are passed.)defaultmetadatamodel_name_or_pathzKUsername to display in chat interface. Defaults to the current user's name.r)   zSystem prompt.system_promptz./chat_history/zFolder to save chat history.save_folderz"Path to a yaml file with examples.examples_pathFz7Whether to show runtime warnings in the chat interface.verbosezPath to a local generation config file or to a HuggingFace repo containing a `generation_config.json` file. Other generation settings passed as CLI arguments will be applied on top of this generation config.rg   mainzLSpecific model version to use (can be a branch name, tag name or commit id).model_revisioncpuzDevice to use for inference.deviceautozOverride the default `torch.dtype` and load the model under this dtype. If `'auto'` is passed, the dtype will be automatically derived from the model's weights.)r   bfloat16float16float32)rz   r;   torch_dtypez2Whether to trust remote code when loading a model.trust_remote_codezWhich attention implementation to use; you can run --attn_implementation=flash_attention_2, in which case you must install this manually by running `pip install flash-attn --no-build-isolation`.attn_implementationzIWhether to use 8 bit precision for the base model - works only with LoRA.load_in_8bitzIWhether to use 4 bit precision for the base model - works only with LoRA.load_in_4bitnf4zQuantization type.fp4bnb_4bit_quant_typez#Whether to use nested quantization.use_bnb_nested_quant	localhostz%Interface the server will listen to..host@  zPort the server will listen to.portrv   )rl   rm   rn   ro   __doc__r   r}   r	   rp   __annotations__r)   r~   r   r   r   rs   rg   r   r   r   r   r   r   r   r   r   r   r   rr   ru   rv   r/   r,   rx   rx      s,    ).u
)   ghD(3-  $)IY@Z#[M8C=[%6&JhAijKj#(Im@n#oM8C=o%6;t2uvGTv (-1
	(x} 	  hiNC  9W0XYFCY!&PA
"K#  $)] ^t  */ r
*#  efL$  efL$   %UFZhmotgu=vww!&uHm?n!o$o kV=d4efD#fdf6W-XYD#Yr/   rx   argsc                     [        U 5      $ )z3
Factory function used to chat with a local model.
)ChatCommand)r   s    r,   chat_command_factoryr     s     tr/   c                      \ rS rSr\S\4S j5       rS r\S\4S j5       r	\S$S\
S	\\   S\4S
 jj5       r\S$S\\   S\\   4S jj5       rS\\   S\4S jrS\
S\S\\\4   4S jr\S\S\S\\   S\\   S\\\\   4   4
S j5       r\S\
S\S   4S j5       rS\
S\S\4   4S jrS\S\
S\S\\\\\4   4   S\S\S\\   S\\\   \\4   4S  jrS! rS" rS#rg)%r   i"  parserc                     [         4nU R                  SUS9nUR                  S5      nUR                  S[        SSS9  UR                  S[        SS	S
S9  UR                  [        S9  g)z
Register this command to argparse so it's available for the transformer-cli

Args:
    parser: Root parser to register command-specific arguments
chat)dataclass_typeszPositional argumentsmodel_name_or_path_or_addressNz7Name of the pre-trained model or address to connect to.)typer{   rz   generate_flagsa  Flags to pass to `generate`, using a space as a separator between flags. Accepts booleans, numbers, and lists of integers, more advanced parameterization should be set through --generation-config. Example: `transformers chat <model_repo> max_new_tokens=100 do_sample=False eos_token_id=[1,2]`. If you're a new user, check this basic flag guide: https://huggingface.co/docs/transformers/llm_tutorial#common-options*)r   r{   rz   nargs)func)rx   
add_parseradd_argument_groupadd_argumentrp   set_defaultsr   )r   r   chat_parsergroups       r,   register_subcommandChatCommand.register_subcommand#  s     )*'''P../EF+J	 	 	
 	W  	 	
 	  &: ;r/   c                    UR                   b  UR                   nUR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       at  SU l        UR                  S:w  d  UR                  S:w  a  [        S5      eUR                   R                  SS5      u  Ul        Ul        UR                  c  [        S	5      eOS
U l        UR                   Ul        [        5       (       d+  [        5       (       d  U R                  (       a  [        S5      e[        5       (       d  [        S5      e[        5       (       d  U R                  (       a  [        S5      eXl        g )Nhttphttpsr   Fr   uu   Looks like you’ve set both a server address and a custom host/port. Please pick just one way to specify the server.:   z\When connecting to a server, please specify a model name with the --model_name_or_path flag.TzYou need to install rich to use the chat interface. Additionally, you have not specified a remote endpoint and are therefore spawning a backend. Torch is required for this: (`pip install rich torch`)zHYou need to install rich to use the chat interface. (`pip install rich`)zYou have not specified a remote endpoint and are therefore spawning a backend. Torch is required for this: (`pip install rich torch`))r   rC   spawn_backendr   r   
ValueErrorrsplitr}   r   r   ImportErrorr   )r+   r   names      r,   r-   ChatCommand.__init__D  sC   --955Dv&&$//'*B*BdooVaFbFb%*"99+tyyD/@$J 
 (,'I'I'P'PQTVW'X$	49**2$v  3
 &*"*.*L*L' "",>,@,@TEWEWx  #$$hii#%%$*<*<7 
 	r/   r1   c                      [         R                  " 5       S:X  a  [        R                  " 5       $ [        R
                  " [        R                  " 5       5      R                  $ )z)Returns the username of the current user.r   )platformsystemosgetloginpwdgetpwuidgetuidpw_namerv   r/   r,   get_usernameChatCommand.get_usernamek  s:     ??	);;= <<		,444r/   Nr   filenamec                    0 n[        U5      US'   XS'   UR                  nUcG  [        R                  " S5      nUR                   SU S3n[
        R                  R                  XB5      n[
        R                  " [
        R                  R                  U5      SS9  [        US	5       n[        R                  " X6S
S9  SSS5        [
        R                  R                  U5      $ ! , (       d  f       N-= f)z!Saves the chat history to a file.settingschat_historyNz%Y-%m-%d_%H-%M-%Sz/chat_.jsonT)exist_okwr3   )indent)varsr   timestrftimer   r   pathrD   makedirsdirnameopenjsondumpabspath)r   r   r   output_dictfoldertime_strfs          r,   	save_chatChatCommand.save_chats  s     "&t*J&*N#!!}}%89H<<=VH:USHww||F5H
BGGOOH-=(C AIIkQ/ !wwx(( ! s   )C&&
C4r~   c                      U c  / nU$ SU S./nU$ )zClears the chat history.r   roler=   rv   )r~   r   s     r,   clear_chat_historyChatCommand.clear_chat_history  s*      D  &-@ADr/   r   c           	         [        U5      S:X  a  0 $ U Vs0 sH0  nSUR                  S5      S   -   S-   UR                  S5      S   _M2     nnUR                  5        VVs0 sH+  u  pEXER                  5       S;   a  UR                  5       OU_M-     nnnUR                  5        VVs0 sH  u  pEXES:X  a  SOU_M     nnnS[        S	[
        4S
 jnUR                  5        VVs0 sH  u  pEXF" U5      (       d  SU S3OU_M     nnnSR                  UR                  5        VVs/ sH  u  pEU SU 3PM     snn5      nSU-   S-   nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  SS5      nUR                  SS5      n [        R                  " U5      nU$ s  snf s  snnf s  snnf s  snnf s  snnf ! [        R                   a    [        S5      ef = f)zUParses the generate flags from the user input into a dictionary of `generate` kwargs.r   "=r   )truefalseNonenullsr1   c                 z    U R                  S5      (       a  U SS  n U R                  SSS5      R                  5       $ )N-r   .r6   )rC   replaceisdigit)r   s    r,   	is_number3ChatCommand.parse_generate_flags.<locals>.is_number  s8    ||C  abE99S"a(0022r/   z, z: {}z"null"z"true"r   z"false"r   z"[[z]"r]   r   zFailed to convert `generate_flags` into a valid JSON object.
`generate_flags` = {generate_flags}
Converted JSON string = {generate_flags_string})lensplititemslowerrp   rs   rD   r   r   loadsJSONDecodeErrorr   )	r+   r   flaggenerate_flags_as_dictkvr   generate_flags_stringprocessed_generate_flagss	            r,   parse_generate_flags ChatCommand.parse_generate_flags  sF   ~!#I
 bp!paoY]#

3(:":S"@$**S/RSBT"Tao!p
 OeNjNjNl"
NldaAGGI)::qwwyANl 	 "
 OeNjNjNl!mNlda!F{V"ANl!m	3 	3 	3 VlUqUqUs!tUsTQ!Yq\\q1Xq"HUs!t
 !%		CYC_C_Ca*bCa41aS1#;Ca*b c !$&; ;c A !6 = =h O 5 = =h O 5 = =i Q 5 = =dC H 5 = =dC H !6 = =c3 G	'+zz2G'H$ ('Y "q"
 "n "u
 +c" ## 	D 	s)   6G!1G(G$ G%G#
4G) ) H	model_generation_configc                    UR                   b  SUR                   ;   ai  [        R                  R                  UR                   5      n[        R                  R	                  UR                   5      n[
        R                  " X45      nOL[
        R                  " UR                   5      nO+[        R                  " U5      nUR                  " S0 SSS.D6  U R                  UR                  5      nUR                  " S0 UD6nXW4$ )zZ
Returns a GenerationConfig object holding the generation parameters for the CLI command.
r   T   )	do_samplemax_new_tokensrv   )rg   r   r   r   basenamer   from_pretrainedcopydeepcopyrF   r  r   )r+   r   r  r   r   rg   parsed_generate_flagsrh   s           r,   get_generation_parameterization+ChatCommand.get_generation_parameterization  s     !!-$000''//$*@*@A77++D,B,BC$4$D$DW$W!$4$D$DTE[E[$\!
 !%.E F$$RTS'QR !% 9 9$:M:M N(//H2GH !..r/   	tokenizerrg   
eos_tokenseos_token_idsc                    UR                   c  UR                  nOUR                   n/ nUb/  UR                  U R                  UR	                  S5      5      5        Ub9  UR                  UR	                  S5       Vs/ sH  n[        U5      PM     sn5        [        U5      S:X  a  UR                  UR                  5        XE4$ s  snf )z:Retrieves the pad token ID and all possible EOS token IDs.,r   )pad_token_ideos_token_idextendconvert_tokens_to_idsr   rr   r   rB   )r  rg   r  r  r  all_eos_token_idstoken_ids          r,   parse_eos_tokensChatCommand.parse_eos_tokens  s     ))1,99L,99L!$$Y%D%DZEUEUVYEZ%[\$$$MDWDWX[D\%]D\c(mD\%]^ !Q&$$%6%C%CD.. &^s   <C
model_argsr   c                     U R                   (       a7  [        SU R                  U R                  U R                  U R                  S9nU$ U R
                  (       a  [        SS9nU$ S nU$ )NT)r   bnb_4bit_compute_dtyper   bnb_4bit_use_double_quantbnb_4bit_quant_storage)r   )r   r   r   r   r   r   )r  quantization_configs     r,   get_quantization_config#ChatCommand.get_quantization_config  st    """4!'1'='=$.$B$B*4*I*I'1'='=# #" $$"4!# #" #'""r/   r   c                    [         R                  " UR                  UR                  UR                  S9nUR
                  S;   a  UR
                  O[        [        UR
                  5      nU R                  U5      nUR                  UR                  USUS.n[        R                  " UR                  4SUR                  0UD6n[        USS 5      c  UR                  UR                  5      nXb4$ )N)revisionr   )r   Nr   )r%  r   r   
device_mapr!  r   hf_device_map)r   r	  model_name_or_path_positionalr   r   r   getattrtorchr"  r   r   tor   )r+   r   r  r   r!  rh   models          r,   load_model_and_tokenizer$ChatCommand.load_model_and_tokenizer  s    !11..(("44
	 +/*:*:n*Ld&&RYZ_aeaqaqRr"::4@++#'#;#;& #6
 %44..
BFBXBX
\h
 5/408HHT[[)Er/   
user_input	interfaceexamplesrh   r   c                    SnUS:X  a-  U R                  UR                  5      nUR                  5         GO6US:X  a  UR                  5         GOUR	                  S5      (       al  [        UR                  5       5      S:  aO  UR                  5       n	[        U	5      S:X  a  U	S   n
OSn
U R                  XrU
5      n
UR                  SU
 S	3S
S9  GOUR	                  S5      (       a  USS R                  5       nUR                  5       nU H   nSU;  d  M  UR                  SU S3SS9    GO?   U R                  U5      nUR                  " S0 UD6nUR                  " S0 UD6  GOUR	                  S5      (       a  [        UR                  5       5      S:X  a  UR                  5       S   nX;   aB  UR                  5         / nUR                  XO   S   5        UR                  SXO   S   S.5        OySU S[        UR                  5       5       S3nUR                  USS9  OHUS:X  a  UR!                  UR"                  UUS9  O&SnUR                  SU S3SS9  UR                  5         XxXV4$ )z
Handles all user commands except for `!exit`. May update the chat history (e.g. reset it) or the
generation config (e.g. set a new flag).
Tz!clearz!helpz!save   r   NzChat saved in !green)r   r[   z!setr3   r   z(Invalid flag format, missing `=` after `z;`. Please use the format `arg_1=value_1 arg_2=value_2 ...`.red!exampler   r)   r   zExample z* not found in list of available examples: r   z!status)r%   rg   rh   F'z/' is not a valid command. Showing help message.rv   )r   r~   rU   re   rC   r   r   r   r_   rE   r  rF   rY   rB   listkeysrj   r}   )r+   r/  r   r0  r1  rg   rh   r   valid_commandsplit_inputr   new_generate_flagsr   parsed_new_generate_flagsnew_model_kwargsexample_nameexample_errors                    r,   handle_non_exit_user_commands)ChatCommand.handle_non_exit_user_commands.  s    !**4+=+=>DOO7"  """7++J4D4D4F0G!0K$**,K;1$&q>~~d(;H!!z'C7!S""6** ",AB!5!5!7!3!9!9!;*d?))Ftf MA A $ *   + -1,E,EFX,Y)#4#;#;#X>W#X ##7&67"":..3z7G7G7I3Ja3O%++-a0L'!,,X-CF-KLV8Nv8VWX |n,VW[\d\i\i\kWlVmmno  %%=%F9$""22"3) #  "M!!:,6e'fns!t  "$5CCr/   c                 L    [         R                  " U R                  5       5        g N)asynciorun
_inner_runrV   s    r,   rG  ChatCommand.run  s    DOO%&r/   c                 X  #    U R                   (       Ga  [        U R                  R                  U R                  R                  U R                  R
                  U R                  R                  U R                  R                  U R                  R                  U R                  R                  U R                  R                  U R                  R                  U R                  R                  SS9n[        U5      n[        UR                  S9nSUl        UR#                  5         U R                  R$                  S-   U R                  R&                  -   nU R                  R                  S:X  a  SOU R                  R                  n[)        U SU R                  R                   35      nU R                  nUR*                  c  [,        nO4[/        UR*                  5       n	[0        R2                  " U	5      nS S S 5        UR4                  c  U R7                  5       n
OUR4                  n
[8        R:                  " UR$                  5      nU R=                  X{5      u  p[?        UR$                  U
S	9nURA                  5         U RC                  URD                  5      nS nURG                  SS
9    URI                  5       nURK                  S5      (       ar  US:X  a   URM                  5       I S h  vN   g U RO                  UUUWUUUS9u  nnpU(       a  URK                  S5      (       d   URM                  5       I S h  vN   M  OURQ                  SUS.5        URS                  USUURU                  5       US.S9nURW                  U5      I S h  vN u  nnURQ                  SUS.5         URM                  5       I S h  vN   GM  ! , (       d  f       GN= f N N NM! [X         a     URM                  5       I S h  vN    g f = f NH! URM                  5       I S h  vN    f = f7f)Nerror)r   r   r   r   r   r   r   r   r   r   	log_level)targetT@r   zhttp://localhostr   )r%   r&   )ra   r4  z!exit)r/  r   r0  r1  rg   rh   r   r7  r)   r   )rJ   rg   r,  )r0   
extra_bodyr(   )-r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rG  daemonstartr}   r   r
   r   DEFAULT_EXAMPLESr   yaml	safe_loadr)   r   r   r	  r  r#   rU   r   r~   re   rR   rC   closerB  rB   chat_completionto_json_stringrN   KeyboardInterrupt)r+   
serve_argsserve_commandthreadr,  r   clientr   r1  r   r)   r  rg   rh   r0  r   rJ   r/  r;  r0   model_outputs                        r,   rH  ChatCommand._inner_run  s~    'yy'' II11"&))"="=$(II$A$A!YY33!YY33$(II$A$A%)YY%C%CYY^^YY^^!J )4M=#4#45F FMLLN		,,s2TYY5M5MM%)YY^^{%B!		%a		/?&@Ayy%'Hd(()Q>>!, * 99$$&D99D"2"B"B4CZCZ"[*.*N*Nt*m'!T-D-DPTU	&&t'9'9:
 	T*)%&__.
 ((--!W,D lln$$A PTOqOq'1!%&/%-.?)5!% Pr PLm-> )
0E0Ej0Q0Q * lln$$- 1R KKJ GH//&0->-M-M-O!&  0  2;1H1H1P+P(j[\JK
 lln$$U ' *)z % ,Q % lln$$ %flln$$s   GP* O	7B6P*.,O! P*.O/P*46O! +P*>O?P*AO! OO! .P*P
P*	
O	P*P*O! !
P+P ,P*?P P*PP 
P*P' P#!P''P*)r   r   rE  )rl   rm   rn   ro   staticmethodr   r   r-   rp   r   rx   r	   r   r9  rt   r   r  r   rq   r  r   rr   r  r"  r   r-  r#   rB  rG  rH  ru   rv   r/   r,   r   r   "  s   <N < <@#N 5# 5 5 )m )x} )PS ) )$ (3- 4:  4(49 4( 4(l/!/<L/	%	&/8 /&/+/ SM/  }	/
 
sDI~	/ /6 #M #hG[>\ # #& ]  uE[]jEj?k  6PDPD PD !	PD
 sDcN*+PD ,PD PD 4jPD 
tDz+T1	2PDh'Z%r/   r   __main__z meta-llama/Llama-3.2-3b-Instructzhttp://localhost:8000)BrF  r
  r   r   r   r?   stringr   argparser   r   dataclassesr   r   	threadingr   typingr   r	   rS  huggingface_hubr
   r   transformersr   r   r   transformers.commandsr   transformers.commands.servingr   r   transformers.utilsr   r   r   r   rich.consoler   	rich.liver   rich.markdownr   r*  r   r   setascii_letters
whitespaceALLOWED_KEY_CHARSdigitsALLOWED_VALUE_CHARSrR  rc   rD   r:  rd   r#   rx   r   r   rl   r   r   r   rG  rv   r/   r,   <module>rt     s       	  	   . (  *  L 
 = F D ??	!$&  ,,v/@/@@A 
6==(6+<+<<?bb 
 MN) QRNO./JK?@  	 	 ";;'7'<'<'>?@ A&Z Zz IZ IZ IZXy }%, }%@ z?D)KD&)@D&tDHHJ r/   