From 6f83147972f056cff44eb64fa4434c7a1ad89260 Mon Sep 17 00:00:00 2001 From: Onur ULUSOY Date: Fri, 21 Jun 2024 01:00:56 +0300 Subject: [PATCH] feat: Added on of off option for cintinuously conversations (#179) --- .../gpt_computer_assistant.py | 2 +- gpt_computer_assistant/gui/settings.py | 24 +++++++++++++++++ gpt_computer_assistant/utils/db.py | 27 +++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/gpt_computer_assistant/gpt_computer_assistant.py b/gpt_computer_assistant/gpt_computer_assistant.py index f564c137a..ac392f280 100644 --- a/gpt_computer_assistant/gpt_computer_assistant.py +++ b/gpt_computer_assistant/gpt_computer_assistant.py @@ -888,7 +888,7 @@ def update_state(self, new_state): if assistant_stopped: if llm_settings[load_model_settings()]["transcription"]: global the_input_box - if the_input_box.toPlainText().endswith("?"): + if the_input_box.toPlainText().endswith("?") and is_continuously_conversations_setting_active(): self.button_handler.toggle_recording(no_screenshot=True, new_record=True) def pulse_circle(self): diff --git a/gpt_computer_assistant/gui/settings.py b/gpt_computer_assistant/gui/settings.py index cd0c50467..8679ea567 100644 --- a/gpt_computer_assistant/gui/settings.py +++ b/gpt_computer_assistant/gui/settings.py @@ -325,4 +325,28 @@ def activate_auto_stop_recording_(): wake_word_screen_button.clicked.connect(activate_auto_stop_recording_) + + + continuously_conversations_button = QPushButton("Enable Continuously Conversations") + + settings_dialog.layout().addWidget(continuously_conversations_button) + + if is_continuously_conversations_setting_active(): + continuously_conversations_button.setText("Disable Continuously Conversations") + + def deactivate_auto_stop_recording_(): + deactivate_continuously_conversations_setting() + the_main_window.update_from_thread("Disabled Continuously Conversations") + settings_dialog.close() + + continuously_conversations_button.clicked.connect(deactivate_auto_stop_recording_) + else: + + def activate_auto_stop_recording_(): + activate_continuously_conversations_setting() + the_main_window.update_from_thread("Enabled Continuously Conversations") + settings_dialog.close() + + continuously_conversations_button.clicked.connect(activate_auto_stop_recording_) + settings_dialog.exec_() diff --git a/gpt_computer_assistant/utils/db.py b/gpt_computer_assistant/utils/db.py index 2dd129f76..d55ad384b 100644 --- a/gpt_computer_assistant/utils/db.py +++ b/gpt_computer_assistant/utils/db.py @@ -399,4 +399,31 @@ def is_wake_word_screen_setting_active(): if not os.path.exists(wake_word_screen_setting): return True with open(wake_word_screen_setting, "r") as f: + return f.read() == "1" + + + + + + +continuously_conversations_setting = os.path.join(artifacts_dir, "continuously_conversations_setting.db") + + +def activate_continuously_conversations_setting(): + """Activate the continuously_conversations setting.""" + with open(continuously_conversations_setting, "w") as f: + f.write("1") + + +def deactivate_continuously_conversations_setting(): + """Deactivate the continuously_conversations setting.""" + with open(continuously_conversations_setting, "w") as f: + f.write("0") + + +def is_continuously_conversations_setting_active(): + """Check if the continuously_conversations setting is active.""" + if not os.path.exists(continuously_conversations_setting): + return False + with open(continuously_conversations_setting, "r") as f: return f.read() == "1" \ No newline at end of file