Preserve changes to override and added link button

This commit is contained in:
jeffser 2024-06-03 17:01:27 -06:00
parent 60b24da482
commit 82a0ab0d9e
3 changed files with 28 additions and 2 deletions

View File

@ -56,7 +56,7 @@ The chat data is located in `~/.var/app/com.jeffser.Alpaca/config/chats.json` yo
To do that you just need to delete the file `~/.var/app/com.jeffser.Alpaca/config/server.json`, this won't affect your saved chats or models.
### Add/Change environment variables for Ollama
You can change anything except `$HOME` and `$OLLAMA_HOST`, to do this go to `~/.var/app/com.jeffser.Alpaca/config/server.json` and change `ollama_overrides` accordingly, some overrides are available to change on the GUI
You can change anything except `$HOME` and `$OLLAMA_HOST`, to do this go to `~/.var/app/com.jeffser.Alpaca/config/server.json` and change `ollama_overrides` accordingly, some overrides are available to change on the GUI.
---

View File

@ -54,6 +54,9 @@ class AlpacaWindow(Adw.ApplicationWindow):
chats = {"chats": {_("New Chat"): {"messages": []}}, "selected_chat": "New Chat"}
attached_image = {"path": None, "base64": None}
#Override elements
override_HSA_OVERRIDE_GFX_VERSION = Gtk.Template.Child()
#Elements
create_model_base = Gtk.Template.Child()
create_model_name = Gtk.Template.Child()
@ -325,6 +328,10 @@ class AlpacaWindow(Adw.ApplicationWindow):
self.save_server_config()
if not self.run_remote: local_instance.reset()
@Gtk.Template.Callback()
def link_button_handler(self, button):
webbrowser.open(button.get_name())
def check_alphanumeric(self, editable, text, length, position):
new_text = ''.join([char for char in text if char.isalnum() or char in ['-', '_']])
if new_text != text: editable.stop_emission_by_name("insert-text")
@ -1024,6 +1031,13 @@ class AlpacaWindow(Adw.ApplicationWindow):
self.keep_alive_spin.set_value(self.model_tweaks['keep_alive'])
#Overrides
if "ollama_overrides" in data: local_instance.overrides = data['ollama_overrides']
for override, element in {"HSA_OVERRIDE_GFX_VERSION": self.override_HSA_OVERRIDE_GFX_VERSION}.items():
if override and override in local_instance.overrides:
model = element.get_model()
for i in range(model.get_n_items()):
if model.get_string(i) == local_instance.overrides[override]:
element.set_selected(i)
self.background_switch.set_active(self.run_on_background)
self.set_hide_on_close(self.run_on_background)

View File

@ -367,11 +367,23 @@
<property name="title" translatable="yes">Ollama Overrides</property>
<property name="description" translatable="yes">Manage the arguments used on Ollama, any changes on this page only applies to the integrated instance, the instance will restart if you make changes</property>
<child>
<object class="AdwComboRow" id="gfx_combo">
<object class="AdwComboRow" id="override_HSA_OVERRIDE_GFX_VERSION">
<signal name="notify" handler="override_changed"/>
<property name="name">HSA_OVERRIDE_GFX_VERSION</property>
<property name="title" translatable="no">AMD Radeon GFX</property>
<property name="subtitle" translatable="yes">HSA_OVERRIDE_GFX_VERSION</property>
<child type="prefix">
<object class="GtkButton">
<signal name="clicked" handler="link_button_handler"/>
<property name="name">https://github.com/ollama/ollama/blob/main/docs/gpu.md#overrides</property>
<property name="vexpand">false</property>
<property name="valign">3</property>
<property name="icon-name">globe-symbolic</property>
<style>
<class name="success"/>
</style>
</object>
</child>
<property name="model">
<object class="GtkStringList">
<items>