From 1b6e1d00feea961cd51a1a55e2a6ea8097ebd7ec Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Fri, 4 Oct 2024 18:17:01 +0700 Subject: [PATCH] fix: handle EOF (#1434) --- engine/commands/chat_completion_cmd.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/commands/chat_completion_cmd.cc b/engine/commands/chat_completion_cmd.cc index 8d06ce4bc..9929321ee 100644 --- a/engine/commands/chat_completion_cmd.cc +++ b/engine/commands/chat_completion_cmd.cc @@ -97,7 +97,9 @@ void ChatCompletionCmd::Exec(const std::string& host, int port, std::string user_input = std::move(msg); if (user_input.empty()) { std::cout << "> "; - std::getline(std::cin, user_input); + if (!std::getline(std::cin, user_input)) { + break; + } } if (user_input == kExitChat) { break;