From 2c7fa47161ba513817a80e165c86a66760c06ebb Mon Sep 17 00:00:00 2001 From: Reid <61492567+reidliu41@users.noreply.github.com> Date: Mon, 14 Jul 2025 15:09:57 +0800 Subject: [PATCH] Fix: Add missing EOFError handling in CLI complete command (#20896) Signed-off-by: reidliu41 --- vllm/entrypoints/cli/openai.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vllm/entrypoints/cli/openai.py b/vllm/entrypoints/cli/openai.py index 5ddaee5b52af1..e71f77ba80673 100644 --- a/vllm/entrypoints/cli/openai.py +++ b/vllm/entrypoints/cli/openai.py @@ -55,7 +55,7 @@ def chat(system_prompt: str | None, model_name: str, client: OpenAI) -> None: try: input_message = input("> ") except EOFError: - return + break conversation.append({"role": "user", "content": input_message}) chat_completion = client.chat.completions.create(model=model_name, @@ -118,7 +118,7 @@ class ChatCommand(CLISubcommand): try: input_message = input("> ") except EOFError: - return + break conversation.append({"role": "user", "content": input_message}) chat_completion = client.chat.completions.create( @@ -170,7 +170,10 @@ class CompleteCommand(CLISubcommand): print("Please enter prompt to complete:") while True: - input_prompt = input("> ") + try: + input_prompt = input("> ") + except EOFError: + break completion = client.completions.create(model=model_name, prompt=input_prompt) output = completion.choices[0].text