main
py 42 lines 1.32 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 from typing import TYPE_CHECKING
4
5 from vllm.config import ModelConfig
6 from vllm.tasks import SupportedTask
7
8 if TYPE_CHECKING:
9 from vllm.entrypoints.serve.sagemaker.api_router import (
10 EndpointFn,
11 GetHandlerFn,
12 RequestType,
13 )
14
15
16 def get_generate_invocation_types(
17 supported_tasks: tuple["SupportedTask", ...],
18 model_config: ModelConfig | None = None,
19 ):
20 # NOTE: Items defined earlier take higher priority
21 invocation_types: list[tuple[RequestType, tuple[GetHandlerFn, EndpointFn]]] = []
22
23 if "generate" in supported_tasks:
24 from vllm.entrypoints.openai.chat_completion.api_router import (
25 chat,
26 create_chat_completion,
27 )
28 from vllm.entrypoints.openai.chat_completion.protocol import (
29 ChatCompletionRequest,
30 )
31 from vllm.entrypoints.openai.completion.api_router import (
32 completion,
33 create_completion,
34 )
35 from vllm.entrypoints.openai.completion.protocol import CompletionRequest
36
37 invocation_types += [
38 (ChatCompletionRequest, (chat, create_chat_completion)),
39 (CompletionRequest, (completion, create_completion)),
40 ]
41
42 return invocation_types