Commit 8b29b88
committed
refactor(chat_handler): extract MTMDChatHandler base class and Simplify the complexity of subsequent multimodal adaptation
- Extracted the core multimodal processing pipeline from `Llava15ChatHandler` into a generic `MTMDChatHandler` base class, separating pipeline logic from model-specific prompt formats.
- Updated all multimodal subclass handlers (e.g., Qwen2.5vl, Qwen3-vl, MiniCPM, GLM4, LFM2-VL) to inherit from the new `MTMDChatHandler`.
- Implemented strict `**kwargs` validation in the baseconstructor to gracefully intercept and report unsupported parameters, significantly improving Developer Experience (DX).
- Introduced dynamic `self.log_prefix` (`self.__class__.__name__`) for accurate and consistent logging across all subclasses.
- Cleaned up redundant state-clearing, image-count logic and hardcoded print statements across subclass `__call__` implementations.
- To avoid exceptions occurring when the close method is called due to initialization failure and the call to exit_stack.1 parent 00da436 commit 8b29b88
3 files changed
Lines changed: 129 additions & 121 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
386 | 388 | | |
387 | 389 | | |
388 | 390 | | |
| 391 | + | |
389 | 392 | | |
390 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
391 | 396 | | |
392 | 397 | | |
393 | 398 | | |
| |||
662 | 667 | | |
663 | 668 | | |
664 | 669 | | |
665 | | - | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
666 | 673 | | |
667 | 674 | | |
668 | 675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
686 | 688 | | |
687 | 689 | | |
688 | 690 | | |
| |||
0 commit comments