Adding size to tags and adding progress bar to models that are being pulled

This commit is contained in:
jeffser 2024-05-27 17:27:05 -06:00
parent aa79368b54
commit 05461fb03a
3 changed files with 13 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -148,13 +148,13 @@ def delete_model(self, model_name):
def pull_model_response(self, dialog, task, model_name, tag_drop_down): def pull_model_response(self, dialog, task, model_name, tag_drop_down):
if dialog.choose_finish(task) == "pull": if dialog.choose_finish(task) == "pull":
model = f"{model_name}:{tag_drop_down.get_selected_item().get_string()}" model = f"{model_name}:{tag_drop_down.get_selected_item().get_string().split(' | ')[0]}"
self.pull_model(model) self.pull_model(model)
def pull_model(self, model_name): def pull_model(self, model_name):
tag_list = Gtk.StringList() tag_list = Gtk.StringList()
for tag in available_models[model_name]['tags']: for tag in available_models[model_name]['tags']:
tag_list.append(tag) tag_list.append(f"{tag[0]} | {tag[1]}")
tag_drop_down = Gtk.DropDown( tag_drop_down = Gtk.DropDown(
enable_search=True, enable_search=True,
model=tag_list model=tag_list

View File

@ -540,7 +540,9 @@ class AlpacaWindow(Adw.ApplicationWindow):
def pull_model_update(self, data, model_name): def pull_model_update(self, data, model_name):
if model_name in list(self.pulling_models.keys()): if model_name in list(self.pulling_models.keys()):
GLib.idle_add(self.pulling_models[model_name].set_subtitle, data['status'] + (f" | {round(data['completed'] / data['total'] * 100, 2)}%" if 'completed' in data and 'total' in data else "")) GLib.idle_add(self.pulling_models[model_name]['row'].set_subtitle, data['status'])
if 'completed' in data and 'total' in data: GLib.idle_add(self.pulling_models[model_name]['progress_bar'].set_fraction, (data['completed'] / data['total']))
else: GLib.idle_add(self.pulling_models[model_name]['progress_bar'].pulse)
else: else:
if len(list(self.pulling_models.keys())) == 0: if len(list(self.pulling_models.keys())) == 0:
GLib.idle_add(self.pulling_model_list_box.set_visible, False) GLib.idle_add(self.pulling_model_list_box.set_visible, False)
@ -577,7 +579,10 @@ class AlpacaWindow(Adw.ApplicationWindow):
title = model title = model
) )
thread = threading.Thread(target=self.pull_model_process, kwargs={"model": model}) thread = threading.Thread(target=self.pull_model_process, kwargs={"model": model})
self.pulling_models[model] = model_row progress_bar = Gtk.ProgressBar(
valign = 3,
show_text = True
)
button = Gtk.Button( button = Gtk.Button(
icon_name = "media-playback-stop-symbolic", icon_name = "media-playback-stop-symbolic",
vexpand = False, vexpand = False,
@ -585,7 +590,9 @@ class AlpacaWindow(Adw.ApplicationWindow):
css_classes = ["error"] css_classes = ["error"]
) )
button.connect("clicked", lambda button, model_name=model : dialogs.stop_pull_model(self, model_name)) button.connect("clicked", lambda button, model_name=model : dialogs.stop_pull_model(self, model_name))
model_row.add_suffix(progress_bar)
model_row.add_suffix(button) model_row.add_suffix(button)
self.pulling_models[model] = {"row": model_row, "progress_bar": progress_bar}
self.pulling_model_list_box.append(model_row) self.pulling_model_list_box.append(model_row)
thread.start() thread.start()
@ -699,12 +706,11 @@ class AlpacaWindow(Adw.ApplicationWindow):
def new_chat(self, chat_name): def new_chat(self, chat_name):
chat_name = self.generate_numbered_chat_name(chat_name) chat_name = self.generate_numbered_chat_name(chat_name)
self.chats["chats"][chat_name] = {"messages": []} self.chats["chats"][chat_name] = {"messages": []}
#self.chats["selected_chat"] = chat_name
self.save_history() self.save_history()
self.new_chat_element(chat_name, True) self.new_chat_element(chat_name, True)
def stop_pull_model(self, model_name): def stop_pull_model(self, model_name):
self.pulling_models[model_name].get_parent().remove(self.pulling_models[model_name]) self.pulling_models[model_name]['row'].get_parent().remove(self.pulling_models[model_name]['row'])
del self.pulling_models[model_name] del self.pulling_models[model_name]
def delete_model(self, model_name): def delete_model(self, model_name):