11# SPDX-License-Identifier: Apache-2.0 
2- 
32from  collections .abc  import  Iterable 
4- from  dataclasses  import  dataclass 
5- from  functools  import  cached_property 
63from  typing  import  TYPE_CHECKING , Any , Generic , Literal , Optional , Union , cast 
74
8- import  torch 
9- from  typing_extensions  import  NotRequired , TypedDict , TypeVar , assert_never 
5+ from  typing_extensions  import  NotRequired , TypedDict , TypeVar 
106
117if  TYPE_CHECKING :
12-     from  vllm .multimodal  import  (MultiModalDataDict , MultiModalKwargs ,
13-                                  MultiModalPlaceholderDict )
14-     from  vllm .multimodal .inputs  import  MultiModalInputs 
8+     from  vllm .multimodal .inputs  import  MultiModalDataDict , MultiModalInputs 
159
1610
1711class  TextPrompt (TypedDict ):
@@ -153,22 +147,6 @@ class TokenInputs(TypedDict):
153147    if the model supports it. 
154148    """ 
155149
156-     multi_modal_inputs : NotRequired ["MultiModalKwargs" ]
157-     """ 
158-     Optional multi-modal inputs to pass to the model, 
159-     if the model supports it. 
160-     """ 
161- 
162-     multi_modal_placeholders : NotRequired ["MultiModalPlaceholderDict" ]
163-     """ 
164-     Placeholder ranges for the multi-modal data. 
165-     """ 
166- 
167-     multi_modal_hashes : NotRequired [list [str ]]
168-     """ 
169-     The hashes of the multi-modal data. 
170-     """ 
171- 
172150    mm_processor_kwargs : NotRequired [dict [str , Any ]]
173151    """ 
174152    Optional multi-modal processor kwargs to be forwarded to the 
@@ -183,9 +161,6 @@ def token_inputs(
183161    token_type_ids : Optional [list [int ]] =  None ,
184162    prompt : Optional [str ] =  None ,
185163    multi_modal_data : Optional ["MultiModalDataDict" ] =  None ,
186-     multi_modal_inputs : Optional ["MultiModalKwargs" ] =  None ,
187-     multi_modal_hashes : Optional [list [str ]] =  None ,
188-     multi_modal_placeholders : Optional ["MultiModalPlaceholderDict" ] =  None ,
189164    mm_processor_kwargs : Optional [dict [str , Any ]] =  None ,
190165) ->  TokenInputs :
191166    """Construct :class:`TokenInputs` from optional values.""" 
@@ -197,12 +172,6 @@ def token_inputs(
197172        inputs ["token_type_ids" ] =  token_type_ids 
198173    if  multi_modal_data  is  not None :
199174        inputs ["multi_modal_data" ] =  multi_modal_data 
200-     if  multi_modal_inputs  is  not None :
201-         inputs ["multi_modal_inputs" ] =  multi_modal_inputs 
202-     if  multi_modal_hashes  is  not None :
203-         inputs ["multi_modal_hashes" ] =  multi_modal_hashes 
204-     if  multi_modal_placeholders  is  not None :
205-         inputs ["multi_modal_placeholders" ] =  multi_modal_placeholders 
206175    if  mm_processor_kwargs  is  not None :
207176        inputs ["mm_processor_kwargs" ] =  mm_processor_kwargs 
208177
@@ -237,112 +206,6 @@ class EncoderDecoderInputs(TypedDict):
237206:class:`vllm.sequence.Sequence`. 
238207""" 
239208
240- 
241- @dataclass  
242- class  SingletonInputsAdapter :
243-     """ 
244-     Unified interface to access the components of :class:`SingletonInputs`. 
245-     """ 
246-     inputs : SingletonInputs 
247- 
248-     @cached_property  
249-     def  prompt (self ) ->  Optional [str ]:
250-         inputs  =  self .inputs 
251- 
252-         if  inputs ["type" ] ==  "token"  or  inputs ["type" ] ==  "multimodal" :
253-             return  inputs .get ("prompt" )
254- 
255-         assert_never (inputs )  # type: ignore[arg-type] 
256- 
257-     @cached_property  
258-     def  prompt_token_ids (self ) ->  list [int ]:
259-         inputs  =  self .inputs 
260- 
261-         if  inputs ["type" ] ==  "token"  or  inputs ["type" ] ==  "multimodal" :
262-             return  inputs .get ("prompt_token_ids" , [])
263- 
264-         assert_never (inputs )  # type: ignore[arg-type] 
265- 
266-     @cached_property  
267-     def  token_type_ids (self ) ->  list [int ]:
268-         inputs  =  self .inputs 
269- 
270-         if  inputs ["type" ] ==  "token"  or  inputs ["type" ] ==  "multimodal" :
271-             return  inputs .get ("token_type_ids" , [])
272- 
273-         assert_never (inputs )  # type: ignore[arg-type] 
274- 
275-     @cached_property  
276-     def  prompt_embeds (self ) ->  Optional [torch .Tensor ]:
277-         inputs  =  self .inputs 
278- 
279-         if  inputs ["type" ] ==  "token"  or  inputs ["type" ] ==  "multimodal" :
280-             return  None 
281- 
282-         assert_never (inputs )  # type: ignore[arg-type] 
283- 
284-     @cached_property  
285-     def  multi_modal_data (self ) ->  "MultiModalDataDict" :
286-         inputs  =  self .inputs 
287- 
288-         if  inputs ["type" ] ==  "token" :
289-             return  inputs .get ("multi_modal_data" , {})
290- 
291-         if  inputs ["type" ] ==  "multimodal" :
292-             return  inputs .get ("mm_kwargs" , {})
293- 
294-         assert_never (inputs )  # type: ignore[arg-type] 
295- 
296-     @cached_property  
297-     def  multi_modal_inputs (self ) ->  Union [dict , "MultiModalKwargs" ]:
298-         inputs  =  self .inputs 
299- 
300-         if  inputs ["type" ] ==  "token" :
301-             return  inputs .get ("multi_modal_inputs" , {})
302- 
303-         if  inputs ["type" ] ==  "multimodal" :
304-             return  inputs .get ("mm_kwargs" , {})
305- 
306-         assert_never (inputs )  # type: ignore[arg-type] 
307- 
308-     @cached_property  
309-     def  multi_modal_hashes (self ) ->  list [str ]:
310-         inputs  =  self .inputs 
311- 
312-         if  inputs ["type" ] ==  "token" :
313-             return  inputs .get ("multi_modal_hashes" , [])
314- 
315-         if  inputs ["type" ] ==  "multimodal" :
316-             # only the case when we use MultiModalInputs 
317-             return  inputs .get ("mm_hashes" , [])  # type: ignore[return-value] 
318- 
319-         assert_never (inputs )  # type: ignore[arg-type] 
320- 
321-     @cached_property  
322-     def  multi_modal_placeholders (self ) ->  "MultiModalPlaceholderDict" :
323-         inputs  =  self .inputs 
324- 
325-         if  inputs ["type" ] ==  "token" :
326-             return  inputs .get ("multi_modal_placeholders" , {})
327- 
328-         if  inputs ["type" ] ==  "multimodal" :
329-             return  inputs .get ("mm_placeholders" , {})
330- 
331-         assert_never (inputs )  # type: ignore[arg-type] 
332- 
333-     @cached_property  
334-     def  mm_processor_kwargs (self ) ->  dict [str , Any ]:
335-         inputs  =  self .inputs 
336- 
337-         if  inputs ["type" ] ==  "token" :
338-             return  inputs .get ("mm_processor_kwargs" , {})
339- 
340-         if  inputs ["type" ] ==  "multimodal" :
341-             return  {}
342- 
343-         assert_never (inputs )  # type: ignore[arg-type] 
344- 
345- 
346209ProcessorInputs  =  Union [DecoderOnlyInputs , EncoderDecoderInputs ]
347210""" 
348211The inputs to :data:`vllm.inputs.InputProcessor`. 
0 commit comments