Skip to content

Commit

Permalink
simpler - just assign methods in init
Browse files Browse the repository at this point in the history
Signed-off-by: Tomer Asida <[email protected]>
  • Loading branch information
tomeras91 committed Nov 25, 2024
1 parent 5f2164a commit dd01b53
Showing 1 changed file with 4 additions and 45 deletions.
49 changes: 4 additions & 45 deletions vllm/entrypoints/openai/serving_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def __init__(
self.request_logger = request_logger
self.return_tokens_as_token_ids = return_tokens_as_token_ids

self._tokenize_prompt_input_async = make_async(self._tokenize_prompt_input)

Check failure on line 143 in vllm/entrypoints/openai/serving_engine.py

View workflow job for this annotation

GitHub Actions / ruff (3.12)

Ruff (E501)

vllm/entrypoints/openai/serving_engine.py:143:81: E501 Line too long (83 > 80)
self._tokenize_prompt_inputs_async = make_async(self._tokenize_prompt_inputs)

Check failure on line 144 in vllm/entrypoints/openai/serving_engine.py

View workflow job for this annotation

GitHub Actions / ruff (3.12)

Ruff (E501)

vllm/entrypoints/openai/serving_engine.py:144:81: E501 Line too long (85 > 80)
self._tokenize_prompt_input_or_inputs_async = make_async(self._tokenize_prompt_input_or_inputs)

Check failure on line 145 in vllm/entrypoints/openai/serving_engine.py

View workflow job for this annotation

GitHub Actions / ruff (3.12)

Ruff (E501)

vllm/entrypoints/openai/serving_engine.py:145:81: E501 Line too long (103 > 80)

async def show_available_models(self) -> ModelList:
"""Show available models. Right now we only have one model."""
model_cards = [
Expand Down Expand Up @@ -397,51 +401,6 @@ def _tokenize_prompt_input_or_inputs(
truncate_prompt_tokens=truncate_prompt_tokens,
)

async def _tokenize_prompt_input_async(
self,
request: AnyRequest,
tokenizer: AnyTokenizer,
prompt_input: Union[str, List[int]],
truncate_prompt_tokens: Optional[Annotated[int, Field(ge=1)]] = None,
add_special_tokens: bool = True,
) -> TextTokensPrompt:
return await make_async(self._tokenize_prompt_input)(
request=request,
tokenizer=tokenizer,
prompt_input=prompt_input,
truncate_prompt_tokens=truncate_prompt_tokens,
add_special_tokens=add_special_tokens)

async def _tokenize_prompt_inputs_async(
self,
request: AnyRequest,
tokenizer: AnyTokenizer,
prompt_inputs: Iterable[Union[str, List[int]]],
truncate_prompt_tokens: Optional[Annotated[int, Field(ge=1)]] = None,
add_special_tokens: bool = True,
) -> Iterator[TextTokensPrompt]:
return await make_async(self._tokenize_prompt_inputs)(
request=request,
tokenizer=tokenizer,
prompt_inputs=prompt_inputs,
truncate_prompt_tokens=truncate_prompt_tokens,
add_special_tokens=add_special_tokens)

async def _tokenize_prompt_input_or_inputs_async(
self,
request: AnyRequest,
tokenizer: AnyTokenizer,
input_or_inputs: Union[str, List[str], List[int], List[List[int]]],
truncate_prompt_tokens: Optional[Annotated[int, Field(ge=1)]] = None,
add_special_tokens: bool = True,
) -> Iterator[TextTokensPrompt]:
return await make_async(self._tokenize_prompt_input_or_inputs)(
request=request,
tokenizer=tokenizer,
input_or_inputs=input_or_inputs,
truncate_prompt_tokens=truncate_prompt_tokens,
add_special_tokens=add_special_tokens)

async def _preprocess_completion(
self,
request: CompletionLikeRequest,
Expand Down

0 comments on commit dd01b53

Please sign in to comment.