o
    پi                     @   sT   d dl Z d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZ G dd deZdS )    N)DictListUnion)BaseMultimodalProcessor)Gemma3ForConditionalGeneration)MultimodalSpecialTokensc                       s>   e Zd ZegZ fddZdeeee	e
f  fddZ  ZS )Gemma3SGLangImageProcessorc                    sP   t  j|||g|R i | |j| _|j| _td|jt	dd
|| _d S )Nz<start_of_image>z:<start_of_image>(?:(?:<image_soft_token>)*<end_of_image>)?)image_tokenimage_token_idimage_token_regex)super__init__boi_token_indexIM_START_TOKEN_IDeoi_token_indexIM_END_TOKEN_IDr   image_token_indexrecompilebuild	mm_tokens)self	hf_configserver_args
_processorargskwargs	__class__ [/home/ubuntu/.local/lib/python3.10/site-packages/sglang/srt/multimodal/processors/gemma3.pyr      s   z#Gemma3SGLangImageProcessor.__init__
image_datac           
         s@   | j ||| jdd}| || j\}}}	| || j| jdS )NT)promptr!   multimodal_tokensdiscard_alpha_channel)	input_idsmm_itemsim_start_id	im_end_id)load_mm_datar   process_and_combine_mm_datatolistr   r   )
r   r!   
input_textrequest_objr   r   base_outputr&   r%   _r   r   r    process_mm_data_async   s   
z0Gemma3SGLangImageProcessor.process_mm_data_async)__name__
__module____qualname__r   modelsr   r   r   strbytesr   r0   __classcell__r   r   r   r    r      s    r   )r   typingr   r   r   (sglang.srt.managers.multimodal_processorr   SGLangBaseProcessorsglang.srt.models.gemma3_mmr   /sglang.srt.multimodal.processors.base_processorr   r   r   r   r   r    <module>   s    