fix: new chat

This commit is contained in:
0xMRTT 2023-08-11 18:39:12 +02:00
parent b438eb1077
commit c2002524fd
2 changed files with 18 additions and 9 deletions

View file

@ -144,7 +144,6 @@ class BavarderApplication(Adw.Application):
self.quit()
def on_new_chat_action(self, widget, _):
print("NEW CHAT")
chat_id = 0
for chat in self.data["chats"]:
if chat["id"] > chat_id:
@ -152,7 +151,7 @@ class BavarderApplication(Adw.Application):
chat_id += 1
chat = {
"id": chat_id,
"title": _("New Chat %i" % chat_id),
"title": "New Chat " + str(chat_id),
"starred": False,
"content": [],
}
@ -261,7 +260,7 @@ class BavarderApplication(Adw.Application):
if self.model_name not in self.models:
self.download_model(self.model_name)
self.model = GPT4All(self.model_name, model_path=model_path)
return True
return True
def download_model(self, model=None):
if model:

View file

@ -347,13 +347,17 @@ class BavarderWindow(Adw.ApplicationWindow):
GLib.idle_add(cleanup, response, self.toast)
def cleanup(response, toast):
self.t.join()
self.toast.dismiss()
try:
self.t.join()
self.toast.dismiss()
if not response:
response = _("Sorry, I don't know what to say.")
if not response:
response = _("Sorry, I don't know what to say.")
self.add_assistant_item(response)
self.add_assistant_item(response)
except AttributeError:
self.toast.dismiss()
self.add_assistant_item(_("Sorry, I don't know what to say."))
self.t = KillableThread(target=thread_run)
self.t.start()
@ -366,9 +370,15 @@ class BavarderWindow(Adw.ApplicationWindow):
try:
self.t.kill()
self.t.join()
del self.t
self.toast.dismiss()
except AttributeError: # nothing to stop
pass
print("Nothing to stop")
except SystemExit:
self.t.join()
del self.t
self.toast.dismiss()
def create_action(self, name, callback, shortcuts=None):
action = Gio.SimpleAction.new(name, None)