pygpt-net 2.4.36.post1__py3-none-any.whl → 2.4.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CHANGELOG.md +38 -1
- README.md +71 -114
- pygpt_net/CHANGELOG.txt +38 -1
- pygpt_net/__init__.py +3 -3
- pygpt_net/controller/__init__.py +7 -3
- pygpt_net/controller/access/control.py +1 -1
- pygpt_net/controller/access/voice.py +11 -5
- pygpt_net/controller/agent/experts.py +11 -6
- pygpt_net/controller/agent/legacy.py +8 -6
- pygpt_net/controller/agent/llama.py +4 -2
- pygpt_net/controller/assistant/__init__.py +9 -4
- pygpt_net/controller/assistant/batch.py +38 -21
- pygpt_net/controller/assistant/editor.py +7 -6
- pygpt_net/controller/assistant/files.py +23 -7
- pygpt_net/controller/assistant/store.py +20 -7
- pygpt_net/controller/assistant/threads.py +34 -8
- pygpt_net/controller/attachment.py +29 -10
- pygpt_net/controller/audio/__init__.py +25 -4
- pygpt_net/controller/calendar/__init__.py +23 -4
- pygpt_net/controller/calendar/note.py +57 -11
- pygpt_net/controller/camera.py +3 -2
- pygpt_net/controller/chat/__init__.py +5 -3
- pygpt_net/controller/chat/attachment.py +39 -44
- pygpt_net/controller/chat/command.py +4 -2
- pygpt_net/controller/chat/common.py +11 -4
- pygpt_net/controller/chat/files.py +10 -3
- pygpt_net/controller/chat/image.py +17 -5
- pygpt_net/controller/chat/input.py +10 -7
- pygpt_net/controller/chat/output.py +21 -6
- pygpt_net/controller/chat/render.py +100 -21
- pygpt_net/controller/chat/response.py +34 -7
- pygpt_net/controller/chat/stream.py +4 -2
- pygpt_net/controller/chat/text.py +6 -4
- pygpt_net/controller/command.py +11 -3
- pygpt_net/controller/config/__init__.py +34 -6
- pygpt_net/controller/config/field/checkbox.py +7 -4
- pygpt_net/controller/config/field/cmd.py +7 -5
- pygpt_net/controller/config/field/combo.py +14 -6
- pygpt_net/controller/config/field/dictionary.py +14 -11
- pygpt_net/controller/config/field/input.py +9 -6
- pygpt_net/controller/config/field/slider.py +11 -8
- pygpt_net/controller/config/field/textarea.py +8 -5
- pygpt_net/controller/config/placeholder.py +52 -21
- pygpt_net/controller/ctx/__init__.py +138 -49
- pygpt_net/controller/ctx/common.py +15 -4
- pygpt_net/controller/ctx/extra.py +11 -3
- pygpt_net/controller/ctx/summarizer.py +24 -5
- pygpt_net/controller/debug/__init__.py +27 -6
- pygpt_net/controller/dialogs/confirm.py +34 -7
- pygpt_net/controller/dialogs/debug.py +4 -2
- pygpt_net/controller/dialogs/info.py +7 -2
- pygpt_net/controller/files.py +48 -10
- pygpt_net/controller/finder.py +11 -5
- pygpt_net/controller/idx/__init__.py +10 -3
- pygpt_net/controller/idx/common.py +4 -2
- pygpt_net/controller/idx/indexer.py +25 -17
- pygpt_net/controller/idx/settings.py +9 -3
- pygpt_net/controller/kernel/__init__.py +34 -8
- pygpt_net/controller/kernel/reply.py +12 -3
- pygpt_net/controller/kernel/stack.py +5 -3
- pygpt_net/controller/lang/custom.py +2 -7
- pygpt_net/controller/lang/mapping.py +5 -3
- pygpt_net/controller/layout.py +2 -2
- pygpt_net/controller/mode.py +16 -4
- pygpt_net/controller/model/__init__.py +14 -3
- pygpt_net/controller/model/editor.py +8 -3
- pygpt_net/controller/notepad.py +26 -12
- pygpt_net/controller/painter/capture.py +23 -4
- pygpt_net/controller/painter/common.py +9 -7
- pygpt_net/controller/plugins/__init__.py +19 -5
- pygpt_net/controller/plugins/presets.py +15 -6
- pygpt_net/controller/plugins/settings.py +9 -3
- pygpt_net/controller/presets/__init__.py +55 -16
- pygpt_net/controller/presets/editor.py +26 -10
- pygpt_net/controller/settings/__init__.py +3 -2
- pygpt_net/controller/settings/editor.py +29 -7
- pygpt_net/controller/settings/profile.py +22 -5
- pygpt_net/controller/theme/__init__.py +54 -12
- pygpt_net/controller/theme/common.py +24 -2
- pygpt_net/controller/theme/markdown.py +32 -16
- pygpt_net/controller/theme/menu.py +26 -5
- pygpt_net/controller/theme/nodes.py +2 -5
- pygpt_net/controller/tools/__init__.py +40 -2
- pygpt_net/controller/ui/__init__.py +4 -6
- pygpt_net/controller/ui/tabs.py +363 -65
- pygpt_net/core/access/actions.py +6 -4
- pygpt_net/core/access/shortcuts.py +4 -3
- pygpt_net/core/access/voice.py +6 -5
- pygpt_net/core/agents/legacy.py +4 -2
- pygpt_net/core/agents/memory.py +7 -2
- pygpt_net/core/agents/observer/evaluation.py +15 -7
- pygpt_net/core/agents/provider.py +9 -4
- pygpt_net/core/agents/runner.py +61 -15
- pygpt_net/core/agents/tools.py +23 -5
- pygpt_net/core/assistants/__init__.py +6 -4
- pygpt_net/core/assistants/files.py +35 -12
- pygpt_net/core/assistants/store.py +20 -10
- pygpt_net/core/attachments/__init__.py +54 -15
- pygpt_net/core/attachments/context.py +217 -64
- pygpt_net/core/audio/__init__.py +71 -3
- pygpt_net/core/audio/context.py +7 -2
- pygpt_net/core/bridge/__init__.py +22 -6
- pygpt_net/core/bridge/context.py +5 -3
- pygpt_net/core/bridge/worker.py +16 -2
- pygpt_net/core/calendar/__init__.py +57 -11
- pygpt_net/core/chain/__init__.py +8 -2
- pygpt_net/core/chain/chat.py +10 -8
- pygpt_net/core/chain/completion.py +10 -7
- pygpt_net/core/command.py +62 -17
- pygpt_net/core/ctx/__init__.py +260 -58
- pygpt_net/core/ctx/bag.py +25 -4
- pygpt_net/core/ctx/container.py +28 -17
- pygpt_net/core/ctx/idx.py +45 -8
- pygpt_net/core/ctx/output.py +95 -74
- pygpt_net/core/ctx/reply.py +5 -2
- pygpt_net/core/db/__init__.py +8 -7
- pygpt_net/core/db/viewer.py +17 -11
- pygpt_net/core/debug/__init__.py +10 -9
- pygpt_net/core/debug/tabs.py +5 -2
- pygpt_net/core/docker/__init__.py +11 -5
- pygpt_net/core/docker/builder.py +11 -3
- pygpt_net/core/events/app.py +5 -3
- pygpt_net/core/events/base.py +11 -5
- pygpt_net/core/events/control.py +5 -3
- pygpt_net/core/events/event.py +18 -7
- pygpt_net/core/events/kernel.py +5 -3
- pygpt_net/core/events/render.py +5 -3
- pygpt_net/core/experts/__init__.py +5 -4
- pygpt_net/core/filesystem/__init__.py +52 -34
- pygpt_net/core/filesystem/actions.py +8 -5
- pygpt_net/core/filesystem/editor.py +13 -3
- pygpt_net/core/filesystem/types.py +12 -7
- pygpt_net/core/filesystem/url.py +7 -3
- pygpt_net/core/idx/__init__.py +34 -25
- pygpt_net/core/idx/chat.py +60 -38
- pygpt_net/core/idx/context.py +6 -2
- pygpt_net/core/idx/indexing.py +84 -35
- pygpt_net/core/idx/llm.py +11 -3
- pygpt_net/core/idx/metadata.py +13 -3
- pygpt_net/core/idx/types/ctx.py +32 -6
- pygpt_net/core/idx/types/external.py +41 -7
- pygpt_net/core/idx/types/files.py +31 -6
- pygpt_net/core/image.py +15 -4
- pygpt_net/core/llm/__init__.py +13 -3
- pygpt_net/core/locale.py +34 -8
- pygpt_net/core/models.py +4 -3
- pygpt_net/core/notepad.py +9 -4
- pygpt_net/core/plugins.py +7 -6
- pygpt_net/core/presets.py +19 -10
- pygpt_net/core/profile.py +12 -6
- pygpt_net/core/prompt/__init__.py +10 -3
- pygpt_net/core/prompt/custom.py +7 -6
- pygpt_net/core/prompt/template.py +9 -3
- pygpt_net/core/render/base.py +117 -22
- pygpt_net/core/render/markdown/body.py +27 -7
- pygpt_net/core/render/markdown/renderer.py +119 -22
- pygpt_net/core/render/plain/body.py +22 -5
- pygpt_net/core/render/plain/renderer.py +97 -21
- pygpt_net/core/render/web/body.py +75 -25
- pygpt_net/core/render/web/renderer.py +313 -63
- pygpt_net/core/settings.py +9 -4
- pygpt_net/core/tabs/__init__.py +290 -103
- pygpt_net/core/tabs/tab.py +17 -4
- pygpt_net/core/tokens.py +44 -11
- pygpt_net/core/updater/__init__.py +20 -7
- pygpt_net/core/vision/analyzer.py +29 -6
- pygpt_net/core/web.py +130 -2
- pygpt_net/data/config/config.json +19 -6
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/config/settings.json +81 -10
- pygpt_net/data/config/settings_section.json +3 -0
- pygpt_net/data/css/style.light.css +1 -0
- pygpt_net/data/css/{web.css → web-blocks.css} +162 -133
- pygpt_net/data/css/{web.light.css → web-blocks.light.css} +7 -0
- pygpt_net/data/css/web-chatgpt.css +350 -0
- pygpt_net/data/css/web-chatgpt.dark.css +64 -0
- pygpt_net/data/css/web-chatgpt.light.css +75 -0
- pygpt_net/data/css/web-chatgpt_wide.css +350 -0
- pygpt_net/data/css/web-chatgpt_wide.dark.css +64 -0
- pygpt_net/data/css/web-chatgpt_wide.light.css +75 -0
- pygpt_net/data/icons/split_screen.svg +1 -0
- pygpt_net/data/locale/locale.de.ini +19 -3
- pygpt_net/data/locale/locale.en.ini +30 -11
- pygpt_net/data/locale/locale.es.ini +19 -3
- pygpt_net/data/locale/locale.fr.ini +19 -3
- pygpt_net/data/locale/locale.it.ini +19 -3
- pygpt_net/data/locale/locale.pl.ini +20 -4
- pygpt_net/data/locale/locale.uk.ini +19 -3
- pygpt_net/data/locale/locale.zh.ini +20 -4
- pygpt_net/data/locale/plugin.cmd_web.de.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.en.ini +20 -10
- pygpt_net/data/locale/plugin.cmd_web.es.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.fr.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.it.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.pl.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.uk.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.zh.ini +2 -0
- pygpt_net/icons.qrc +1 -0
- pygpt_net/icons_rc.py +165 -136
- pygpt_net/item/ctx.py +46 -24
- pygpt_net/plugin/audio_input/simple.py +21 -5
- pygpt_net/plugin/audio_output/__init__.py +4 -1
- pygpt_net/plugin/base/config.py +4 -2
- pygpt_net/plugin/base/plugin.py +26 -6
- pygpt_net/plugin/base/worker.py +37 -9
- pygpt_net/plugin/cmd_code_interpreter/__init__.py +39 -37
- pygpt_net/plugin/cmd_code_interpreter/runner.py +25 -12
- pygpt_net/plugin/cmd_web/__init__.py +46 -6
- pygpt_net/plugin/cmd_web/config.py +74 -48
- pygpt_net/plugin/cmd_web/websearch.py +61 -28
- pygpt_net/plugin/cmd_web/worker.py +79 -13
- pygpt_net/plugin/idx_llama_index/__init__.py +2 -2
- pygpt_net/plugin/real_time/__init__.py +2 -2
- pygpt_net/provider/core/config/patch.py +54 -1
- pygpt_net/provider/core/ctx/base.py +4 -1
- pygpt_net/provider/core/ctx/db_sqlite/__init__.py +10 -1
- pygpt_net/provider/core/ctx/db_sqlite/storage.py +22 -1
- pygpt_net/provider/gpt/assistants.py +10 -9
- pygpt_net/provider/gpt/audio.py +3 -2
- pygpt_net/provider/gpt/chat.py +8 -7
- pygpt_net/provider/gpt/completion.py +6 -4
- pygpt_net/provider/gpt/image.py +9 -2
- pygpt_net/provider/gpt/store.py +14 -13
- pygpt_net/provider/gpt/vision.py +6 -5
- pygpt_net/tools/__init__.py +9 -1
- pygpt_net/tools/base.py +15 -1
- pygpt_net/tools/code_interpreter/__init__.py +174 -75
- pygpt_net/tools/code_interpreter/ui/dialogs.py +21 -103
- pygpt_net/tools/code_interpreter/ui/widgets.py +284 -9
- pygpt_net/tools/html_canvas/__init__.py +78 -23
- pygpt_net/tools/html_canvas/ui/dialogs.py +46 -62
- pygpt_net/tools/html_canvas/ui/widgets.py +96 -3
- pygpt_net/ui/base/context_menu.py +2 -2
- pygpt_net/ui/layout/chat/input.py +10 -18
- pygpt_net/ui/layout/chat/output.py +26 -44
- pygpt_net/ui/layout/ctx/ctx_list.py +13 -4
- pygpt_net/ui/layout/toolbox/footer.py +18 -2
- pygpt_net/ui/main.py +2 -2
- pygpt_net/ui/menu/config.py +7 -11
- pygpt_net/ui/menu/debug.py +11 -1
- pygpt_net/ui/menu/theme.py +9 -2
- pygpt_net/ui/widget/filesystem/explorer.py +2 -2
- pygpt_net/ui/widget/lists/context.py +27 -5
- pygpt_net/ui/widget/tabs/Input.py +2 -2
- pygpt_net/ui/widget/tabs/body.py +2 -1
- pygpt_net/ui/widget/tabs/layout.py +195 -0
- pygpt_net/ui/widget/tabs/output.py +218 -55
- pygpt_net/ui/widget/textarea/html.py +11 -1
- pygpt_net/ui/widget/textarea/output.py +10 -1
- pygpt_net/ui/widget/textarea/search_input.py +4 -1
- pygpt_net/ui/widget/textarea/web.py +49 -9
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/METADATA +72 -115
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/RECORD +258 -250
- /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/entry_points.txt +0 -0
@@ -6,12 +6,14 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import re
|
13
|
+
from typing import Optional, List, Dict
|
13
14
|
|
14
15
|
from PySide6.QtGui import QTextCursor
|
16
|
+
from PySide6.QtWidgets import QTextEdit
|
15
17
|
|
16
18
|
from pygpt_net.core.types import (
|
17
19
|
MODE_AGENT,
|
@@ -57,7 +59,7 @@ class Presets:
|
|
57
59
|
self.window.controller.model.select_current()
|
58
60
|
self.window.dispatch(AppEvent(AppEvent.PRESET_SELECTED)) # app event
|
59
61
|
|
60
|
-
def get_current(self) -> PresetItem
|
62
|
+
def get_current(self) -> Optional[PresetItem]:
|
61
63
|
"""
|
62
64
|
Get current preset
|
63
65
|
|
@@ -92,7 +94,11 @@ class Presets:
|
|
92
94
|
self.window.ui.nodes['preset.prompt'].toPlainText()
|
93
95
|
)
|
94
96
|
|
95
|
-
def paste_prompt(
|
97
|
+
def paste_prompt(
|
98
|
+
self,
|
99
|
+
idx: int,
|
100
|
+
parent: str = "global"
|
101
|
+
):
|
96
102
|
"""
|
97
103
|
Paste prompt from template
|
98
104
|
|
@@ -109,7 +115,11 @@ class Presets:
|
|
109
115
|
elif parent == "editor":
|
110
116
|
self.paste_to_textarea(self.window.ui.config["preset"]["prompt"], template['prompt'])
|
111
117
|
|
112
|
-
def paste_custom_prompt(
|
118
|
+
def paste_custom_prompt(
|
119
|
+
self,
|
120
|
+
idx: int,
|
121
|
+
parent: str = "global"
|
122
|
+
):
|
113
123
|
"""
|
114
124
|
Paste prompt from custom template
|
115
125
|
|
@@ -126,7 +136,11 @@ class Presets:
|
|
126
136
|
elif parent == "editor":
|
127
137
|
self.paste_to_textarea(self.window.ui.config["preset"]["prompt"], template.content)
|
128
138
|
|
129
|
-
def save_prompt(
|
139
|
+
def save_prompt(
|
140
|
+
self,
|
141
|
+
name: str = "",
|
142
|
+
force: bool = False
|
143
|
+
):
|
130
144
|
"""
|
131
145
|
Save prompt to file
|
132
146
|
|
@@ -147,7 +161,12 @@ class Presets:
|
|
147
161
|
self.window.core.prompt.custom.new(name, content)
|
148
162
|
self.window.update_status("Prompt saved")
|
149
163
|
|
150
|
-
def rename_prompt(
|
164
|
+
def rename_prompt(
|
165
|
+
self,
|
166
|
+
uuid: str,
|
167
|
+
name: str = "",
|
168
|
+
force: bool = False
|
169
|
+
):
|
151
170
|
"""
|
152
171
|
Rename prompt
|
153
172
|
|
@@ -169,7 +188,11 @@ class Presets:
|
|
169
188
|
self.window.core.prompt.custom.save()
|
170
189
|
self.window.update_status("Prompt renamed")
|
171
190
|
|
172
|
-
def delete_prompt(
|
191
|
+
def delete_prompt(
|
192
|
+
self,
|
193
|
+
uuid: str,
|
194
|
+
force: bool = False
|
195
|
+
):
|
173
196
|
"""
|
174
197
|
Delete prompt
|
175
198
|
|
@@ -189,7 +212,11 @@ class Presets:
|
|
189
212
|
self.window.core.prompt.custom.delete(uuid)
|
190
213
|
self.window.update_status("Prompt deleted")
|
191
214
|
|
192
|
-
def paste_to_textarea(
|
215
|
+
def paste_to_textarea(
|
216
|
+
self,
|
217
|
+
textarea: QTextEdit,
|
218
|
+
text: str
|
219
|
+
):
|
193
220
|
"""
|
194
221
|
Paste text to textarea
|
195
222
|
|
@@ -213,7 +240,11 @@ class Presets:
|
|
213
240
|
textarea.setTextCursor(cur)
|
214
241
|
textarea.setFocus()
|
215
242
|
|
216
|
-
def set(
|
243
|
+
def set(
|
244
|
+
self,
|
245
|
+
mode: str,
|
246
|
+
preset_id: str
|
247
|
+
):
|
217
248
|
"""
|
218
249
|
Set preset
|
219
250
|
|
@@ -227,7 +258,11 @@ class Presets:
|
|
227
258
|
self.window.core.config.data['current_preset'] = {}
|
228
259
|
self.window.core.config.data['current_preset'][mode] = preset_id
|
229
260
|
|
230
|
-
def set_by_idx(
|
261
|
+
def set_by_idx(
|
262
|
+
self,
|
263
|
+
mode: str,
|
264
|
+
idx: int
|
265
|
+
):
|
231
266
|
"""
|
232
267
|
Set preset by index
|
233
268
|
|
@@ -327,7 +362,7 @@ class Presets:
|
|
327
362
|
else:
|
328
363
|
self.window.core.config.set('prompt', None)
|
329
364
|
|
330
|
-
def get_current_functions(self) ->
|
365
|
+
def get_current_functions(self) -> Optional[List[Dict]]:
|
331
366
|
"""
|
332
367
|
Get current preset functions
|
333
368
|
|
@@ -404,7 +439,7 @@ class Presets:
|
|
404
439
|
filename = re.sub(r'[^a-zA-Z0-9_\-\.]', '_', filename)
|
405
440
|
return filename
|
406
441
|
|
407
|
-
def duplicate(self, idx: int = None):
|
442
|
+
def duplicate(self, idx: Optional[int] = None):
|
408
443
|
"""
|
409
444
|
Duplicate preset
|
410
445
|
|
@@ -422,7 +457,7 @@ class Presets:
|
|
422
457
|
self.editor.edit(idx)
|
423
458
|
self.window.update_status(trans('status.preset.duplicated'))
|
424
459
|
|
425
|
-
def enable(self, idx: int = None):
|
460
|
+
def enable(self, idx: Optional[int] = None):
|
426
461
|
"""
|
427
462
|
Enable preset
|
428
463
|
|
@@ -436,7 +471,7 @@ class Presets:
|
|
436
471
|
self.window.core.presets.enable(preset_id)
|
437
472
|
self.refresh()
|
438
473
|
|
439
|
-
def disable(self, idx: int = None):
|
474
|
+
def disable(self, idx: Optional[int] = None):
|
440
475
|
"""
|
441
476
|
Disable preset
|
442
477
|
|
@@ -486,7 +521,11 @@ class Presets:
|
|
486
521
|
if mode == MODE_ASSISTANT:
|
487
522
|
self.window.core.assistants.load()
|
488
523
|
|
489
|
-
def delete(
|
524
|
+
def delete(
|
525
|
+
self,
|
526
|
+
idx: Optional[int] = None,
|
527
|
+
force: bool = False
|
528
|
+
):
|
490
529
|
"""
|
491
530
|
Delete preset
|
492
531
|
|
@@ -533,7 +572,7 @@ class Presets:
|
|
533
572
|
self.window.core.presets.restore(mode)
|
534
573
|
self.refresh()
|
535
574
|
|
536
|
-
def is_current(self, idx: int = None) -> bool:
|
575
|
+
def is_current(self, idx: Optional[int] = None) -> bool:
|
537
576
|
"""
|
538
577
|
Check if preset is current
|
539
578
|
|
@@ -6,11 +6,12 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import datetime
|
13
13
|
import os
|
14
|
+
from typing import Any, Optional, Dict
|
14
15
|
|
15
16
|
from pygpt_net.core.types import (
|
16
17
|
MODE_AGENT,
|
@@ -30,7 +31,6 @@ from pygpt_net.utils import trans
|
|
30
31
|
|
31
32
|
from .experts import Experts
|
32
33
|
|
33
|
-
|
34
34
|
class Editor:
|
35
35
|
def __init__(self, window=None):
|
36
36
|
"""
|
@@ -160,7 +160,7 @@ class Editor:
|
|
160
160
|
self.id = "preset"
|
161
161
|
self.current = None
|
162
162
|
|
163
|
-
def get_options(self) ->
|
163
|
+
def get_options(self) -> Dict[str, Dict[str, Any]]:
|
164
164
|
"""
|
165
165
|
Get preset options
|
166
166
|
|
@@ -168,7 +168,7 @@ class Editor:
|
|
168
168
|
"""
|
169
169
|
return self.options
|
170
170
|
|
171
|
-
def get_option(self, id: str) ->
|
171
|
+
def get_option(self, id: str) -> Dict[str, Any]:
|
172
172
|
"""
|
173
173
|
Get preset option
|
174
174
|
|
@@ -212,7 +212,14 @@ class Editor:
|
|
212
212
|
self.get_option(key),
|
213
213
|
)
|
214
214
|
|
215
|
-
def hook_update(
|
215
|
+
def hook_update(
|
216
|
+
self,
|
217
|
+
key: str,
|
218
|
+
value: Any,
|
219
|
+
caller,
|
220
|
+
*args,
|
221
|
+
**kwargs
|
222
|
+
):
|
216
223
|
"""
|
217
224
|
Hook: on settings update in real-time (prompt)
|
218
225
|
|
@@ -230,7 +237,7 @@ class Editor:
|
|
230
237
|
else:
|
231
238
|
self.window.controller.presets.from_global() # update current preset
|
232
239
|
|
233
|
-
def edit(self, idx: int = None):
|
240
|
+
def edit(self, idx: Optional[int] = None):
|
234
241
|
"""
|
235
242
|
Open preset editor
|
236
243
|
|
@@ -243,7 +250,7 @@ class Editor:
|
|
243
250
|
self.init(preset)
|
244
251
|
self.window.ui.dialogs.open_editor('editor.preset.presets', idx, width=800)
|
245
252
|
|
246
|
-
def init(self, id: str = None):
|
253
|
+
def init(self, id: Optional[str] = None):
|
247
254
|
"""
|
248
255
|
Initialize preset editor
|
249
256
|
|
@@ -337,7 +344,11 @@ class Editor:
|
|
337
344
|
self.window.ui.config[self.id]['name'].setFocus()
|
338
345
|
self.show_hide_by_mode()
|
339
346
|
|
340
|
-
def save(
|
347
|
+
def save(
|
348
|
+
self,
|
349
|
+
force: bool = False,
|
350
|
+
close: bool = True
|
351
|
+
):
|
341
352
|
"""
|
342
353
|
Save ore create preset
|
343
354
|
|
@@ -559,8 +570,13 @@ class Editor:
|
|
559
570
|
value=self.window.core.config.get('model'),
|
560
571
|
)
|
561
572
|
|
562
|
-
def update_from_global(self, key, value):
|
563
|
-
"""
|
573
|
+
def update_from_global(self, key: str, value: Any):
|
574
|
+
"""
|
575
|
+
Update field from global config
|
576
|
+
|
577
|
+
:param key: field key
|
578
|
+
:param value: field value
|
579
|
+
"""
|
564
580
|
preset_id = self.window.core.config.get('preset')
|
565
581
|
if preset_id is not None and preset_id != "":
|
566
582
|
if preset_id in self.window.core.presets.items:
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 00:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
13
|
+
from typing import Optional
|
13
14
|
|
14
15
|
from .editor import Editor
|
15
16
|
from .profile import Profile
|
@@ -149,7 +150,7 @@ class Settings:
|
|
149
150
|
i += 1
|
150
151
|
return section_idx
|
151
152
|
|
152
|
-
def toggle_file_editor(self, file: str = None):
|
153
|
+
def toggle_file_editor(self, file: Optional[str] = None):
|
153
154
|
"""
|
154
155
|
Toggle file editor
|
155
156
|
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import copy
|
13
|
+
from typing import Optional, Any, Dict
|
13
14
|
|
14
15
|
from pygpt_net.utils import trans
|
15
16
|
|
@@ -63,6 +64,7 @@ class Editor:
|
|
63
64
|
self.window.ui.add_hook("update.config.debug", self.hook_update)
|
64
65
|
self.window.ui.add_hook("update.config.notepad.num", self.hook_update)
|
65
66
|
self.window.ui.add_hook("update.config.render.code_syntax", self.hook_update)
|
67
|
+
self.window.ui.add_hook("update.config.theme.style", self.hook_update)
|
66
68
|
# self.window.ui.add_hook("llama.idx.storage", self.hook_update) # vector store update
|
67
69
|
# self.window.ui.add_hook("update.config.llama.idx.list", self.hook_update)
|
68
70
|
|
@@ -93,7 +95,7 @@ class Editor:
|
|
93
95
|
if initialize:
|
94
96
|
self.initialized = True
|
95
97
|
|
96
|
-
def save(self, id: str = None):
|
98
|
+
def save(self, id: Optional[str] = None):
|
97
99
|
"""
|
98
100
|
Save settings
|
99
101
|
|
@@ -163,6 +165,11 @@ class Editor:
|
|
163
165
|
value = self.window.core.config.get('render.code_syntax')
|
164
166
|
self.window.controller.theme.toggle_syntax(value, update_menu=True)
|
165
167
|
|
168
|
+
# style
|
169
|
+
if self.config_changed('theme.style'):
|
170
|
+
value = self.window.core.config.get('theme.style')
|
171
|
+
self.window.controller.theme.toggle_style(value)
|
172
|
+
|
166
173
|
# convert lists
|
167
174
|
if self.config_changed('ctx.convert_lists'):
|
168
175
|
self.window.controller.ctx.refresh()
|
@@ -206,7 +213,14 @@ class Editor:
|
|
206
213
|
return True
|
207
214
|
return False
|
208
215
|
|
209
|
-
def hook_update(
|
216
|
+
def hook_update(
|
217
|
+
self,
|
218
|
+
key: str,
|
219
|
+
value: Any,
|
220
|
+
caller,
|
221
|
+
*args,
|
222
|
+
**kwargs
|
223
|
+
):
|
210
224
|
"""
|
211
225
|
Hook: on settings update
|
212
226
|
|
@@ -301,7 +315,12 @@ class Editor:
|
|
301
315
|
self.window.core.config.set(key, value)
|
302
316
|
self.window.controller.debug.toggle_menu()
|
303
317
|
|
304
|
-
def toggle_collapsed(
|
318
|
+
def toggle_collapsed(
|
319
|
+
self,
|
320
|
+
id: str,
|
321
|
+
value: Any,
|
322
|
+
section: str
|
323
|
+
):
|
305
324
|
"""
|
306
325
|
Toggle collapsed state of section
|
307
326
|
|
@@ -386,7 +405,7 @@ class Editor:
|
|
386
405
|
return
|
387
406
|
self.window.core.settings.load_default_editor_app()
|
388
407
|
|
389
|
-
def get_sections(self) -> dict:
|
408
|
+
def get_sections(self) -> Dict[str, dict]:
|
390
409
|
"""
|
391
410
|
Return settings sections dict
|
392
411
|
|
@@ -394,7 +413,10 @@ class Editor:
|
|
394
413
|
"""
|
395
414
|
return self.sections
|
396
415
|
|
397
|
-
def get_options(
|
416
|
+
def get_options(
|
417
|
+
self,
|
418
|
+
section: Optional[str] = None
|
419
|
+
) -> Dict[str, Any]:
|
398
420
|
"""
|
399
421
|
Return settings options dict
|
400
422
|
|
@@ -411,7 +433,7 @@ class Editor:
|
|
411
433
|
options[key] = self.options[key]
|
412
434
|
return options
|
413
435
|
|
414
|
-
def get_option(self, key: str) ->
|
436
|
+
def get_option(self, key: str) -> Dict[str, Any]:
|
415
437
|
"""
|
416
438
|
Return settings option
|
417
439
|
|
@@ -6,12 +6,13 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import copy
|
13
13
|
import os
|
14
14
|
from pathlib import Path
|
15
|
+
from typing import Optional, Dict, Any
|
15
16
|
from uuid import uuid4
|
16
17
|
|
17
18
|
from PySide6.QtGui import QAction
|
@@ -40,7 +41,12 @@ class Profile:
|
|
40
41
|
self.window.profiles.setup() # widget dialog
|
41
42
|
self.dialog_initialized = True
|
42
43
|
|
43
|
-
def switch(
|
44
|
+
def switch(
|
45
|
+
self,
|
46
|
+
uuid: str,
|
47
|
+
force: bool = False,
|
48
|
+
save_current: bool = True
|
49
|
+
):
|
44
50
|
"""
|
45
51
|
Switch profile
|
46
52
|
|
@@ -87,7 +93,7 @@ class Profile:
|
|
87
93
|
break
|
88
94
|
idx += 1
|
89
95
|
|
90
|
-
def get_profiles(self) ->
|
96
|
+
def get_profiles(self) -> Dict[str, Dict[str, Any]]:
|
91
97
|
"""
|
92
98
|
Get profiles
|
93
99
|
|
@@ -158,7 +164,13 @@ class Profile:
|
|
158
164
|
else:
|
159
165
|
self.open()
|
160
166
|
|
161
|
-
def handle_update(
|
167
|
+
def handle_update(
|
168
|
+
self,
|
169
|
+
mode: str,
|
170
|
+
name: str,
|
171
|
+
path: str,
|
172
|
+
uuid: Optional[str] = None
|
173
|
+
):
|
162
174
|
"""
|
163
175
|
Handle new/edit profile dialog
|
164
176
|
|
@@ -356,7 +368,12 @@ class Profile:
|
|
356
368
|
self.update_list()
|
357
369
|
self.update_menu()
|
358
370
|
|
359
|
-
def duplicate(
|
371
|
+
def duplicate(
|
372
|
+
self,
|
373
|
+
uuid: str,
|
374
|
+
new_name: str,
|
375
|
+
new_path: str
|
376
|
+
):
|
360
377
|
"""
|
361
378
|
Duplicate profile
|
362
379
|
|
@@ -6,17 +6,18 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
13
|
+
from typing import Any, Optional
|
14
|
+
|
15
|
+
from pygpt_net.core.events import RenderEvent
|
13
16
|
|
14
17
|
from .common import Common
|
15
18
|
from .markdown import Markdown
|
16
19
|
from .menu import Menu
|
17
20
|
from .nodes import Nodes
|
18
|
-
from ...core.events import RenderEvent
|
19
|
-
|
20
21
|
|
21
22
|
class Theme:
|
22
23
|
def __init__(self, window=None):
|
@@ -47,7 +48,11 @@ class Theme:
|
|
47
48
|
# apply current theme to nodes
|
48
49
|
self.reload(force=False)
|
49
50
|
|
50
|
-
def toggle(
|
51
|
+
def toggle(
|
52
|
+
self,
|
53
|
+
name: str,
|
54
|
+
force: bool = True
|
55
|
+
):
|
51
56
|
"""
|
52
57
|
Toggle theme by name
|
53
58
|
|
@@ -68,12 +73,27 @@ class Theme:
|
|
68
73
|
# update themes menu
|
69
74
|
self.menu.update_list()
|
70
75
|
self.menu.update_syntax()
|
71
|
-
self.window.ui.menu['theme.blocks'].setChecked(self.window.core.config.get("render.blocks"))
|
72
76
|
|
73
77
|
if force:
|
74
78
|
self.window.controller.ui.restore_state() # restore state after theme change
|
75
79
|
|
76
|
-
def
|
80
|
+
def toggle_style(self, name: str):
|
81
|
+
"""
|
82
|
+
Toggle theme style (web)
|
83
|
+
|
84
|
+
:param name: web style name
|
85
|
+
"""
|
86
|
+
self.window.core.config.set('theme.style', name)
|
87
|
+
self.window.core.config.save()
|
88
|
+
event = RenderEvent(RenderEvent.ON_THEME_CHANGE)
|
89
|
+
self.window.dispatch(event)
|
90
|
+
self.reload()
|
91
|
+
|
92
|
+
def toggle_option(
|
93
|
+
self,
|
94
|
+
name: str,
|
95
|
+
value: Any = None
|
96
|
+
):
|
77
97
|
"""
|
78
98
|
Toggle theme menu option
|
79
99
|
|
@@ -106,7 +126,11 @@ class Theme:
|
|
106
126
|
self.window.core.config.save()
|
107
127
|
self.nodes.apply_all()
|
108
128
|
|
109
|
-
def toggle_syntax(
|
129
|
+
def toggle_syntax(
|
130
|
+
self,
|
131
|
+
name: str,
|
132
|
+
update_menu: bool = False
|
133
|
+
):
|
110
134
|
"""
|
111
135
|
Toggle syntax highlight
|
112
136
|
|
@@ -120,10 +144,24 @@ class Theme:
|
|
120
144
|
if update_menu:
|
121
145
|
self.menu.update_syntax()
|
122
146
|
|
147
|
+
def update_style(self):
|
148
|
+
"""Update style"""
|
149
|
+
current = self.window.core.config.get('theme.style')
|
150
|
+
self.toggle_style(current)
|
151
|
+
|
152
|
+
def update_theme(self, force: bool = True):
|
153
|
+
"""
|
154
|
+
Update theme
|
155
|
+
|
156
|
+
:param force: force theme change (manual trigger)
|
157
|
+
"""
|
158
|
+
current = self.window.core.config.get('theme')
|
159
|
+
self.toggle(current, force=force)
|
160
|
+
|
123
161
|
def update_syntax(self):
|
124
162
|
"""Update syntax menu"""
|
125
|
-
|
126
|
-
self.toggle_syntax(
|
163
|
+
current = self.window.core.config.get('render.code_syntax')
|
164
|
+
self.toggle_syntax(current, update_menu=True)
|
127
165
|
|
128
166
|
def reload(self, force: bool = True):
|
129
167
|
"""
|
@@ -131,10 +169,13 @@ class Theme:
|
|
131
169
|
|
132
170
|
:param force: force theme change (manual trigger)
|
133
171
|
"""
|
134
|
-
|
135
|
-
self.toggle(current, force=force)
|
172
|
+
self.update_theme(force=force)
|
136
173
|
|
137
|
-
def apply(
|
174
|
+
def apply(
|
175
|
+
self,
|
176
|
+
theme: str = 'dark_teal.xml',
|
177
|
+
custom: Optional[str] = None
|
178
|
+
):
|
138
179
|
"""
|
139
180
|
Update material theme and apply custom CSS
|
140
181
|
|
@@ -183,4 +224,5 @@ class Theme:
|
|
183
224
|
def reload_all(self):
|
184
225
|
"""Reload all"""
|
185
226
|
self.setup()
|
227
|
+
self.update_style()
|
186
228
|
self.update_syntax()
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
13
|
+
from typing import List
|
13
14
|
|
14
15
|
from pygpt_net.utils import trans
|
15
16
|
|
@@ -108,7 +109,7 @@ class Common:
|
|
108
109
|
elif element == "font.toolbox":
|
109
110
|
return 'font-size: {}px;'.format(self.window.core.config.get('font_size.toolbox'))
|
110
111
|
|
111
|
-
def get_themes_list(self) ->
|
112
|
+
def get_themes_list(self) -> List[str]:
|
112
113
|
"""
|
113
114
|
Return a list of available themes
|
114
115
|
|
@@ -156,3 +157,24 @@ class Common:
|
|
156
157
|
with open(path) as file:
|
157
158
|
content += file.read()
|
158
159
|
return content
|
160
|
+
|
161
|
+
def get_styles_list(self) -> List[str]:
|
162
|
+
"""
|
163
|
+
Return a list of available styles
|
164
|
+
|
165
|
+
:return: list of styles names
|
166
|
+
"""
|
167
|
+
styles = []
|
168
|
+
app_dir = os.path.join(self.window.core.config.get_app_path(), 'data', 'css')
|
169
|
+
user_dir = os.path.join(self.window.core.config.path, 'css')
|
170
|
+
for path in [app_dir, user_dir]:
|
171
|
+
if not os.path.exists(path):
|
172
|
+
continue
|
173
|
+
for file in os.listdir(path):
|
174
|
+
if file.startswith("web-") and file.endswith('.css'):
|
175
|
+
to_replace = ['web-', '.css', '.light', '.dark']
|
176
|
+
for item in to_replace:
|
177
|
+
file = file.replace(item, '')
|
178
|
+
if file not in styles:
|
179
|
+
styles.append(file)
|
180
|
+
return sorted(styles)
|