Skip to content

Commit 9b77e35

Browse files
authored
Merge pull request #307 from FrancescoCaracciolo/master
Add per chat profiles
2 parents 57b49f1 + fb45c81 commit 9b77e35

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

data/io.github.qwersyk.Newelle.gschema.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,8 @@
176176
<key name="editor-color-scheme" type="s">
177177
<default>"Adwaita-dark"</default>
178178
</key>
179+
<key name="remember-profile" type="b">
180+
<default>false</default>
181+
</key>
179182
</schema>
180183
</schemalist>

src/controller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def load_settings(self, settings):
342342
self.virtualization = settings.get_boolean("virtualization")
343343
self.memory = settings.get_int("memory")
344344
self.hidden_files = settings.get_boolean("hidden-files")
345+
self.remember_profile = settings.get_boolean("remember-profile")
345346
self.reverse_order = settings.get_boolean("reverse-order")
346347
self.remove_thinking = settings.get_boolean("remove-thinking")
347348
self.auto_generate_name = settings.get_boolean("auto-generate-name")

src/ui/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ def update_zoom(x,y):
184184
self.settings.bind("hidden-files", switch, 'active', Gio.SettingsBindFlags.DEFAULT)
185185
self.interface.add(row)
186186

187+
row = Adw.ActionRow(title=_("Remember assistant profile per chat"), subtitle=_("When changing chat, the profile corresponding to the last generation is selected"))
188+
switch = Gtk.Switch(valign=Gtk.Align.CENTER)
189+
row.add_suffix(switch)
190+
self.settings.bind("remember-profile", switch, 'active', Gio.SettingsBindFlags.DEFAULT)
191+
self.interface.add(row)
192+
187193
row = Adw.ActionRow(title=_("Send with ENTER"), subtitle=_("If enabled, messages will be sent with ENTER, to go to a new line use CTRL+ENTER. If disabled, messages will be sent with SHIFT+ENTER, and newline with enter"))
188194
switch = Gtk.Switch(valign=Gtk.Align.CENTER)
189195
row.add_suffix(switch)

src/window.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,9 @@ def chose_chat(self, button, *a):
18781878
old_chat_id = self.chat_id
18791879
self.chat_id = int(button.get_name())
18801880
self.chat = self.chats[self.chat_id]["chat"]
1881+
# Change profile
1882+
if self.controller.newelle_settings.remember_profile and "profile" in self.chats[self.chat_id]:
1883+
self.switch_profile(self.chats[self.chat_id]["profile"])
18811884
self.update_history()
18821885
if old_chat_id > self.chat_id:
18831886
self.chat_stack.set_transition_type(Gtk.StackTransitionType.SLIDE_UP)
@@ -2154,6 +2157,9 @@ def get_variable(self, name:str):
21542157

21552158
def send_message(self, manual=True):
21562159
"""Send a message in the chat and get bot answer, handle TTS etc"""
2160+
# Save profile for generation
2161+
self.chats[self.chat_id]["profile"] = self.current_profile
2162+
21572163
GLib.idle_add(self.hide_placeholder)
21582164
if manual:
21592165
self.auto_run_times = 0

0 commit comments

Comments
 (0)