o
    پi+                     @   s^   d dl Z d dlmZ 	ddedeeef deded	ef
d
dZde jd	eeef fddZdS )    N)Any Fconfig	args_dictprefixpop_argsreturnc           
      C   s  dg}g }|  dkr=| D ],\}}t| |r;|dur;|dkr.t|tr.t| |t| nt| || |r;|| qn1| d}| D ]'\}}||rm|durm|t	|d }	t| |	rft| |	| |rm|| qF|r~|D ]}||vr}|
| qrt	|dkS )aD  
    Update configuration object from arguments dictionary.

    Args:
        config: The configuration object to update
        args_dict: Dictionary containing arguments
        prefix: Prefix for the configuration parameters in the args_dict.
               If None, assumes direct attribute mapping without prefix.
    
model_pathr   Ntext_encoder_precisions.r   )stripitemshasattr
isinstancelistsetattrtupleappend
startswithlenpop)
r   r   r   r   args_not_to_removeargs_to_removekeyvalueprefix_with_dot	attr_name r   W/home/ubuntu/.local/lib/python3.10/site-packages/sglang/multimodal_gen/configs/utils.pyupdate_config_from_args   s8   





r   argsc                 C   sB   i }t |  D ]\}}|durt| dr|| jv r|||< q|S )z\
    Clean the arguments by removing the ones that not explicitly provided by the user.
    N	_provided)varsr   r   r!   )r    provided_argskvr   r   r   clean_cli_args4   s   r&   )r   F)	argparsetypingr   dictstrboolr   	Namespacer&   r   r   r   r   <module>   s   

 -