vllm.renderers.chat_utils.item_tracker
¶
Classes:
-
BaseMultiModalItemTracker–Tracks multi-modal items in a given request and ensures that the number
BaseMultiModalItemTracker
¶
Tracks multi-modal items in a given request and ensures that the number of multi-modal items in a given request does not exceed the configured maximum per prompt.
Methods:
-
add–Add a multi-modal item to the current prompt and returns the
Attributes:
-
use_unified_vision_chunk_modality(bool) –Check if model uses unified vision_chunk modality for images/videos.
Source code in vllm/renderers/chat_utils/item_tracker.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
use_unified_vision_chunk_modality
cached
property
¶
Check if model uses unified vision_chunk modality for images/videos.
_validate_add(modality)
¶
Validate that one more item of the modality can be tracked.
Source code in vllm/renderers/chat_utils/item_tracker.py
add(modality, item)
¶
Add a multi-modal item to the current prompt and returns the placeholder string to use, if any.
An optional uuid can be added which serves as a unique identifier of the media.
Note
prompt_embeds bypass MM-processor validation because they are
pre-computed embeddings that do not go through any HF processor, encoder,
or model-specific placeholder logic. The corresponding placeholder string is
managed by the parser via _add_placeholder, so we return None here.
Source code in vllm/renderers/chat_utils/item_tracker.py
_resolve_items(items_by_modality, mm_processor, modality_order)
¶
Materialize the tracker's per-modality items into mm_data / mm_uuids.
Note
mm_processor is None for text-only models (no registered HF
processor) whose only modality is prompt_embeds. Every other
modality requires a processor, enforced by the guard below.
Source code in vllm/renderers/chat_utils/item_tracker.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |