main
py 45 lines 1.47 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 from dataclasses import dataclass
4 from typing import TypeAlias
5
6 from typing_extensions import Required, TypedDict
7
8 from vllm.entrypoints.chat_utils import (
9 ChatCompletionContentPartImageEmbedsParam,
10 ChatCompletionContentPartImageParam,
11 ChatCompletionContentPartTextParam,
12 ChatCompletionContentPartVideoParam,
13 )
14
15 ScoreContentPartParam: TypeAlias = (
16 ChatCompletionContentPartImageParam
17 | ChatCompletionContentPartImageEmbedsParam
18 | ChatCompletionContentPartTextParam
19 | ChatCompletionContentPartVideoParam
20 )
21
22
23 class ScoreMultiModalParam(TypedDict, total=False):
24 """A specialized parameter type for scoring multimodal content.
25
26 The reasons why don't reuse `CustomChatCompletionMessageParam` directly:
27 1. Score tasks don't need the 'role' field (user/assistant/system) that's required in chat completions
28 2. Including chat-specific fields would confuse users about their purpose in scoring
29 3. This is a more focused interface that only exposes what's needed for scoring
30 """ # noqa: E501
31
32 content: Required[list[ScoreContentPartParam]]
33 """The multimodal contents"""
34
35
36 # Raw input data with content key in ScoreMultiModalParam.
37 ScoreInput = str | ScoreMultiModalParam
38 # Score data without content key.
39 ScoreData = str | list[ScoreContentPartParam]
40
41
42 @dataclass
43 class ScoringData:
44 data_1: list[ScoreData]
45 data_2: list[ScoreData]