From ade0b3735eb330f3cef20751e24da2407a92d067 Mon Sep 17 00:00:00 2001 From: jeffser Date: Tue, 25 Jun 2024 23:32:09 -0600 Subject: [PATCH] New pull model menu --- com.jeffser.Alpaca.json | 8 ++-- src/dialogs.py | 30 -------------- src/window.py | 39 ++++++++++++++++- src/window.ui | 92 ++++++++++++++++++++++++++--------------- 4 files changed, 100 insertions(+), 69 deletions(-) diff --git a/com.jeffser.Alpaca.json b/com.jeffser.Alpaca.json index 67bbc84..8d98e8c 100644 --- a/com.jeffser.Alpaca.json +++ b/com.jeffser.Alpaca.json @@ -108,16 +108,16 @@ "sources": [ { "type": "file", - "url": "https://github.com/ollama/ollama/releases/download/v0.1.39/ollama-linux-amd64", - "sha256": "4d19be355842a6297c93ab5ada139fe396126736bf3c3882a879dc245dffe3af", + "url": "https://github.com/ollama/ollama/releases/download/v0.1.45/ollama-linux-amd64", + "sha256": "ddd21e38600958ecac8529b53015d49238a74b71e72f14d090a2f112cf169a69", "only-arches": [ "x86_64" ] }, { "type": "file", - "url": "https://github.com/ollama/ollama/releases/download/v0.1.39/ollama-linux-arm64", - "sha256": "60ec2d36928c11d6c6d84fe91451308a46aafaedbdba44664e5a6080009ce097", + "url": "https://github.com/ollama/ollama/releases/download/v0.1.45/ollama-linux-arm64", + "sha256": "423b9fee30a46ffd663b726fa85a1c8b7766f7fe5e5ec3b44e5813b619d3c3d8", "only-arches": [ "aarch64" ] diff --git a/src/dialogs.py b/src/dialogs.py index f9ae997..3f25dbd 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -143,36 +143,6 @@ def delete_model(self, model_name): callback = lambda dialog, task, model_name = model_name: delete_model_response(self, dialog, task, model_name) ) -# PULL MODEL | WORKS - -def pull_model_response(self, dialog, task, model_name, tag_drop_down): - if dialog.choose_finish(task) == "pull": - model = f"{model_name}:{tag_drop_down.get_selected_item().get_string().split(' | ')[0]}" - self.pull_model(model) - -def pull_model(self, model_name): - tag_list = Gtk.StringList() - for tag in self.available_models[model_name]['tags']: - tag_list.append(f"{tag[0]} | {tag[1]}") - tag_drop_down = Gtk.DropDown( - enable_search=True, - model=tag_list - ) - dialog = Adw.AlertDialog( - heading=_("Pull Model"), - body=_("Please select a tag to pull '{}'").format(model_name), - extra_child=tag_drop_down, - close_response="cancel" - ) - dialog.add_response("cancel", _("Cancel")) - dialog.add_response("pull", _("Pull")) - dialog.set_response_appearance("pull", Adw.ResponseAppearance.SUGGESTED) - dialog.choose( - parent = self.manage_models_dialog, - cancellable = None, - callback = lambda dialog, task, model_name = model_name, tag_drop_down = tag_drop_down: pull_model_response(self, dialog, task, model_name, tag_drop_down) - ) - # REMOVE IMAGE | WORKS def remove_attached_file_response(self, dialog, task, button): diff --git a/src/window.py b/src/window.py index 2a343c9..450b66d 100644 --- a/src/window.py +++ b/src/window.py @@ -98,6 +98,10 @@ class AlpacaWindow(Adw.ApplicationWindow): model_drop_down = Gtk.Template.Child() model_string_list = Gtk.Template.Child() chat_right_click_menu = Gtk.Template.Child() + model_tag_list_box = Gtk.Template.Child() + manage_models_carousel = Gtk.Template.Child() + manage_models_title = Gtk.Template.Child() + create_model_button = Gtk.Template.Child() manage_models_dialog = Gtk.Template.Child() pulling_model_list_box = Gtk.Template.Child() @@ -234,6 +238,9 @@ class AlpacaWindow(Adw.ApplicationWindow): @Gtk.Template.Callback() def manage_models_button_activate(self, button=None): + self.manage_models_carousel.scroll_to(self.manage_models_carousel.get_nth_page(0), False) + self.manage_models_title.set_title(_("Manage Models")) + self.create_model_button.set_visible(True) self.update_list_local_models() self.manage_models_dialog.present(self) @@ -859,6 +866,34 @@ class AlpacaWindow(Adw.ApplicationWindow): self.pulling_model_list_box.append(overlay) thread.start() + def confirm_pull_model(self, model_name): + self.manage_models_title.set_title(_("Manage Models")) + self.create_model_button.set_visible(True) + self.manage_models_carousel.scroll_to(self.manage_models_carousel.get_nth_page(0), True) + self.pull_model(model_name) + + def list_available_model_tags(self, model_name): + self.manage_models_title.set_title(model_name) + self.create_model_button.set_visible(False) + self.model_tag_list_box.remove_all() + tags = self.available_models[model_name]['tags'] + for tag_data in tags: + if f"{model_name}:{tag_data[0]}" not in self.local_models: + tag_row = Adw.ActionRow( + title = tag_data[0], + subtitle = tag_data[1] + ) + pull_button = Gtk.Button( + icon_name = "folder-download-symbolic", + vexpand = False, + valign = 3, + tooltip_text = _("Pull '{} ({})'").format(model_name, tag_data[0]) + ) + pull_button.connect("clicked", lambda button, model_name=f"{model_name}:{tag_data[0]}" : self.confirm_pull_model(model_name)) + tag_row.add_suffix(pull_button) + self.model_tag_list_box.append(tag_row) + self.manage_models_carousel.scroll_to(self.manage_models_carousel.get_nth_page(1), True) + def update_list_available_models(self): self.available_model_list_box.remove_all() for name, model_info in self.available_models.items(): @@ -870,7 +905,7 @@ class AlpacaWindow(Adw.ApplicationWindow): icon_name = "globe-symbolic", vexpand = False, valign = 3, - tooltip_text = _("Visit '{}' website").format(name) + tooltip_text = model_info["url"] ) pull_button = Gtk.Button( icon_name = "folder-download-symbolic", @@ -879,7 +914,7 @@ class AlpacaWindow(Adw.ApplicationWindow): tooltip_text = _("Pull '{}'").format(name) ) link_button.connect("clicked", lambda button=link_button, link=model_info["url"]: webbrowser.open(link)) - pull_button.connect("clicked", lambda button=pull_button, model_name=name: dialogs.pull_model(self, model_name)) + pull_button.connect("clicked", lambda button=pull_button, model_name=name: self.list_available_model_tags(model_name)) model.add_suffix(link_button) model.add_suffix(pull_button) self.available_model_list_box.append(model) diff --git a/src/window.ui b/src/window.ui index 5bfd03b..65a9869 100644 --- a/src/window.ui +++ b/src/window.ui @@ -473,7 +473,7 @@ - Create model + Create Model @@ -579,7 +579,7 @@ - + True list-add-symbolic Create model @@ -587,27 +587,70 @@ - - Manage models + + Manage Models - - true - true + + 0 + 0 + true + true + 12 - - 12 - 12 - 12 - 12 - 1 - 12 + + true + true - - false + + 12 + 12 + 12 + 12 + 1 + 12 + + + false + none + + + + + + none + + + + + + none + + + + + + + + + + + + 12 + 12 + 12 + 12 none - - - none - - - - - - none - - -