This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
forked from vllm-project/vllm
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/async chat serving (vllm-project#2727)
- Loading branch information
1 parent
f10844f
commit e132240
Showing
5 changed files
with
72 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import asyncio | ||
from dataclasses import dataclass | ||
|
||
from vllm.entrypoints.openai.serving_chat import OpenAIServingChat | ||
|
||
MODEL_NAME = "openai-community/gpt2" | ||
CHAT_TEMPLATE = "Dummy chat template for testing {}" | ||
|
||
|
||
@dataclass | ||
class MockModelConfig: | ||
tokenizer = MODEL_NAME | ||
trust_remote_code = False | ||
tokenizer_mode = "auto" | ||
max_model_len = 100 | ||
tokenizer_revision = None | ||
|
||
|
||
@dataclass | ||
class MockEngine: | ||
|
||
async def get_model_config(self): | ||
return MockModelConfig | ||
|
||
|
||
async def _async_serving_chat_init(): | ||
serving_completion = OpenAIServingChat(MockEngine(), | ||
served_model_names=[MODEL_NAME], | ||
response_role="assistant", | ||
chat_template=CHAT_TEMPLATE) | ||
return serving_completion | ||
|
||
|
||
def test_async_serving_chat_init(): | ||
serving_completion = asyncio.run(_async_serving_chat_init()) | ||
assert serving_completion.tokenizer is not None | ||
assert serving_completion.tokenizer.chat_template == CHAT_TEMPLATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters