Skip to content
Merged
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
25 changes: 19 additions & 6 deletions src/vllm_router/services/request_service/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,11 @@ async def route_general_request(
else:
endpoints = list(
filter(
lambda x: requested_model in x.model_names
and x.Id == request_endpoint
and not x.sleep,
lambda x: (
requested_model in x.model_names
and x.Id == request_endpoint
and not x.sleep
),
endpoints,
)
)
Expand Down Expand Up @@ -1064,21 +1066,32 @@ async def route_sleep_wakeup_request(

url = server_url + endpoint

# Forward any additional query parameters (e.g. /sleep `level` and `mode`,
# /wake_up `tags`) to the upstream engine. `id` is router-only and is
# consumed above to pick the target engine.
upstream_params = {k: v for k, v in request.query_params.items() if k != "id"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a dictionary comprehension upstream_params = {k: v for k, v in request.query_params.items() if k != "id"} will drop duplicate query parameters (e.g., if multiple tags are provided like ?tags=a&tags=b, only the last one tags=b will be preserved). Since aiohttp supports a sequence of key-value tuples for the params argument, we can use a list comprehension with request.query_params.multi_items() to preserve all multi-valued query parameters.

Suggested change
upstream_params = {k: v for k, v in request.query_params.items() if k != "id"}
upstream_params = [(k, v) for k, v in request.query_params.multi_items() if k != "id"]


async with aiohttp.ClientSession() as client:
if endpoint == "/is_sleeping":
async with client.get(url, headers=headers) as response:
async with client.get(
url, headers=headers, params=upstream_params
) as response:
response.raise_for_status()
return await response.json()
else:
request_body = await request.body()
response_status = None
if request_body:
req_data = json.loads(request_body)
async with client.post(url, json=req_data, headers=headers) as response:
async with client.post(
url, json=req_data, headers=headers, params=upstream_params
) as response:
response.raise_for_status()
response_status = response.status
else:
async with client.post(url, headers=headers) as response:
async with client.post(
url, headers=headers, params=upstream_params
) as response:
response.raise_for_status()
response_status = response.status

Expand Down
Loading