Added back support for creating models
This commit is contained in:
parent
80d1149932
commit
01b38fa37a
@ -472,10 +472,11 @@ class model_manager_container(Gtk.Box):
|
||||
def change_model(self, model_name:str):
|
||||
self.model_selector.change_model(model_name)
|
||||
|
||||
#threading.Thread(target=self.pulling_list.pull_model, args=(url, model_name, modelfile)).start()
|
||||
#Important: Call this using a thread, if not the app crashes
|
||||
def pull_model(self, url:str, model_name:str, modelfile:str=None): ##TODO, once you make an instance manager remove the url from this
|
||||
if ':' in model_name and model_name not in [model.get_name() for model in list(self.pulling_list)]:
|
||||
if ':' not in model_name:
|
||||
model_name += ':latest'
|
||||
if model_name not in [model.get_name() for model in list(self.pulling_list)] and model_name not in [model.get_name() for model in list(self.local_list)]:
|
||||
logger.info("Pulling model: {}".format(model_name))
|
||||
model = pulling_model(model_name)
|
||||
self.pulling_list.append(model)
|
||||
@ -489,14 +490,14 @@ class model_manager_container(Gtk.Box):
|
||||
|
||||
if response.status_code == 200 and not model.error:
|
||||
GLib.idle_add(window.show_notification, _("Task Complete"), _("Model '{}' pulled successfully.").format(model_name), Gio.ThemedIcon.new("emblem-ok-symbolic"))
|
||||
GLib.idle_add(window.show_toast, _("Model '{}' pulled successfully.").format(model), window.manage_models_overlay)
|
||||
GLib.idle_add(window.show_toast, _("Model '{}' pulled successfully.").format(model_name), window.manage_models_overlay)
|
||||
self.add_local_model(model_name)
|
||||
elif response.status_code == 200:
|
||||
GLib.idle_add(window.show_notification, _("Pull Model Error"), _("Failed to pull model '{}': {}").format(model_name, model.error), Gio.ThemedIcon.new("dialog-error-symbolic"))
|
||||
GLib.idle_add(window.show_toast, _("Error pulling '{}': {}").format(model, model.error), window.manage_models_overlay)
|
||||
GLib.idle_add(window.show_toast, _("Error pulling '{}': {}").format(model_name, model.error), window.manage_models_overlay)
|
||||
else:
|
||||
GLib.idle_add(window.show_notification, _("Pull Model Error"), _("Failed to pull model '{}' due to network error.").format(model_name), Gio.ThemedIcon.new("dialog-error-symbolic"))
|
||||
GLib.idle_add(window.show_toast, _("Error pulling '{}'").format(model), window.manage_models_overlay)
|
||||
GLib.idle_add(window.show_toast, _("Error pulling '{}'").format(model_name), window.manage_models_overlay)
|
||||
GLib.idle_add(window.manage_models_dialog.close)
|
||||
GLib.idle_add(window.connection_error)
|
||||
|
||||
|
@ -236,7 +236,7 @@ def create_model_from_existing_response(self, dialog, task, dropdown):
|
||||
|
||||
def create_model_from_existing(self):
|
||||
string_list = Gtk.StringList()
|
||||
for model in self.local_models:
|
||||
for model in self.model_manager.get_model_list():
|
||||
string_list.append(self.convert_model_name(model, 0))
|
||||
|
||||
dropdown = Gtk.DropDown()
|
||||
|
@ -62,7 +62,6 @@ class AlpacaWindow(Adw.ApplicationWindow):
|
||||
pulling_models = {}
|
||||
attachments = {}
|
||||
header_bar = Gtk.Template.Child()
|
||||
model_selector = None
|
||||
|
||||
#Override elements
|
||||
override_HSA_OVERRIDE_GFX_VERSION = Gtk.Template.Child()
|
||||
@ -147,7 +146,7 @@ class AlpacaWindow(Adw.ApplicationWindow):
|
||||
|
||||
self.chat_list_box.send_tab_to_top(self.chat_list_box.get_selected_row())
|
||||
|
||||
current_model = self.model_selector.get_model()
|
||||
current_model = self.model_manager.get_selected_model()
|
||||
if current_model is None:
|
||||
self.show_toast(_("Please select a model before chatting"), self.main_overlay)
|
||||
return
|
||||
@ -282,34 +281,8 @@ class AlpacaWindow(Adw.ApplicationWindow):
|
||||
for line in modelfile_raw.split('\n'):
|
||||
if not line.startswith('SYSTEM') and not line.startswith('FROM'):
|
||||
modelfile.append(line)
|
||||
#self.pulling_model_list_box.set_visible(True)
|
||||
model_row = Adw.ActionRow(
|
||||
title = name
|
||||
)
|
||||
thread = threading.Thread(target=self.pull_model_process, kwargs={"model": name, "modelfile": '\n'.join(modelfile)})
|
||||
overlay = Gtk.Overlay()
|
||||
progress_bar = Gtk.ProgressBar(
|
||||
valign = 2,
|
||||
show_text = False,
|
||||
margin_start = 10,
|
||||
margin_end = 10,
|
||||
css_classes = ["osd", "horizontal", "bottom"]
|
||||
)
|
||||
button = Gtk.Button(
|
||||
icon_name = "media-playback-stop-symbolic",
|
||||
vexpand = False,
|
||||
valign = 3,
|
||||
css_classes = ["error"],
|
||||
tooltip_text = _("Stop Creating '{}'").format(name)
|
||||
)
|
||||
button.connect("clicked", lambda button, model_name=name : dialogs.stop_pull_model(self, model_name))
|
||||
model_row.add_suffix(button)
|
||||
self.pulling_models[name] = {"row": model_row, "progress_bar": progress_bar, "overlay": overlay}
|
||||
overlay.set_child(model_row)
|
||||
overlay.add_overlay(progress_bar)
|
||||
#self.pulling_model_list_box.append(overlay)
|
||||
threading.Thread(target=self.model_manager.pull_model, kwargs={"url": connection_handler.URL, "model_name": name, "modelfile": '\n'.join(modelfile)}).start()
|
||||
self.navigation_view_manage_models.pop()
|
||||
thread.start()
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def override_changed(self, entry):
|
||||
@ -351,7 +324,7 @@ class AlpacaWindow(Adw.ApplicationWindow):
|
||||
|
||||
def verify_if_image_can_be_used(self):
|
||||
logger.debug("Verifying if image can be used")
|
||||
selected = self.model_selector.get_model()
|
||||
selected = self.model_manager.get_selected_model()
|
||||
if selected == None:
|
||||
return True
|
||||
selected = selected.split(":")[0]
|
||||
@ -501,7 +474,7 @@ Generate a title following these rules:
|
||||
```PROMPT
|
||||
{message['content']}
|
||||
```"""
|
||||
current_model = self.model_selector.get_model()
|
||||
current_model = self.model_manager.get_selected_model()
|
||||
data = {"model": current_model, "prompt": prompt, "stream": False}
|
||||
if 'images' in message:
|
||||
data["images"] = message['images']
|
||||
|
Loading…
x
Reference in New Issue
Block a user