protocol.py 2.59 KB
Newer Older
1
from typing import (AsyncGenerator, List, Mapping, Optional, Protocol,
2
3
4
5
6
7
8
9
10
11
12
                    runtime_checkable)

from vllm.config import DecodingConfig, ModelConfig
from vllm.core.scheduler import SchedulerOutputs
from vllm.inputs.data import PromptInputs
from vllm.lora.request import LoRARequest
from vllm.outputs import EmbeddingRequestOutput, RequestOutput
from vllm.pooling_params import PoolingParams
from vllm.prompt_adapter.request import PromptAdapterRequest
from vllm.sampling_params import SamplingParams
from vllm.sequence import SamplerOutput
13
from vllm.transformers_utils.tokenizer import AnyTokenizer
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


@runtime_checkable
class AsyncEngineClient(Protocol):
    """Protocol class for Clients to AsyncLLMEngine"""

    @property
    def is_running(self) -> bool:
        ...

    @property
    def is_stopped(self) -> bool:
        ...

    @property
    def errored(self) -> bool:
        ...

32
    def generate(
33
34
35
36
37
38
39
        self,
        inputs: PromptInputs,
        sampling_params: SamplingParams,
        request_id: str,
        lora_request: Optional[LoRARequest] = None,
        trace_headers: Optional[Mapping[str, str]] = None,
        prompt_adapter_request: Optional[PromptAdapterRequest] = None
40
    ) -> AsyncGenerator[RequestOutput, None]:
41
        """Generates outputs for a request"""
42
        ...
43

44
    def encode(
45
46
47
48
49
50
        self,
        inputs: PromptInputs,
        pooling_params: PoolingParams,
        request_id: str,
        lora_request: Optional[LoRARequest] = None,
        trace_headers: Optional[Mapping[str, str]] = None,
51
    ) -> AsyncGenerator[EmbeddingRequestOutput, None]:
52
        """Generate outputs for a request from an embedding model."""
53
        ...
54
55
56
57
58
59
60
61
62
63

    async def abort(self, request_id: str) -> None:
        """Abort a request.

        Args:
            request_id: The unique id of the request.
        """

    async def get_model_config(self) -> ModelConfig:
        """Get the model configuration of the vLLM engine."""
64
        ...
65
66

    async def get_decoding_config(self) -> DecodingConfig:
67
        ...
68
69
70
71
72
        """Get the decoding configuration of the vLLM engine."""

    async def get_tokenizer(
        self,
        lora_request: Optional[LoRARequest] = None,
73
74
75
    ) -> AnyTokenizer:
        """Get the appropriate tokenizer for the request"""
        ...
76
77

    async def is_tracing_enabled(self) -> bool:
78
        ...
79
80
81
82
83
84

    async def do_log_stats(
        self,
        scheduler_outputs: Optional[SchedulerOutputs] = None,
        model_output: Optional[List[SamplerOutput]] = None,
    ) -> None:
85
        ...
86
87
88

    async def check_health(self) -> None:
        """Raise if unhealthy"""
89
        ...