Files
xc-llm-ascend/tools/send_request.py
SILONG ZENG 523e83016b [Lint]Style: Convert root, benchmarks, tools and docs to ruff format (#5843)
### What this PR does / why we need it?
Description
This PR fixes linting issues in the root directory, benchmarks/, tools/
and docs/ to align with the project's Ruff configuration.

This is part of a gradual effort to enable full linting coverage across
the repository. The corresponding paths have been removed from the
exclude list in pyproject.toml.

### Does this PR introduce _any_ user-facing change?

### How was this patch tested?

- vLLM version: v0.13.0
- vLLM main:
2f4e6548ef

---------

Signed-off-by: root <root@LAPTOP-VQKDDVMG.localdomain>
Co-authored-by: root <root@LAPTOP-VQKDDVMG.localdomain>
2026-01-13 15:29:34 +08:00

40 lines
1.3 KiB
Python

from typing import Any
import requests
def send_v1_completions(prompt, model, server, request_args=None):
data: dict[str, Any] = {"model": model, "prompt": prompt}
if request_args:
data.update(request_args)
url = server.url_for("v1", "completions")
response = requests.post(url, json=data)
print(f"Status Code: {response.status_code}")
response_json = response.json()
print(f"Response json: {response_json}")
response_text = response_json["choices"][0]["text"]
print(f"Response: {response_text}")
assert response_text, "empty response"
def send_v1_chat_completions(prompt, model, server, request_args=None):
data: dict[str, Any] = {
"model": model,
"messages": [
{
"role": "user",
"content": prompt,
}
],
}
if request_args:
data.update(request_args)
url = server.url_for("v1", "chat", "completions")
response = requests.post(url, json=data)
print(f"Status Code: {response.status_code}")
response_json = response.json()
print(f"Response json: {response_json}")
response_text = response_json["choices"][0]["message"]["content"]
print(f"Response: {response_text}")
assert response_text, "empty response"