feat: add benchmark serving (#657)

This commit is contained in:
zhyncs
2024-07-20 02:15:21 +10:00
committed by GitHub
parent ac971ff633
commit c126a6ccba
3 changed files with 660 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ from sglang.srt.openai_api_adapter import (
v1_chat_completions,
v1_completions,
)
from sglang.srt.openai_protocol import ModelCard, ModelList
from sglang.srt.server_args import PortArgs, ServerArgs
from sglang.srt.utils import (
API_KEY_HEADER_NAME,
@@ -73,6 +74,21 @@ async def health() -> Response:
return Response(status_code=200)
def get_model_list():
"""Available models."""
model_names = [tokenizer_manager.model_path]
return model_names
@app.get("/v1/models")
def available_models():
"""Show available models."""
model_cards = []
for model_name in get_model_list():
model_cards.append(ModelCard(id=model_name, root=model_name))
return ModelList(data=model_cards)
@app.get("/get_model_info")
async def get_model_info():
result = {