o
    -i6                     @   s,  d Z ddlZddlZddlZddl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mZ ddlmZmZ dd	lmZmZ dd
lmZmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ee"Z#G dd dej$Z%eeG dd dZ&de!de!fddZ'dej(fddZ)de!fddZ*dS )z
This file contains the command line arguments for the vLLM's
OpenAI-compatible server. It is kept in a separate file for documentation
purposes.
    N)Sequence)field)AnyLiteral)	dataclass)config)AsyncEngineArgsoptional_type)ChatTemplateContentFormatOptionvalidate_chat_template)H11_MAX_HEADER_COUNT_DEFAULT%H11_MAX_INCOMPLETE_EVENT_SIZE_DEFAULT)LoRAModulePath)init_logger)ToolParserManager)FlexibleArgumentParserc                
   @   s>   e Zd Z	ddejdejdeee B dB dedB fddZdS )	LoRAParserActionNparser	namespacevaluesoption_stringc                 C   s   |d u rg }t |trtdg }|D ]b}|dv rqd|v r2d|vr2|d\}}|t|| qzt|}	tdi |	}
||
 W q tjyW   |	d|  Y q tyu } z|	d| dt|  W Y d }~qd }~ww t
|| j| d S )	NzExpected values to be a list)N =,z(Invalid JSON format for --lora-modules: z#Invalid fields for --lora-modules: z -  )
isinstancestr	TypeErrorsplitappendr   jsonloadsJSONDecodeErrorerrorsetattrdest)selfr   r   r   r   	lora_listitemnamepath	lora_dictloraer   r   ]/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/vllm/entrypoints/openai/cli_args.py__call__&   s0   

zLoRAParserAction.__call__N)	__name__
__module____qualname__argparseArgumentParser	Namespacer   r   r/   r   r   r   r.   r   %   s    r   c                   @   s>  e Zd ZU dZdZedB ed< 	 dZeed< 	 dZ	edB ed< 	 dZ
ed ed	< 	 d
Zeed< 	 d
Zeed< 	 edd dZee ed< 	 edd dZee ed< 	 edd dZee ed< 	 dZee dB ed< 	 dZee dB ed< 	 dZedB ed< 	 dZeed< 	 d
Zeed< 	 dZeeef dB ed< 	 dZeed< 	 dZedB ed< 	 dZ edB ed< 	 dZ!edB ed < 	 d
Z"eed!< 	 ee#j$Z%eed"< 	 dZ&edB ed#< 	 dZ'edB ed$< 	 ed%d dZ(ee ed&< 	 d
Z)eed'< 	 d
Z*eed(< 	 d
Z+eed)< 	 d
Z,eed*< 	 d
Z-eed+< 	 dZ.edB ed,< 	 d-Z/eed.< 	 dZ0edB ed/< 	 e1j2Z3edB ed0< 	 dZ4edB ed1< 	 d
Z5eed2< 	 d
Z6eed3< 	 d
Z7eed4< 	 d
Z8eed5< 	 d
Z9eed6< 	 d
Z:eed7< 	 d8Z;eed9< 	 e<Z=eed:< 	 e>Z?eed;< 	 e1j@ZAeed<< 	 d
ZBeed=< 	 d
ZCeed>< 	 eDd?eEd@eEfdAdBZFdS )CFrontendArgsz4Arguments for the OpenAI-compatible frontend server.Nhosti@  portudsinfo)criticalr#   warningr;   debugtraceuvicorn_log_levelFdisable_uvicorn_access_logallow_credentialsc                   C      dgS N*r   r   r   r   r.   <lambda>Z       zFrontendArgs.<lambda>)default_factoryallowed_originsc                   C   rC   rD   r   r   r   r   r.   rF   \   rG   allowed_methodsc                   C   rC   rD   r   r   r   r   r.   rF   ^   rG   allowed_headersapi_keylora_moduleschat_templateautochat_template_content_formattrust_request_chat_templatedefault_chat_template_kwargs	assistantresponse_rolessl_keyfilessl_certfilessl_ca_certsenable_ssl_refreshssl_cert_reqsssl_ciphers	root_pathc                   C   s   g S r0   r   r   r   r   r.   rF      s    
middlewarereturn_tokens_as_token_ids disable_frontend_multiprocessingenable_request_id_headersenable_auto_tool_choice#exclude_tools_when_tool_choice_nonetool_call_parserr   tool_parser_plugintool_serverlog_config_filemax_log_lendisable_fastapi_docsenable_prompt_tokens_detailsenable_server_load_trackingenable_force_include_usageenable_tokenizer_info_endpointenable_log_outputsTenable_log_deltash11_max_incomplete_event_sizeh11_max_header_countlog_error_stacktokens_onlyenable_offline_docsr   returnc                 C   s0  ddl m} |t}tj|d d< tj|d d< tj|d d< |d d= |d d= |d d= tj|d d< tt|d	 d< t|d	 d
< d|d d
< t|d d< d|d v rZ|d d= g |d d< tt	
 }d|}d| d|d d< | jdtjd}| D ]\}}|jd|dd fi | q| S )Nr   )
get_kwargsrI   typerJ   rK   nargsrR   rM   actionr   r\   defaultr   {z,} or name registered in --tool-parser-pluginrb   metavarFrontend)titledescriptionz--_-)vllm.engine.arg_utilsrt   r7   r    r!   r	   r   r   listr   list_registeredjoinadd_argument_group__doc__itemsadd_argumentreplace)r   rt   frontend_kwargsvalid_tool_parsersparsers_strfrontend_groupkeyvaluer   r   r.   add_cli_args   s6   






"zFrontendArgs.add_cli_args)Gr1   r2   r3   r   r8   r   __annotations__r9   intr:   r@   r   rA   boolrB   r   rI   r   rJ   rK   rL   rM   r   rN   rP   r
   rQ   rR   dictr   rT   rU   rV   rW   rX   ssl	CERT_NONErY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   envsVLLM_LOGGING_CONFIG_PATHre   rf   rg   rh   ri   rj   rk   rl   rm   r   rn   r   ro   VLLM_SERVER_DEV_MODErp   rq   rr   staticmethodr   r   r   r   r   r.   r7   G   s   
 r7   r   rs   c                 C   s^   | j dtddd | j ddddd	 | j d
dtddd | j ddd t| } t| } | S )a(  Create the CLI argument parser used by the OpenAI API server.

    We rely on the helper methods of `FrontendArgs` and `AsyncEngineArgs` to
    register all arguments instead of manually enumerating them here. This
    avoids code duplication and keeps the argument definitions in one place.
    	model_tag?z8The model tag to serve (optional if specified in config))ru   rv   helpz
--headless
store_trueFzRRun in headless mode. See multi-node data parallel documentation for more details.)rw   rx   r   z--api-server-countz-ascNzVHow many API server processes to run. Defaults to data_parallel_size if not specified.)ru   rx   r   z--configzRead CLI options from a config file. Must be a YAML with the following options: https://docs.vllm.ai/en/latest/configuration/serve_args.html)r   )r   r   r   r7   r   r   )r   r   r   r.   make_arg_parser	  s4   

r   argsc                 C   sR   t | dr| jdkrdS t| j | jr| jstd| jr%| js'tddS dS )z>Quick checks for model serve args that raise prior to loading.	subparserserveNz<Error: --enable-auto-tool-choice requires --tool-call-parserz:Error: --enable-log-outputs requires --enable-log-requests)	hasattrr   r   rN   r`   rb   r   rl   enable_log_requests)r   r   r   r.   validate_parsed_serve_args1  s   
r   c                  C   s   t dd} t| S )Nz%-m vllm.entrypoints.openai.api_server)prog)r   r   )parser_for_docsr   r   r.   create_parser_for_docs@  s   r   )+r   r4   r    r   collections.abcr   dataclassesr   typingr   r   pydantic.dataclassesr   	vllm.envsr   vllm.configr   r   r   r	   vllm.entrypoints.chat_utilsr
   r   vllm.entrypoints.constantsr   r   'vllm.entrypoints.openai.models.protocolr   vllm.loggerr   vllm.tool_parsersr   vllm.utils.argparse_utilsr   r1   loggerActionr   r7   r   r6   r   r   r   r   r   r.   <module>   s4   " A(