|
4 | 4 | Optional, Tuple, Union, cast)
|
5 | 5 |
|
6 | 6 | import torch
|
7 |
| -from typing_extensions import (NotRequired, TypedDict, TypeIs, TypeVar, |
8 |
| - assert_never) |
| 7 | +from typing_extensions import NotRequired, TypedDict, TypeVar, assert_never |
9 | 8 |
|
10 | 9 | if TYPE_CHECKING:
|
11 | 10 | from vllm.multimodal import (MultiModalDataDict, MultiModalKwargs,
|
@@ -177,26 +176,6 @@ class TokenInputs(TypedDict):
|
177 | 176 | """
|
178 | 177 |
|
179 | 178 |
|
180 |
| -def is_token_inputs( |
181 |
| - inputs: Union[TokenInputs, |
182 |
| - "MultiModalInputsV2"]) -> TypeIs[TokenInputs]: |
183 |
| - """ |
184 |
| - Helper function to make sure mypy narrows down the type to |
185 |
| - TokenInputs. |
186 |
| - """ |
187 |
| - return inputs["type"] == "token" |
188 |
| - |
189 |
| - |
190 |
| -def is_multimodal_inputs( |
191 |
| - inputs: Union[TokenInputs, "MultiModalInputsV2"] |
192 |
| -) -> TypeIs["MultiModalInputsV2"]: |
193 |
| - """ |
194 |
| - Helper function to make sure mypy narrows down the type to |
195 |
| - MultiModalInputsV2. |
196 |
| - """ |
197 |
| - return inputs["type"] == "multimodal" |
198 |
| - |
199 |
| - |
200 | 179 | def token_inputs(
|
201 | 180 | prompt_token_ids: List[int],
|
202 | 181 | token_type_ids: Optional[List[int]] = None,
|
@@ -328,11 +307,11 @@ def multi_modal_inputs(self) -> Union[Dict, "MultiModalKwargs"]:
|
328 | 307 | def multi_modal_hashes(self) -> List[str]:
|
329 | 308 | inputs = self.inputs
|
330 | 309 |
|
331 |
| - if is_token_inputs(inputs): |
| 310 | + if inputs["type"] == "token": |
332 | 311 | return inputs.get("multi_modal_hashes", [])
|
333 |
| - elif is_multimodal_inputs(inputs): |
| 312 | + elif inputs["type"] == "multimodal": |
334 | 313 | # only the case when we use MultiModalInputsV2
|
335 |
| - return inputs.get("mm_hashes", []) |
| 314 | + return inputs.get("mm_hashes", []) # type: ignore[return-value] |
336 | 315 |
|
337 | 316 | assert_never(inputs) # type: ignore[arg-type]
|
338 | 317 |
|
|
0 commit comments