|
17 | 17 | from __future__ import annotations |
18 | 18 |
|
19 | 19 | import time |
| 20 | +import traceback |
20 | 21 | from dataclasses import asdict, dataclass, fields |
21 | 22 | from enum import Enum |
22 | 23 | from typing import Any, Dict, Generic, Optional, Union |
23 | 24 |
|
24 | 25 | import numpy as np |
25 | 26 | from typing_extensions import TypeVar |
26 | 27 |
|
27 | | -from fastdeploy import envs |
28 | 28 | from fastdeploy.engine.pooling_params import PoolingParams |
29 | 29 | from fastdeploy.engine.sampling_params import SamplingParams |
30 | 30 | from fastdeploy.entrypoints.openai.protocol import ToolCall |
@@ -190,6 +190,22 @@ def from_dict(cls, d: dict): |
190 | 190 | pooling_params = PoolingParams.from_dict(d["pooling_params"]) |
191 | 191 | else: |
192 | 192 | sampling_params = SamplingParams.from_dict(d) |
| 193 | + if ( |
| 194 | + isinstance(d.get("multimodal_inputs"), dict) |
| 195 | + and isinstance(d["multimodal_inputs"].get("mm_positions"), list) |
| 196 | + and len(d["multimodal_inputs"]["mm_positions"]) > 0 |
| 197 | + ): |
| 198 | + # if mm_positions is not of type ImagePosition, convert to ImagePosition |
| 199 | + try: |
| 200 | + for i, mm_pos in enumerate(d["multimodal_inputs"]["mm_positions"]): |
| 201 | + d["multimodal_inputs"]["mm_positions"][i] = ( |
| 202 | + ImagePosition(**mm_pos) if not isinstance(mm_pos, ImagePosition) else mm_pos |
| 203 | + ) |
| 204 | + except Exception as e: |
| 205 | + data_processor_logger.error( |
| 206 | + f"Convert mm_positions to ImagePosition error: {e}, {str(traceback.format_exc())}" |
| 207 | + ) |
| 208 | + |
193 | 209 | return cls( |
194 | 210 | request_id=d["request_id"], |
195 | 211 | prompt=d.get("prompt"), |
|
0 commit comments