Skip to content

[Frontend] add --quick option for vllm chat/complete #18297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2025
Merged
Changes from 3 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
29 changes: 29 additions & 0 deletions vllm/entrypoints/cli/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,18 @@ def cmd(args: argparse.Namespace) -> None:
model_name, client = _interactive_cli(args)
system_prompt = args.system_prompt
conversation: list[ChatCompletionMessageParam] = []

if system_prompt is not None:
conversation.append({"role": "system", "content": system_prompt})

if args.quick_chat:
conversation.append({"role": "user", "content": args.quick_chat})

chat_completion = client.chat.completions.create(
model=model_name, messages=conversation)
print(chat_completion.choices[0].message.content)
return

print("Please enter a message for the chat model:")
while True:
try:
Expand Down Expand Up @@ -136,6 +145,12 @@ def subparser_init(
default=None,
help=("The system prompt to be added to the chat template, "
"used for models that support system prompts."))
chat_parser.add_argument("-q",
"--quick",
type=str,
metavar="MESSAGE",
help=("Send a single prompt as MESSAGE "
"and print the response, then exit."))
return chat_parser


Expand All @@ -149,6 +164,13 @@ def __init__(self):
@staticmethod
def cmd(args: argparse.Namespace) -> None:
model_name, client = _interactive_cli(args)

if args.quick_complete:
completion = client.completions.create(model=model_name,
prompt=args.quick_complete)
print(completion.choices[0].text)
return

print("Please enter prompt to complete:")
while True:
input_prompt = input("> ")
Expand All @@ -168,6 +190,13 @@ def subparser_init(
"via the running API server."),
usage="vllm complete [options]")
_add_query_options(complete_parser)
complete_parser.add_argument(
"-q",
"--quick",
type=str,
metavar="PROMPT",
help=
"Send a single prompt and print the completion output, then exit.")
return complete_parser


Expand Down