Skip to content

Commit

Permalink
Prevent sending message / running tasks when no input
Browse files Browse the repository at this point in the history
  • Loading branch information
vietanhdev committed Sep 30, 2024
1 parent 751e0a9 commit 7cf9fb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion llama_assistant/llama_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"},
]
Expand Down

0 comments on commit 7cf9fb1

Please sign in to comment.