Removed 'Featured models' from welcome dialog, added 'Open Model Manager' button in welcome screen if the user doesn't have models

This commit is contained in:
jeffser 2024-08-07 21:02:29 -06:00
parent d339a18901
commit 1477bacf6a
2 changed files with 23 additions and 160 deletions

View File

@ -307,18 +307,6 @@ class AlpacaWindow(Adw.ApplicationWindow):
entry.set_css_classes(["error"]) entry.set_css_classes(["error"])
self.show_toast(_("Failed to connect to server"), self.preferences_dialog) self.show_toast(_("Failed to connect to server"), self.preferences_dialog)
@Gtk.Template.Callback()
def pull_featured_model(self, button):
action_row = button.get_parent().get_parent().get_parent()
button.get_parent().remove(button)
model = f"{action_row.get_title().lower()}:latest"
action_row.set_subtitle(_("Pulling in the background..."))
spinner = Gtk.Spinner()
spinner.set_spinning(True)
action_row.add_suffix(spinner)
action_row.set_sensitive(False)
self.pull_model(model)
@Gtk.Template.Callback() @Gtk.Template.Callback()
def closing_app(self, user_data): def closing_app(self, user_data):
if self.get_hide_on_close(): if self.get_hide_on_close():
@ -1296,27 +1284,37 @@ Generate a title following these rules:
self.add_code_blocks() self.add_code_blocks()
self.bot_message = None self.bot_message = None
else: else:
possible_prompts = [ button_container = Gtk.Box(
"What can you do?",
"Give me a pancake recipe",
"Why is the sky blue?"
]
prompt_container = Gtk.Box(
orientation = 1, orientation = 1,
spacing = 10, spacing = 10,
halign = 3 halign = 3
) )
for prompt in random.sample(possible_prompts, 3): if len(self.local_models) > 0:
prompt_button = Gtk.Button( possible_prompts = [
label=prompt "What can you do?",
"Give me a pancake recipe",
"Why is the sky blue?"
]
for prompt in random.sample(possible_prompts, 3):
prompt_button = Gtk.Button(
label=prompt,
tooltip_text=_("Send prompt: '{}'").format(prompt)
)
prompt_button.connect('clicked', lambda *_, prompt=prompt : self.send_sample_prompt(prompt))
button_container.append(prompt_button)
else:
button = Gtk.Button(
label=_("Open Model Manager"),
tooltip_text=_("Open Model Manager"),
css_classes=["accent"]
) )
prompt_button.connect('clicked', lambda *_, prompt=prompt : self.send_sample_prompt(prompt)) button.connect('clicked', lambda *_ : self.manage_models_dialog.present(self))
prompt_container.append(prompt_button) button_container.append(button)
self.chat_welcome_screen = Adw.StatusPage( self.chat_welcome_screen = Adw.StatusPage(
icon_name="com.jeffser.Alpaca", icon_name="com.jeffser.Alpaca",
title="Alpaca", title="Alpaca",
description="Try one of these prompts", description=_("Try one of these prompts") if len(self.local_models) > 0 else _("It looks like you don't have any models downloaded yet. Download models to get started!"),
child=prompt_container, child=button_container,
vexpand=True vexpand=True
) )
self.chat_container.append(self.chat_welcome_screen) self.chat_container.append(self.chat_welcome_screen)

View File

@ -953,141 +953,6 @@
<property name="description" translatable="yes">Alpaca and its developers are not liable for any damages to devices or software resulting from the execution of code generated by an AI model. Please exercise caution and review the code carefully before running it.</property> <property name="description" translatable="yes">Alpaca and its developers are not liable for any damages to devices or software resulting from the execution of code generated by an AI model. Please exercise caution and review the code carefully before running it.</property>
</object> </object>
</child> </child>
<child>
<object class="AdwStatusPage">
<property name="hexpand">true</property>
<property name="vexpand">true</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="title" translatable="yes">Featured Models</property>
<property name="description" translatable="yes">Alpaca works locally on your device, to start chatting you'll need an AI model, you can either pull models from this list or the 'Manage Models' menu later.
By downloading any model you accept their license agreement available on the model's website.
</property>
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<style>
<class name="boxed-list"/>
</style>
<child>
<object class="AdwActionRow">
<property name="title" translatable="no">Llama3</property>
<property name="subtitle" translatable="yes">Built by Meta</property>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="link_button_handler"/>
<property name="vexpand">false</property>
<property name="icon-name">globe-symbolic</property>
<property name="valign">3</property>
<property name="name">https://ollama.com/library/llama3</property>
<property name="tooltip-text">https://ollama.com/library/llama3</property>
</object>
</child>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="pull_featured_model"/>
<property name="vexpand">false</property>
<property name="icon-name">folder-download-symbolic</property>
<property name="valign">3</property>
<property name="tooltip-text">Pull 'Llama3 (latest)'</property>
<style>
<class name="accent"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="no">Gemma2</property>
<property name="subtitle" translatable="yes">Built by Google DeepMind</property>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="link_button_handler"/>
<property name="vexpand">false</property>
<property name="icon-name">globe-symbolic</property>
<property name="valign">3</property>
<property name="name">https://ollama.com/library/gemma2</property>
<property name="tooltip-text">https://ollama.com/library/gemma2</property>
</object>
</child>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="pull_featured_model"/>
<property name="vexpand">false</property>
<property name="icon-name">folder-download-symbolic</property>
<property name="valign">3</property>
<property name="tooltip-text">Pull 'Gemma2 (latest)'</property>
<style>
<class name="accent"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="no">Phi3</property>
<property name="subtitle" translatable="yes">Built by Microsoft</property>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="link_button_handler"/>
<property name="vexpand">false</property>
<property name="icon-name">globe-symbolic</property>
<property name="valign">3</property>
<property name="name">https://ollama.com/library/phi3</property>
<property name="tooltip-text">https://ollama.com/library/phi3</property>
</object>
</child>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="pull_featured_model"/>
<property name="vexpand">false</property>
<property name="icon-name">folder-download-symbolic</property>
<property name="valign">3</property>
<property name="tooltip-text">Pull 'Phi3 (latest)'</property>
<style>
<class name="accent"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="no">Llava</property>
<property name="subtitle" translatable="yes">Multimodal AI with image recognition</property>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="link_button_handler"/>
<property name="vexpand">false</property>
<property name="icon-name">globe-symbolic</property>
<property name="valign">3</property>
<property name="name">https://ollama.com/library/llava</property>
<property name="tooltip-text">https://ollama.com/library/llava</property>
</object>
</child>
<child type="suffix">
<object class="GtkButton">
<signal name="clicked" handler="pull_featured_model"/>
<property name="vexpand">false</property>
<property name="icon-name">folder-download-symbolic</property>
<property name="valign">3</property>
<property name="tooltip-text">Pull 'Llava (latest)'</property>
<style>
<class name="accent"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>