New pull model menu

This commit is contained in:
jeffser 2024-06-25 23:32:09 -06:00
parent ce3dce4c67
commit ade0b3735e
4 changed files with 100 additions and 69 deletions

View File

@ -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"
]

View File

@ -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):

View File

@ -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)

View File

@ -473,7 +473,7 @@
<object class="AdwHeaderBar">
<property name="title-widget">
<object class="AdwWindowTitle">
<property name="title" translatable="yes">Create model</property>
<property name="title" translatable="yes">Create Model</property>
</object>
</property>
</object>
@ -579,7 +579,7 @@
<child type="top">
<object class="AdwHeaderBar">
<child type="start">
<object class="GtkMenuButton">
<object class="GtkMenuButton" id="create_model_button">
<property name="primary">True</property>
<property name="icon-name">list-add-symbolic</property>
<property name="tooltip-text" translatable="yes">Create model</property>
@ -587,12 +587,19 @@
</object>
</child>
<property name="title-widget">
<object class="AdwWindowTitle">
<property name="title" translatable="yes">Manage models</property>
<object class="AdwWindowTitle" id="manage_models_title">
<property name="title" translatable="yes">Manage Models</property>
</object>
</property>
</object>
</child>
<child>
<object class= "AdwCarousel" id="manage_models_carousel">
<property name="halign">0</property>
<property name="valign">0</property>
<property name="allow-long-swipes">true</property>
<property name="allow-scroll-wheel">true</property>
<property name="spacing">12</property>
<child>
<object class="GtkScrolledWindow">
<property name="hexpand">true</property>
@ -636,6 +643,25 @@
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<child>
<object class="GtkListBox" id="model_tag_list_box">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="selection-mode">none</property>
<style>
<class name="boxed-list"/>
<class name="card"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>