pygpt-net 2.4.37__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 +29 -0
- README.md +44 -115
- pygpt_net/CHANGELOG.txt +29 -0
- 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 +34 -7
- 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 +92 -29
- 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/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 +17 -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 +40 -16
- 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 +15 -4
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/config/settings.json +55 -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 +12 -0
- pygpt_net/data/locale/locale.en.ini +17 -2
- pygpt_net/data/locale/locale.es.ini +12 -0
- pygpt_net/data/locale/locale.fr.ini +12 -0
- pygpt_net/data/locale/locale.it.ini +12 -0
- pygpt_net/data/locale/locale.pl.ini +12 -0
- pygpt_net/data/locale/locale.uk.ini +12 -0
- pygpt_net/data/locale/locale.zh.ini +12 -0
- 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/provider/core/config/patch.py +43 -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.37.dist-info → pygpt_net-2.4.41.dist-info}/METADATA +45 -116
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/RECORD +255 -247
- /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/entry_points.txt +0 -0
@@ -6,10 +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
|
from datetime import datetime
|
13
|
+
from typing import Optional, List
|
14
|
+
|
13
15
|
from PySide6.QtGui import QTextCursor, QTextBlockFormat
|
14
16
|
|
15
17
|
from pygpt_net.core.render.base import BaseRenderer
|
@@ -71,7 +73,12 @@ class Renderer(BaseRenderer):
|
|
71
73
|
if pid is not None:
|
72
74
|
self.pids[pid] = PidData(pid, meta)
|
73
75
|
|
74
|
-
def begin(
|
76
|
+
def begin(
|
77
|
+
self,
|
78
|
+
meta: CtxMeta,
|
79
|
+
ctx: CtxItem,
|
80
|
+
stream: bool = False
|
81
|
+
):
|
75
82
|
"""
|
76
83
|
Render begin
|
77
84
|
|
@@ -81,7 +88,12 @@ class Renderer(BaseRenderer):
|
|
81
88
|
"""
|
82
89
|
self.to_end(meta)
|
83
90
|
|
84
|
-
def end(
|
91
|
+
def end(
|
92
|
+
self,
|
93
|
+
meta: CtxMeta,
|
94
|
+
ctx: CtxItem,
|
95
|
+
stream: bool = False
|
96
|
+
):
|
85
97
|
"""
|
86
98
|
Render end
|
87
99
|
|
@@ -91,7 +103,12 @@ class Renderer(BaseRenderer):
|
|
91
103
|
"""
|
92
104
|
self.to_end(meta)
|
93
105
|
|
94
|
-
def end_extra(
|
106
|
+
def end_extra(
|
107
|
+
self,
|
108
|
+
meta: CtxMeta,
|
109
|
+
ctx: CtxItem,
|
110
|
+
stream: bool = False
|
111
|
+
):
|
95
112
|
"""
|
96
113
|
Render end extra
|
97
114
|
|
@@ -101,7 +118,11 @@ class Renderer(BaseRenderer):
|
|
101
118
|
"""
|
102
119
|
self.to_end(meta)
|
103
120
|
|
104
|
-
def stream_begin(
|
121
|
+
def stream_begin(
|
122
|
+
self,
|
123
|
+
meta: CtxMeta,
|
124
|
+
ctx: CtxItem
|
125
|
+
):
|
105
126
|
"""
|
106
127
|
Render stream begin
|
107
128
|
|
@@ -110,7 +131,11 @@ class Renderer(BaseRenderer):
|
|
110
131
|
"""
|
111
132
|
pass # do nothing
|
112
133
|
|
113
|
-
def stream_end(
|
134
|
+
def stream_end(
|
135
|
+
self,
|
136
|
+
meta: CtxMeta,
|
137
|
+
ctx: CtxItem
|
138
|
+
):
|
114
139
|
"""
|
115
140
|
Render stream end
|
116
141
|
|
@@ -119,7 +144,12 @@ class Renderer(BaseRenderer):
|
|
119
144
|
"""
|
120
145
|
pass # do nothing
|
121
146
|
|
122
|
-
def append_context(
|
147
|
+
def append_context(
|
148
|
+
self,
|
149
|
+
meta: CtxMeta,
|
150
|
+
items: List[CtxItem],
|
151
|
+
clear: bool = True
|
152
|
+
):
|
123
153
|
"""
|
124
154
|
Append all context to output
|
125
155
|
|
@@ -128,7 +158,7 @@ class Renderer(BaseRenderer):
|
|
128
158
|
:param clear: True if clear all output before append
|
129
159
|
"""
|
130
160
|
if clear:
|
131
|
-
self.clear_output()
|
161
|
+
self.clear_output(meta)
|
132
162
|
|
133
163
|
i = 0
|
134
164
|
for item in items:
|
@@ -136,7 +166,13 @@ class Renderer(BaseRenderer):
|
|
136
166
|
self.append_context_item(meta, item)
|
137
167
|
i += 1
|
138
168
|
|
139
|
-
def append_input(
|
169
|
+
def append_input(
|
170
|
+
self,
|
171
|
+
meta: CtxMeta,
|
172
|
+
item: CtxItem,
|
173
|
+
flush: bool = True,
|
174
|
+
append: bool = False
|
175
|
+
):
|
140
176
|
"""
|
141
177
|
Append text input to output
|
142
178
|
|
@@ -159,7 +195,11 @@ class Renderer(BaseRenderer):
|
|
159
195
|
self.append_raw(meta, item, text.strip())
|
160
196
|
self.to_end(meta)
|
161
197
|
|
162
|
-
def append_output(
|
198
|
+
def append_output(
|
199
|
+
self,
|
200
|
+
meta: CtxMeta,
|
201
|
+
item: CtxItem
|
202
|
+
):
|
163
203
|
"""
|
164
204
|
Append text output to output
|
165
205
|
|
@@ -180,7 +220,12 @@ class Renderer(BaseRenderer):
|
|
180
220
|
self.append_raw(meta, item, text.strip())
|
181
221
|
self.to_end(meta)
|
182
222
|
|
183
|
-
def append_extra(
|
223
|
+
def append_extra(
|
224
|
+
self,
|
225
|
+
meta: CtxMeta,
|
226
|
+
item: CtxItem,
|
227
|
+
footer: bool = False
|
228
|
+
):
|
184
229
|
"""
|
185
230
|
Append extra data (images, files, etc.) to output
|
186
231
|
|
@@ -252,7 +297,13 @@ class Renderer(BaseRenderer):
|
|
252
297
|
if len(appended) > 0:
|
253
298
|
self.to_end(meta)
|
254
299
|
|
255
|
-
def append_chunk(
|
300
|
+
def append_chunk(
|
301
|
+
self,
|
302
|
+
meta: CtxMeta,
|
303
|
+
item: CtxItem,
|
304
|
+
text_chunk: str,
|
305
|
+
begin: bool = False
|
306
|
+
):
|
256
307
|
"""
|
257
308
|
Append output chunk to output
|
258
309
|
|
@@ -286,7 +337,10 @@ class Renderer(BaseRenderer):
|
|
286
337
|
self.pids[pid].buffer += raw_chunk
|
287
338
|
self.append(meta, item, self.helpers.format_chunk(text_chunk), "")
|
288
339
|
|
289
|
-
def append_block(
|
340
|
+
def append_block(
|
341
|
+
self,
|
342
|
+
meta: CtxMeta
|
343
|
+
):
|
290
344
|
"""
|
291
345
|
Append block to output
|
292
346
|
|
@@ -301,7 +355,12 @@ class Renderer(BaseRenderer):
|
|
301
355
|
cursor.insertBlock(block_format)
|
302
356
|
node.setTextCursor(cursor)
|
303
357
|
|
304
|
-
def append_raw(
|
358
|
+
def append_raw(
|
359
|
+
self,
|
360
|
+
meta: CtxMeta,
|
361
|
+
ctx: CtxItem,
|
362
|
+
text: str
|
363
|
+
):
|
305
364
|
"""
|
306
365
|
Append and format raw text to output
|
307
366
|
|
@@ -330,7 +389,11 @@ class Renderer(BaseRenderer):
|
|
330
389
|
cursor.movePosition(QTextCursor.End)
|
331
390
|
node.setTextCursor(cursor)
|
332
391
|
|
333
|
-
def append_context_item(
|
392
|
+
def append_context_item(
|
393
|
+
self,
|
394
|
+
meta: CtxMeta,
|
395
|
+
item: CtxItem
|
396
|
+
):
|
334
397
|
"""
|
335
398
|
Append context item to output
|
336
399
|
|
@@ -341,7 +404,13 @@ class Renderer(BaseRenderer):
|
|
341
404
|
self.append_output(meta, item)
|
342
405
|
self.append_extra(meta, item)
|
343
406
|
|
344
|
-
def append(
|
407
|
+
def append(
|
408
|
+
self,
|
409
|
+
meta: CtxMeta,
|
410
|
+
ctx: CtxItem,
|
411
|
+
text: str,
|
412
|
+
end: str = "\n"
|
413
|
+
):
|
345
414
|
"""
|
346
415
|
Append text to output
|
347
416
|
|
@@ -361,7 +430,11 @@ class Renderer(BaseRenderer):
|
|
361
430
|
cur.insertText("\n")
|
362
431
|
node.setTextCursor(cur) # Update visible cursor
|
363
432
|
|
364
|
-
def append_timestamp(
|
433
|
+
def append_timestamp(
|
434
|
+
self,
|
435
|
+
item: CtxItem,
|
436
|
+
text: str
|
437
|
+
) -> str:
|
365
438
|
"""
|
366
439
|
Append timestamp to text
|
367
440
|
|
@@ -377,7 +450,7 @@ class Renderer(BaseRenderer):
|
|
377
450
|
text = '{}: {}'.format(hour, text)
|
378
451
|
return text
|
379
452
|
|
380
|
-
def reset(self, meta: CtxMeta = None):
|
453
|
+
def reset(self, meta: Optional[CtxMeta] = None):
|
381
454
|
"""
|
382
455
|
Reset
|
383
456
|
|
@@ -392,14 +465,14 @@ class Renderer(BaseRenderer):
|
|
392
465
|
"""Reload output, called externally only on theme change to redraw content"""
|
393
466
|
self.window.controller.ctx.refresh_output() # if clear all and appends all items again
|
394
467
|
|
395
|
-
def clear_output(self, meta: CtxMeta = None):
|
468
|
+
def clear_output(self, meta: Optional[CtxMeta] = None):
|
396
469
|
"""
|
397
470
|
Clear output
|
398
471
|
|
399
472
|
:param meta: context meta
|
400
473
|
"""
|
401
474
|
self.reset()
|
402
|
-
self.get_output_node().clear()
|
475
|
+
self.get_output_node(meta).clear()
|
403
476
|
|
404
477
|
def clear_input(self):
|
405
478
|
"""Clear input"""
|
@@ -424,7 +497,10 @@ class Renderer(BaseRenderer):
|
|
424
497
|
"""
|
425
498
|
return self.window.core.config.get('output_timestamp')
|
426
499
|
|
427
|
-
def get_output_node(
|
500
|
+
def get_output_node(
|
501
|
+
self,
|
502
|
+
meta: Optional[CtxMeta] = None
|
503
|
+
) -> ChatOutput:
|
428
504
|
"""
|
429
505
|
Get output node for current context
|
430
506
|
|
@@ -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 Optional, List, Dict
|
13
14
|
|
14
15
|
from pygpt_net.core.events import Event
|
15
16
|
from pygpt_net.item.ctx import CtxItem
|
@@ -46,23 +47,40 @@ class Body:
|
|
46
47
|
|
47
48
|
:return: CSS styles
|
48
49
|
"""
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
syntax_dark = [
|
51
|
+
"dracula",
|
52
|
+
"fruity",
|
53
|
+
"github-dark",
|
54
|
+
"gruvbox-dark",
|
55
|
+
"inkpot",
|
56
|
+
"material",
|
57
|
+
"monokai",
|
58
|
+
"native",
|
59
|
+
"nord",
|
60
|
+
"nord-darker",
|
61
|
+
"one-dark",
|
62
|
+
"paraiso-dark",
|
63
|
+
"rrt",
|
64
|
+
"solarized-dark",
|
65
|
+
"stata-dark",
|
66
|
+
"vim",
|
67
|
+
"zenburn",
|
68
|
+
]
|
69
|
+
syntax_style = self.window.core.config.get("render.code_syntax")
|
70
|
+
if syntax_style is None or syntax_style == "":
|
71
|
+
syntax_style = "default"
|
55
72
|
fonts_path = os.path.join(self.window.core.config.get_app_path(), "data", "fonts").replace("\\", "/")
|
56
73
|
stylesheet = self.window.controller.theme.markdown.get_web_css().replace('%fonts%', fonts_path)
|
57
|
-
if
|
74
|
+
if syntax_style in syntax_dark:
|
58
75
|
stylesheet += "pre { color: #fff; }"
|
59
76
|
else:
|
60
77
|
stylesheet += "pre { color: #000; }"
|
61
|
-
|
62
|
-
""" + self.highlight.get_style_defs()
|
63
|
-
return content
|
78
|
+
return stylesheet + " " + self.highlight.get_style_defs()
|
64
79
|
|
65
|
-
def prepare_action_icons(
|
80
|
+
def prepare_action_icons(
|
81
|
+
self,
|
82
|
+
ctx: CtxItem
|
83
|
+
) -> str:
|
66
84
|
"""
|
67
85
|
Append action icons
|
68
86
|
|
@@ -78,7 +96,11 @@ class Body:
|
|
78
96
|
html += extra
|
79
97
|
return html
|
80
98
|
|
81
|
-
def get_action_icons(
|
99
|
+
def get_action_icons(
|
100
|
+
self,
|
101
|
+
ctx: CtxItem,
|
102
|
+
all: bool = False
|
103
|
+
) -> List[str]:
|
82
104
|
"""
|
83
105
|
Get action icons for context item
|
84
106
|
|
@@ -141,7 +163,12 @@ class Body:
|
|
141
163
|
)
|
142
164
|
return icons
|
143
165
|
|
144
|
-
def get_icon(
|
166
|
+
def get_icon(
|
167
|
+
self,
|
168
|
+
icon: str,
|
169
|
+
title: Optional[str] = None,
|
170
|
+
item: Optional[CtxItem] = None
|
171
|
+
) -> str:
|
145
172
|
"""
|
146
173
|
Get icon
|
147
174
|
|
@@ -154,7 +181,12 @@ class Body:
|
|
154
181
|
return '<img src="file://{}" class="action-img" title="{}" alt="{}" data-id="{}">'.format(
|
155
182
|
icon, title, title, item.id)
|
156
183
|
|
157
|
-
def get_image_html(
|
184
|
+
def get_image_html(
|
185
|
+
self,
|
186
|
+
url: str,
|
187
|
+
num: Optional[int] = None,
|
188
|
+
num_all: Optional[int] = None
|
189
|
+
) -> str:
|
158
190
|
"""
|
159
191
|
Get image HTML
|
160
192
|
|
@@ -176,7 +208,12 @@ class Body:
|
|
176
208
|
path=path,
|
177
209
|
num=num_str)
|
178
210
|
|
179
|
-
def get_url_html(
|
211
|
+
def get_url_html(
|
212
|
+
self,
|
213
|
+
url: str,
|
214
|
+
num: Optional[int] = None,
|
215
|
+
num_all: Optional[int] = None
|
216
|
+
) -> str:
|
180
217
|
"""
|
181
218
|
Get URL HTML
|
182
219
|
|
@@ -187,19 +224,19 @@ class Body:
|
|
187
224
|
"""
|
188
225
|
icon_path = os.path.join(
|
189
226
|
self.window.core.config.get_app_path(),
|
190
|
-
"data", "icons", "
|
227
|
+
"data", "icons", "language.svg"
|
191
228
|
)
|
192
|
-
icon = '<img src="file://{}"
|
229
|
+
icon = '<img src="file://{}" class="extra-src-icon">'.format(icon_path)
|
193
230
|
num_str = ""
|
194
231
|
if num is not None and num_all is not None and num_all > 1:
|
195
232
|
num_str = " [{}]".format(num)
|
196
|
-
return """{icon}<
|
233
|
+
return """{icon}<a href="{url}" title="{url}">{url}</a> <small>{num}</small>""". \
|
197
234
|
format(url=url,
|
198
235
|
num=num_str,
|
199
236
|
icon=icon,
|
200
237
|
)
|
201
238
|
|
202
|
-
def get_docs_html(self, docs:
|
239
|
+
def get_docs_html(self, docs: List[Dict]) -> str:
|
203
240
|
"""
|
204
241
|
Get Llama-index doc metadata HTML
|
205
242
|
|
@@ -235,7 +272,7 @@ class Body:
|
|
235
272
|
self.window.core.config.get_app_path(),
|
236
273
|
"data", "icons", "db.svg"
|
237
274
|
)
|
238
|
-
icon = '<img src="file://{}"
|
275
|
+
icon = '<img src="file://{}" class="extra-src-icon">'.format(icon_path)
|
239
276
|
if html_sources != "":
|
240
277
|
html += "<p>{icon}<small><b>{prefix}:</b></small></p>".format(
|
241
278
|
prefix=trans('chat.prefix.doc'),
|
@@ -246,7 +283,12 @@ class Body:
|
|
246
283
|
html += "</div> "
|
247
284
|
return html
|
248
285
|
|
249
|
-
def get_file_html(
|
286
|
+
def get_file_html(
|
287
|
+
self,
|
288
|
+
url: str,
|
289
|
+
num: Optional[int] = None,
|
290
|
+
num_all: Optional[int] = None
|
291
|
+
) -> str:
|
250
292
|
"""
|
251
293
|
Get file HTML
|
252
294
|
|
@@ -259,7 +301,7 @@ class Body:
|
|
259
301
|
self.window.core.config.get_app_path(),
|
260
302
|
"data", "icons", "attachments.svg"
|
261
303
|
)
|
262
|
-
icon = '<img src="file://{}"
|
304
|
+
icon = '<img src="file://{}" class="extra-src-icon">'.format(icon_path)
|
263
305
|
num_str = ""
|
264
306
|
if num is not None and num_all is not None and num_all > 1:
|
265
307
|
num_str = " [{}]".format(num)
|
@@ -311,7 +353,7 @@ class Body:
|
|
311
353
|
html += "</div>"
|
312
354
|
return html
|
313
355
|
|
314
|
-
def get_html(self) -> str:
|
356
|
+
def get_html(self, pid: int) -> str:
|
315
357
|
"""
|
316
358
|
Build webview HTML code
|
317
359
|
|
@@ -319,12 +361,14 @@ class Body:
|
|
319
361
|
"""
|
320
362
|
classes = []
|
321
363
|
classes_str = ""
|
364
|
+
style = self.window.core.config.get("theme.style", "blocks")
|
322
365
|
if self.window.core.config.get('render.blocks'):
|
323
366
|
classes.append("display-blocks")
|
324
367
|
if self.window.core.config.get('ctx.edit_icons'):
|
325
368
|
classes.append("display-edit-icons")
|
326
369
|
if self.is_timestamp_enabled():
|
327
370
|
classes.append("display-timestamp")
|
371
|
+
classes.append("theme-" + style)
|
328
372
|
if classes:
|
329
373
|
classes_str = ' class="' + " ".join(classes) + '"'
|
330
374
|
|
@@ -354,13 +398,14 @@ class Body:
|
|
354
398
|
let scrollTimeout = null;
|
355
399
|
let prevScroll = 0;
|
356
400
|
let bridge;
|
401
|
+
let pid = """ + str(pid) + """
|
357
402
|
new QWebChannel(qt.webChannelTransport, function (channel) {
|
358
403
|
bridge = channel.objects.bridge;
|
359
404
|
});
|
360
405
|
history.scrollRestoration = "manual";
|
361
406
|
document.addEventListener('keydown', function(event) {
|
362
407
|
if (event.ctrlKey && event.key === 'f') {
|
363
|
-
window.location.href = 'bridge://open_find'; // send to bridge
|
408
|
+
window.location.href = 'bridge://open_find:' + pid; // send to bridge
|
364
409
|
event.preventDefault();
|
365
410
|
}
|
366
411
|
if (event.key === 'Escape') {
|
@@ -368,6 +413,11 @@ class Body:
|
|
368
413
|
event.preventDefault();
|
369
414
|
}
|
370
415
|
});
|
416
|
+
document.addEventListener('click', function(event) {
|
417
|
+
if (event.target.tagName !== 'A' && !event.target.closest('a')) {
|
418
|
+
window.location.href = 'bridge://focus';
|
419
|
+
}
|
420
|
+
});
|
371
421
|
function highlightCode() {
|
372
422
|
document.querySelectorAll('pre code').forEach(el => {
|
373
423
|
if (!el.classList.contains('hljs')) hljs.highlightElement(el);
|