From 7cf9fb1ab7411c5f0b57a3843c79084bd0e9a24b Mon Sep 17 00:00:00 2001 From: Viet-Anh Nguyen Date: Mon, 30 Sep 2024 23:09:26 +0700 Subject: [PATCH] Prevent sending message / running tasks when no input --- llama_assistant/llama_assistant.py | 11 ++++++++++- pyproject.toml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/llama_assistant/llama_assistant.py b/llama_assistant/llama_assistant.py index 9bdaa89..018f9d8 100644 --- a/llama_assistant/llama_assistant.py +++ b/llama_assistant/llama_assistant.py @@ -378,9 +378,16 @@ def init_ui(self): self.esc_shortcut.activated.connect(self.hide) def on_task_button_clicked(self): + message = self.input_field.toPlainText() + if message == "": + # Show a message box if the input field is empty + msg = QMessageBox() + msg.setText("Please enter a message first.") + msg.setWindowTitle("No Input") + msg.exec() + return sender = self.sender() task = sender.text().lower() - message = self.input_field.toPlainText() self.input_field.clear() self.process_text(message, task) @@ -486,6 +493,8 @@ def toggle_visibility(self): def on_submit(self): message = self.input_field.toPlainText() + if message == "": + return self.input_field.clear() if message == "cls" or message == "clear": diff --git a/pyproject.toml b/pyproject.toml index a3f6160..992ac5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "llama-assistant" -version = "0.1.23" +version = "0.1.24" authors = [ {name = "Viet-Anh Nguyen", email = "vietanh.dev@gmail.com"}, ]