Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions vllm/entrypoints/scale_out/token_in_token_out/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from http import HTTPStatus

from fastapi import APIRouter, Depends, FastAPI, HTTPException, Request, Response
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse, StreamingResponse
from pydantic import ValidationError

from vllm.engine.protocol import EngineClient
from vllm.entrypoints.serve.tokenize.serving import ServingTokenization
Expand All @@ -20,6 +22,7 @@

from ...serve.engine.protocol import ErrorResponse
from .protocol import (
AbortRequestsRequest,
GenerateRequest,
GenerateResponseBase,
)
Expand Down Expand Up @@ -87,14 +90,17 @@ async def abort_requests(raw_request: Request):
status_code=HTTPStatus.BAD_REQUEST.value,
detail=f"JSON decode error: {e}",
) from e
request_ids = body.get("request_ids")
if request_ids is None:
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST.value,
detail="Missing 'request_ids' in request body",
)
# Validate the parsed body instead of declaring it as a FastAPI body param:
# FastAPI's strict content-type check would then reject clients that send
# no `Content-Type`, which the legacy `/abort_requests` path still allows.
try:
request = AbortRequestsRequest.model_validate(body)
except ValidationError as e:
raise RequestValidationError(
errors=[{**err, "loc": ("body", *err["loc"])} for err in e.errors()]
) from e
# Abort requests in background
asyncio.create_task(engine_client(raw_request).abort(request_ids))
asyncio.create_task(engine_client(raw_request).abort(request.request_ids))
return Response(status_code=200)


Expand Down
6 changes: 6 additions & 0 deletions vllm/entrypoints/scale_out/token_in_token_out/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ def output_mode_or_tokens(value: Any) -> Any:
]


class AbortRequestsRequest(BaseModel):
"""Request for the /inference/v1/abort_requests endpoint."""

request_ids: str | list[str]


class DerenderChatRequest(BaseModel):
"""Request for the /v1/chat/completions/derender endpoint (non-streaming).

Expand Down
Loading