
    h|                     @   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZ d dlZd dlmZmZ d dlmZmZmZ d d	lmZ d d
lmZm Z  d dl!m"Z"m#Z#  ejH                         dk7  rd dl%Z% e"       rd dl&m'Z' d dl(m)Z) d dl*m+Z+  e#       rd dl,Z,d dlm-Z-mZm.Z.mZ  e/ej`                  ejb                  z         Z2 e/ej`                  ejf                  z   ejb                  z   dz         Z4ddiddiddiddiddiddiddidZ5dZ6ddjo                  e5jq                                dZ9 G d d       Z:e G d! d"             Z;d#e
fd$Z< G d% d&e      Z=e>d'k(  r. e;       Z?d(e?_@        d)e?_@         e=e?      ZAeAj                          yy)*    N)ArgumentParser	Namespace)AsyncIterator)	dataclassfield)Thread)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                       e Zd Zddee   dee   fdZdee   deee	f   fdZ
defdZd	 Zd
efdZd
edefdZddefdZdededefdZy)RichInterfaceN
model_name	user_namec                 f    t               | _        |d| _        n|| _        |d| _        y || _        y )N	assistantuser)r   _consoler$   r%   )selfr$   r%   s      X/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/transformers/commands/chat.py__init__zRichInterface.__init__s   s3    	)DO(DO#DN&DN    streamreturnc                   K   | j                   j                  d| j                   d       t        | j                   d      5 }d}| d {   2 3 d {   }|j                  d   j
                  j                  }|s/t        j                  dd|      }||z  }g }|j                         D ]G  }|j                  |       |j                  d	      r|j                  d
       7|j                  d       I t        dj                  |      j                         d      }|j                  |d       7 7 6 	 d d d        n# 1 sw Y   nxY w| j                   j                          S w)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resub
splitlinesappend
startswithr   joinstripupdate)	r*   r.   liver   tokenoutputslineslinemarkdowns	            r+   stream_outputzRichInterface.stream_output~   sE    l4??*;2>?$--A> &	4$D%+| $4 $4e--*0088 &&gF  OO- -DLL&u- T*V,- $BGGEN$8$8$:}U Hd3I  , $4|&	4 &	4 &	4P 	sO   AE,ED5ED9D7D9CE7D99E;	E,E	#E,c                     | j                   j                  d| j                   d      }| j                   j                          |S )z!Gets user input from the console.[bold red]<z>:
)r)   inputr%   r8   )r*   rM   s     r+   rM   zRichInterface.input   s9    ##k$..1A$FGr-   c                 8    | j                   j                          y)zClears the console.N)r)   clearr*   s    r+   rO   zRichInterface.clear   s    r-   r   c                     | j                   j                  d| j                   d|        | j                   j                          y)z%Prints a user message to the console.rL   z>:[/ bold red]
N)r)   r8   r%   )r*   r   s     r+   print_user_messagez RichInterface.print_user_message   s7    k$..)99I$PQr-   colorc                 z    | j                   j                  d| d|        | j                   j                          y)z,Prints text in a given color to the console.z[bold ]Nr)   r8   )r*   r   rS   s      r+   print_colorzRichInterface.print_color   s1    fUG1TF34r-   minimalc                     | j                   j                  t        |rt        nt                     | j                   j                          y)z'Prints the help message to the console.N)r)   r8   r   HELP_STRING_MINIMALHELP_STRING)r*   rX   s     r+   
print_helpzRichInterface.print_help   s.    HG%8UVr-   generation_configmodel_kwargsc                     | j                   j                  d| d       |r| j                   j                  d|        | j                   j                  d|        | j                   j                          y)zFPrints the status of the model and generation settings to the console.z[bold blue]Model: r5   z[bold blue]Model kwargs: z[bold blue]NrV   )r*   r$   r]   r^   s       r+   print_statuszRichInterface.print_status   sf    0B?@MM";L> JKk*;)<=>r-   )NN)F)__name__
__module____qualname__r	   strr,   r   r   tupleintrJ   rM   rO   rR   rW   boolr\   r   dictr`    r-   r+   r#   r#   r   s    	'8C= 	'HSM 	',-8R*S ,X]^acf^fXg ,\s s 
 C 
$ 
s ?O _c r-   r#   c                      e Zd ZU dZ edddi      Zee   ed<    edddi      Z	ee   ed<    eddd	i      Z
ee   ed
<    edddi      Zeed<    edddi      Zee   ed<    edddi      Zeed<    edddi      Zee   ed<    edddi      Zeed<    edddi      Zeed<    eddg dd      Zee   ed<    eddg dd      Zee   ed <    eddd!i      Zeed"<    eddd#i      Zee   ed$<    eddd%i      Zeed&<    eddd'i      Zeed(<    ed)d*d+d)gd      Zeed,<    eddd-i      Zeed.<    ed/dd0i      Zeed1<    ed2dd3i      Zeed4<   d5 Zy)6ChatArgumentsz
    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.r]   mainzLSpecific model version to use (can be a branch name, tag name or commit id).model_revisionautozDevice to use for inference.devicezA`torch_dtype` is deprecated! Please use `dtype` argument instead.)rv   bfloat16float16float32)rl   r9   torch_dtypezOverride 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.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.portc                 `    | j                   "| j                  dk(  r| j                   | _        yyy)z(Only used for BC `torch_dtype` argument.Nrv   )r{   r|   rP   s    r+   __post_init__zChatArguments.__post_init__!  s1     'DJJ&,@))DJ -A'r-   )ra   rb   rc   __doc__r   ro   r	   rd   __annotations__r(   rp   rq   rr   rs   rg   r]   ru   rw   r{   r|   r}   r~   r   r   r   r   r   r   rf   r   ri   r-   r+   rk   rk      sV    ).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  &:X1YZFCZ!&WA
"K#  !PA
E8C=  $)] ^t  */ r
*#  efL$  efL$   %UFZhmotgu=vww!&uHm?n!o$o kV=d4efD#fdf6W-XYD#Y*r-   rk   argsc                     t        |       S )z;
    Factory function used to chat with a local model.
    )ChatCommand)r   s    r+   chat_command_factoryr   (  s     tr-   c                      e Zd Zedefd       Zd Zedefd       Zed"de	de
e   defd	       Zed"d
e
e   dee   fd       Zdee   defdZde	dedeeef   fdZededede
e   de
e   deeee   f   f
d       Zede	de
d   fd       Zde	dedef   fdZdede	dedeeeeef   f   dededee   deee   eef   fdZd  Zd! Zy)#r   parserc                     t         f}| j                  d|      }|j                  d      }|j                  dt        dd       |j                  dt        dd	d
       |j                  t               y)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.)typerm   rl   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   rm   rl   nargs)func)rk   
add_parseradd_argument_groupadd_argumentrd   set_defaultsr   )r   r   chat_parsergroups       r+   register_subcommandzChatCommand.register_subcommand0  s     )*'''P../EF+J	 	 	
 	W  	 	
 	  &: ;r-   c                 z   |j                   |j                   }|j                  d      s"|j                  d      s|j                  d      rpd| _        |j                  dk7  s|j                  dk7  rt        d      |j                   j                  dd      \  |_        |_        |j                  #t        d	      d
| _        |j                   |_        t               s!t               s| j                  rt        d      t               st        d      t               s| j                  rt        d      || _        y )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   r@   spawn_backendr   r   
ValueErrorrsplitro   r   r   ImportErrorr   )r*   r   names      r+   r,   zChatCommand.__init__Q  s+   --955Dv&$//'*BdooVaFb%*"99+tyyD/@$J 
 (,'I'I'P'PQTVW'X$	49**2$v  &*"*.*L*L' ",>,@TEWEWx  #$hii#%$*<*<7 
 	r-   r/   c                      t        j                         dk(  rt        j                         S t	        j
                  t        j                               j                  S )z)Returns the username of the current user.r   )platformsystemosgetloginpwdgetpwuidgetuidpw_nameri   r-   r+   get_usernamezChatCommand.get_usernamex  s:     ??	);;= <<		,444r-   Nr   filenamec                    i }t        |      |d<   | |d<   |j                  }|Gt        j                  d      }|j                   d| d}t
        j                  j                  ||      }t        j                  t
        j                  j                  |      d       t        |d	      5 }t        j                  ||d
       ddd       t
        j                  j                  |      S # 1 sw Y   (xY w)z!Saves the chat history to a file.settingschat_historyNz%Y-%m-%d_%H-%M-%Sz/chat_.jsonT)exist_okwr1   )indent)varsrq   timestrftimer   r   pathrA   makedirsdirnameopenjsondumpabspath)r   r   r   output_dictfoldertime_strfs          r+   	save_chatzChatCommand.save_chat  s     "&t*J&*N#!!}}%89H<<=VH:USHww||FH5H
BGGOOH-=(C  	0AIIk1Q/	0wwx((	0 	0s   +C++C4rp   c                     | g }|S d| dg}|S )zClears the chat history.r   roler;   ri   )rp   r   s     r+   clear_chat_historyzChatCommand.clear_chat_history  s*      D  &-@ADr-   r   c           	         t        |      dk(  ri S |D ci c]/  }d|j                  d      d   z   dz   |j                  d      d   1 }}|j                         D ci c]*  \  }}||j                         dv r|j                         n|, }}}|j                         D ci c]  \  }}||dk(  rdn| }}}dt        d	t
        fd
}|j                         D ci c]  \  }}| ||      sd| dn| }}}dj                  |j                         D cg c]  \  }}| d|  c}}      }d|z   dz   }|j                  dd      }|j                  dd      }|j                  dd      }|j                  dd      }|j                  dd      }|j                  dd      }	 t        j                  |      }|S c c}w c c}}w c c}}w c c}}w c c}}w # t        j                  $ r t        d      w xY w)zUParses the generate flags from the user input into a dictionary of `generate` kwargs.r   "=r   )truefalseNonenullsr/   c                 p    | j                  d      r| dd  } | j                  ddd      j                         S )N-r   .r4   )r@   replaceisdigit)r   s    r+   	is_numberz3ChatCommand.parse_generate_flags.<locals>.is_number  s5    ||C abE99S"a(0022r-   z, z: {}z"null"z"true"r   z"false"r   z"[[z]"rU   r   zFailed to convert `generate_flags` into a valid JSON object.
`generate_flags` = {generate_flags}
Converted JSON string = {generate_flags_string})lensplititemslowerrd   rg   rA   r   r   loadsJSONDecodeErrorr   )	r*   r   flaggenerate_flags_as_dictkvr   generate_flags_stringprocessed_generate_flagss	            r+   parse_generate_flagsz ChatCommand.parse_generate_flags  s@   ~!#I
 bp!pY]#

3(:":S"@$**S/RSBT"T!p!p
 OeNjNjNl"
FJaAAGGI)::qwwyA"
 "
 OeNjNjNl!mda!qF{V"A!m!m	3 	3 	3 VlUqUqUs!tTQPQ!Yq\q1Xq"H!t!t
 !%		CYC_C_Ca*b41aaS1#;*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)   4F>/G#G	GG
'G G:model_generation_configc                    |j                   d|j                   v rit        j                  j                  |j                         }t        j                  j	                  |j                         }t        j                  ||      }nJt        j                  |j                         }n*t        j                  |      } |j                  di ddd | j                  |j                        } |j                  di |}||fS )zj
        Returns a GenerationConfig object holding the generation parameters for the CLI command.
        r   T   )	do_samplemax_new_tokensri   )r]   r   r   r   basenamer   from_pretrainedcopydeepcopyrC   r   r   )r*   r   r   r   r   r]   parsed_generate_flagsr^   s           r+   get_generation_parameterizationz+ChatCommand.get_generation_parameterization  s     !!-$000''//$*@*@A77++D,B,BC$4$D$DWh$W!$4$D$DTE[E[$\!
 !%.E F$$$RTS'QR !% 9 9$:M:M N/(//H2GH !,..r-   	tokenizerr]   
eos_tokenseos_token_idsc                    |j                   |j                  }n|j                   }g }|/|j                  | j                  |j	                  d                   |7|j                  |j	                  d      D cg c]  }t        |       c}       t        |      dk(  r|j                  |j                         ||fS c c}w )z:Retrieves the pad token ID and all possible EOS token IDs.,r   )pad_token_ideos_token_idextendconvert_tokens_to_idsr   rf   r   r?   )r   r]   r   r   r   all_eos_token_idstoken_ids          r+   parse_eos_tokenszChatCommand.parse_eos_tokens  s     ))1,99L,99L!$$Y%D%DZEUEUVYEZ%[\$$$MDWDWX[D\%]c(m%]^ !Q&$$%6%C%CD... &^s   9B?
model_argsr   c                     | j                   r:t        d| j                  | j                  | j                  | j                        }|S | j
                  rt        d      }|S d }|S )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_configz#ChatCommand.get_quantization_config  st    """4!'1'7'7$.$B$B*4*I*I'1'7'7# #" $$"4!# #" #'""r-   r   c                    t        j                  |j                  |j                  |j                        }|j
                  dv r|j
                  nt        t        |j
                        }| j                  |      }|j                  |j                  |d|d}t        j                  |j                  fd|j                  i|}t        |dd       |j                  |j                        }||fS )N)revisionr}   )rv   Nrv   )r  r~   r|   
device_mapr  r}   hf_device_map)r   r   model_name_or_path_positionalru   r}   r|   getattrtorchr  r~   r   torw   )r*   r   r   r|   r  r^   models          r+   load_model_and_tokenizerz$ChatCommand.load_model_and_tokenizer   s    !11..(("44
	 #jjN:

tzz@Z"::4@++#'#;#; #6
 %44..
BFBXBX
\h
 5/408HHT[[)Eir-   
user_input	interfaceexamplesr^   r   c                    d}|dk(  r-| j                  |j                        }|j                          n/|dk(  r|j                          n|j	                  d      rnt        |j                               dk  rR|j                         }	t        |	      dk(  r|	d   }
nd}
| j                  |||
      }
|j                  d|
 d	d
       n|j	                  d      r|dd j                         }|j                         }|D ]   }d|vs|j                  d| dd        nA | j                  |      } |j                  di |} |j                  di | n	|j	                  d      rt        |j                               dk(  r|j                         d   }||v rD|j                          g }|j                  ||   d          |j                  d||   d   d       nd| dt        |j                                d}|j                  |d       nM|dk(  r|j!                  |j"                  ||       n)d}|j                  d| dd       |j                          ||||fS )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   rS   z!setr1   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$   r]   r^   F'z/' is not a valid command. Showing help message.ri   )r   rp   rO   r\   r@   r   r   r   rW   rB   r   rC   rR   r?   listkeysr`   ro   )r*   r  r   r  r  r]   r^   r   valid_commandsplit_inputr   new_generate_flagsr   parsed_new_generate_flagsnew_model_kwargsexample_nameexample_errors                    r+   handle_non_exit_user_commandsz)ChatCommand.handle_non_exit_user_commands;  s    !**4+=+=>DOO7"  """7+J4D4D4F0G!0K$**,K;1$&q>~~dD(;H!!z'C7!S""6* ",AB!5!5!7!3!9!9!;* 8d?))Ftf MA A $ *  8 -1,E,EFX,Y)#;#4#;#;#X>W#X ###7&67"":.3z7G7G7I3Ja3O%++-a0Lx'!,,Xl-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                 J    t        j                  | j                                y N)asynciorun
_inner_runrP   s    r+   r/  zChatCommand.run  s    DOO%&r-   c                 0  K   | j                   rt        | j                  j                  | j                  j                  | j                  j
                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  | j                  j                  d      }t        |      }t        |j                        }d|_        |j#                          | j                  j$                  dz   | j                  j&                  z   }| j                  j                  dk(  rdn| j                  j                  }t)        | d| j                  j                         }| j                  }|j*                  t,        }n3t/        |j*                        5 }	t1        j2                  |	      }d d d        |j4                  | j7                         }
n|j4                  }
t9        j:                  |j$                        }| j=                  ||      \  }}t?        |j$                  |
	      }|jA                          | jC                  |jD                        }|jG                  d
       	 	 |jI                         }|jK                  d      ri|dk(  r	 |jM                          d {    y | jO                  ||||||      \  }}}}|r|jK                  d      s.	 |jM                          d {    |jQ                  d|d       |jS                  |d|jU                         |d      }|jW                  |       d {   }|jQ                  d|d       	 |jM                          d {    # 1 sw Y   xY w7 7 7 D# tX        $ r Y |jM                          d {  7   y w xY w7 A# |jM                          d {  7   w xY ww)Nerror)rw   r|   r}   r~   r   r   r   r   r   r   	log_level)targetT@r   zhttp://localhostr   )r$   r%   )rX   r  z!exit)r  r   r  r  r]   r^   r   r   r(   r   )r]   r  )r.   
extra_bodyr'   )-r   r   r   rw   r|   r}   r~   r   r   r   r   r   r   r   r   r/  daemonstartro   ru   r
   rr   DEFAULT_EXAMPLESr   yaml	safe_loadr(   r   r   r   r   r#   rO   r   rp   r\   rM   r@   closer+  r?   chat_completionto_json_stringrJ   KeyboardInterrupt)r*   
serve_argsserve_commandthreadr  r   clientr   r  r   r(   r   r]   r^   r  r   r  r$  r.   model_outputs                       r+   r0  zChatCommand._inner_run  ss    'yy''iioo"&))"="=$(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*NtUl*m'<!T-D-DPTU	&&t'9'9: 	T*(%&__.
 ((-!W,B lln$$? PTOqOq'1!%&/%-.?)5!% Pr PLm-> )
0E0Ej0Q ( lln$$% KKJ GH//->-M-M-O!&  0  &/%<%<V%DD[\JK
 lln$$S #- -t %$  E % lln$$ %flln$$s   GPN;5B:P0&O P*O+P00O !P4O
5P:AO OO !P4O65P;O 	P
PO 	O3O8 P+O.,P2O33O8 6P8PPPPr-  )ra   rb   rc   staticmethodr   r   r,   rd   r   rk   r	   r   r"  rh   r   r   r   re   r   r   rf   r  r  r   r  r#   r+  r/  r0  ri   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'W%r-   r   __main__z meta-llama/Llama-3.2-3b-Instructzhttp://localhost:8000)Cr.  r   r   r   r   r<   stringr   argparser   r   collections.abcr   dataclassesr   r   	threadingr   typingr	   r:  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_CHARSr9  rZ   rA   r#  r[   r#   rk   r   r   ra   r   r   r   r/  ri   r-   r+   <module>r[     s       	  	   . ) (    L 
 = F D 8??	!$&  ,,v/@/@@A 
6==(6+<+<<?bb 
 MN) QRNO./JK?@  	 	 ";;'7'<'<'>?@ A&Y Yx V* V* V*ry z%, z%z z?D)KD&)@D&tDHHJ r-   