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.
Files changed (258) hide show
  1. CHANGELOG.md +38 -1
  2. README.md +71 -114
  3. pygpt_net/CHANGELOG.txt +38 -1
  4. pygpt_net/__init__.py +3 -3
  5. pygpt_net/controller/__init__.py +7 -3
  6. pygpt_net/controller/access/control.py +1 -1
  7. pygpt_net/controller/access/voice.py +11 -5
  8. pygpt_net/controller/agent/experts.py +11 -6
  9. pygpt_net/controller/agent/legacy.py +8 -6
  10. pygpt_net/controller/agent/llama.py +4 -2
  11. pygpt_net/controller/assistant/__init__.py +9 -4
  12. pygpt_net/controller/assistant/batch.py +38 -21
  13. pygpt_net/controller/assistant/editor.py +7 -6
  14. pygpt_net/controller/assistant/files.py +23 -7
  15. pygpt_net/controller/assistant/store.py +20 -7
  16. pygpt_net/controller/assistant/threads.py +34 -8
  17. pygpt_net/controller/attachment.py +29 -10
  18. pygpt_net/controller/audio/__init__.py +25 -4
  19. pygpt_net/controller/calendar/__init__.py +23 -4
  20. pygpt_net/controller/calendar/note.py +57 -11
  21. pygpt_net/controller/camera.py +3 -2
  22. pygpt_net/controller/chat/__init__.py +5 -3
  23. pygpt_net/controller/chat/attachment.py +39 -44
  24. pygpt_net/controller/chat/command.py +4 -2
  25. pygpt_net/controller/chat/common.py +11 -4
  26. pygpt_net/controller/chat/files.py +10 -3
  27. pygpt_net/controller/chat/image.py +17 -5
  28. pygpt_net/controller/chat/input.py +10 -7
  29. pygpt_net/controller/chat/output.py +21 -6
  30. pygpt_net/controller/chat/render.py +100 -21
  31. pygpt_net/controller/chat/response.py +34 -7
  32. pygpt_net/controller/chat/stream.py +4 -2
  33. pygpt_net/controller/chat/text.py +6 -4
  34. pygpt_net/controller/command.py +11 -3
  35. pygpt_net/controller/config/__init__.py +34 -6
  36. pygpt_net/controller/config/field/checkbox.py +7 -4
  37. pygpt_net/controller/config/field/cmd.py +7 -5
  38. pygpt_net/controller/config/field/combo.py +14 -6
  39. pygpt_net/controller/config/field/dictionary.py +14 -11
  40. pygpt_net/controller/config/field/input.py +9 -6
  41. pygpt_net/controller/config/field/slider.py +11 -8
  42. pygpt_net/controller/config/field/textarea.py +8 -5
  43. pygpt_net/controller/config/placeholder.py +52 -21
  44. pygpt_net/controller/ctx/__init__.py +138 -49
  45. pygpt_net/controller/ctx/common.py +15 -4
  46. pygpt_net/controller/ctx/extra.py +11 -3
  47. pygpt_net/controller/ctx/summarizer.py +24 -5
  48. pygpt_net/controller/debug/__init__.py +27 -6
  49. pygpt_net/controller/dialogs/confirm.py +34 -7
  50. pygpt_net/controller/dialogs/debug.py +4 -2
  51. pygpt_net/controller/dialogs/info.py +7 -2
  52. pygpt_net/controller/files.py +48 -10
  53. pygpt_net/controller/finder.py +11 -5
  54. pygpt_net/controller/idx/__init__.py +10 -3
  55. pygpt_net/controller/idx/common.py +4 -2
  56. pygpt_net/controller/idx/indexer.py +25 -17
  57. pygpt_net/controller/idx/settings.py +9 -3
  58. pygpt_net/controller/kernel/__init__.py +34 -8
  59. pygpt_net/controller/kernel/reply.py +12 -3
  60. pygpt_net/controller/kernel/stack.py +5 -3
  61. pygpt_net/controller/lang/custom.py +2 -7
  62. pygpt_net/controller/lang/mapping.py +5 -3
  63. pygpt_net/controller/layout.py +2 -2
  64. pygpt_net/controller/mode.py +16 -4
  65. pygpt_net/controller/model/__init__.py +14 -3
  66. pygpt_net/controller/model/editor.py +8 -3
  67. pygpt_net/controller/notepad.py +26 -12
  68. pygpt_net/controller/painter/capture.py +23 -4
  69. pygpt_net/controller/painter/common.py +9 -7
  70. pygpt_net/controller/plugins/__init__.py +19 -5
  71. pygpt_net/controller/plugins/presets.py +15 -6
  72. pygpt_net/controller/plugins/settings.py +9 -3
  73. pygpt_net/controller/presets/__init__.py +55 -16
  74. pygpt_net/controller/presets/editor.py +26 -10
  75. pygpt_net/controller/settings/__init__.py +3 -2
  76. pygpt_net/controller/settings/editor.py +29 -7
  77. pygpt_net/controller/settings/profile.py +22 -5
  78. pygpt_net/controller/theme/__init__.py +54 -12
  79. pygpt_net/controller/theme/common.py +24 -2
  80. pygpt_net/controller/theme/markdown.py +32 -16
  81. pygpt_net/controller/theme/menu.py +26 -5
  82. pygpt_net/controller/theme/nodes.py +2 -5
  83. pygpt_net/controller/tools/__init__.py +40 -2
  84. pygpt_net/controller/ui/__init__.py +4 -6
  85. pygpt_net/controller/ui/tabs.py +363 -65
  86. pygpt_net/core/access/actions.py +6 -4
  87. pygpt_net/core/access/shortcuts.py +4 -3
  88. pygpt_net/core/access/voice.py +6 -5
  89. pygpt_net/core/agents/legacy.py +4 -2
  90. pygpt_net/core/agents/memory.py +7 -2
  91. pygpt_net/core/agents/observer/evaluation.py +15 -7
  92. pygpt_net/core/agents/provider.py +9 -4
  93. pygpt_net/core/agents/runner.py +61 -15
  94. pygpt_net/core/agents/tools.py +23 -5
  95. pygpt_net/core/assistants/__init__.py +6 -4
  96. pygpt_net/core/assistants/files.py +35 -12
  97. pygpt_net/core/assistants/store.py +20 -10
  98. pygpt_net/core/attachments/__init__.py +54 -15
  99. pygpt_net/core/attachments/context.py +217 -64
  100. pygpt_net/core/audio/__init__.py +71 -3
  101. pygpt_net/core/audio/context.py +7 -2
  102. pygpt_net/core/bridge/__init__.py +22 -6
  103. pygpt_net/core/bridge/context.py +5 -3
  104. pygpt_net/core/bridge/worker.py +16 -2
  105. pygpt_net/core/calendar/__init__.py +57 -11
  106. pygpt_net/core/chain/__init__.py +8 -2
  107. pygpt_net/core/chain/chat.py +10 -8
  108. pygpt_net/core/chain/completion.py +10 -7
  109. pygpt_net/core/command.py +62 -17
  110. pygpt_net/core/ctx/__init__.py +260 -58
  111. pygpt_net/core/ctx/bag.py +25 -4
  112. pygpt_net/core/ctx/container.py +28 -17
  113. pygpt_net/core/ctx/idx.py +45 -8
  114. pygpt_net/core/ctx/output.py +95 -74
  115. pygpt_net/core/ctx/reply.py +5 -2
  116. pygpt_net/core/db/__init__.py +8 -7
  117. pygpt_net/core/db/viewer.py +17 -11
  118. pygpt_net/core/debug/__init__.py +10 -9
  119. pygpt_net/core/debug/tabs.py +5 -2
  120. pygpt_net/core/docker/__init__.py +11 -5
  121. pygpt_net/core/docker/builder.py +11 -3
  122. pygpt_net/core/events/app.py +5 -3
  123. pygpt_net/core/events/base.py +11 -5
  124. pygpt_net/core/events/control.py +5 -3
  125. pygpt_net/core/events/event.py +18 -7
  126. pygpt_net/core/events/kernel.py +5 -3
  127. pygpt_net/core/events/render.py +5 -3
  128. pygpt_net/core/experts/__init__.py +5 -4
  129. pygpt_net/core/filesystem/__init__.py +52 -34
  130. pygpt_net/core/filesystem/actions.py +8 -5
  131. pygpt_net/core/filesystem/editor.py +13 -3
  132. pygpt_net/core/filesystem/types.py +12 -7
  133. pygpt_net/core/filesystem/url.py +7 -3
  134. pygpt_net/core/idx/__init__.py +34 -25
  135. pygpt_net/core/idx/chat.py +60 -38
  136. pygpt_net/core/idx/context.py +6 -2
  137. pygpt_net/core/idx/indexing.py +84 -35
  138. pygpt_net/core/idx/llm.py +11 -3
  139. pygpt_net/core/idx/metadata.py +13 -3
  140. pygpt_net/core/idx/types/ctx.py +32 -6
  141. pygpt_net/core/idx/types/external.py +41 -7
  142. pygpt_net/core/idx/types/files.py +31 -6
  143. pygpt_net/core/image.py +15 -4
  144. pygpt_net/core/llm/__init__.py +13 -3
  145. pygpt_net/core/locale.py +34 -8
  146. pygpt_net/core/models.py +4 -3
  147. pygpt_net/core/notepad.py +9 -4
  148. pygpt_net/core/plugins.py +7 -6
  149. pygpt_net/core/presets.py +19 -10
  150. pygpt_net/core/profile.py +12 -6
  151. pygpt_net/core/prompt/__init__.py +10 -3
  152. pygpt_net/core/prompt/custom.py +7 -6
  153. pygpt_net/core/prompt/template.py +9 -3
  154. pygpt_net/core/render/base.py +117 -22
  155. pygpt_net/core/render/markdown/body.py +27 -7
  156. pygpt_net/core/render/markdown/renderer.py +119 -22
  157. pygpt_net/core/render/plain/body.py +22 -5
  158. pygpt_net/core/render/plain/renderer.py +97 -21
  159. pygpt_net/core/render/web/body.py +75 -25
  160. pygpt_net/core/render/web/renderer.py +313 -63
  161. pygpt_net/core/settings.py +9 -4
  162. pygpt_net/core/tabs/__init__.py +290 -103
  163. pygpt_net/core/tabs/tab.py +17 -4
  164. pygpt_net/core/tokens.py +44 -11
  165. pygpt_net/core/updater/__init__.py +20 -7
  166. pygpt_net/core/vision/analyzer.py +29 -6
  167. pygpt_net/core/web.py +130 -2
  168. pygpt_net/data/config/config.json +19 -6
  169. pygpt_net/data/config/models.json +3 -3
  170. pygpt_net/data/config/modes.json +3 -3
  171. pygpt_net/data/config/settings.json +81 -10
  172. pygpt_net/data/config/settings_section.json +3 -0
  173. pygpt_net/data/css/style.light.css +1 -0
  174. pygpt_net/data/css/{web.css → web-blocks.css} +162 -133
  175. pygpt_net/data/css/{web.light.css → web-blocks.light.css} +7 -0
  176. pygpt_net/data/css/web-chatgpt.css +350 -0
  177. pygpt_net/data/css/web-chatgpt.dark.css +64 -0
  178. pygpt_net/data/css/web-chatgpt.light.css +75 -0
  179. pygpt_net/data/css/web-chatgpt_wide.css +350 -0
  180. pygpt_net/data/css/web-chatgpt_wide.dark.css +64 -0
  181. pygpt_net/data/css/web-chatgpt_wide.light.css +75 -0
  182. pygpt_net/data/icons/split_screen.svg +1 -0
  183. pygpt_net/data/locale/locale.de.ini +19 -3
  184. pygpt_net/data/locale/locale.en.ini +30 -11
  185. pygpt_net/data/locale/locale.es.ini +19 -3
  186. pygpt_net/data/locale/locale.fr.ini +19 -3
  187. pygpt_net/data/locale/locale.it.ini +19 -3
  188. pygpt_net/data/locale/locale.pl.ini +20 -4
  189. pygpt_net/data/locale/locale.uk.ini +19 -3
  190. pygpt_net/data/locale/locale.zh.ini +20 -4
  191. pygpt_net/data/locale/plugin.cmd_web.de.ini +2 -0
  192. pygpt_net/data/locale/plugin.cmd_web.en.ini +20 -10
  193. pygpt_net/data/locale/plugin.cmd_web.es.ini +2 -0
  194. pygpt_net/data/locale/plugin.cmd_web.fr.ini +2 -0
  195. pygpt_net/data/locale/plugin.cmd_web.it.ini +2 -0
  196. pygpt_net/data/locale/plugin.cmd_web.pl.ini +2 -0
  197. pygpt_net/data/locale/plugin.cmd_web.uk.ini +2 -0
  198. pygpt_net/data/locale/plugin.cmd_web.zh.ini +2 -0
  199. pygpt_net/icons.qrc +1 -0
  200. pygpt_net/icons_rc.py +165 -136
  201. pygpt_net/item/ctx.py +46 -24
  202. pygpt_net/plugin/audio_input/simple.py +21 -5
  203. pygpt_net/plugin/audio_output/__init__.py +4 -1
  204. pygpt_net/plugin/base/config.py +4 -2
  205. pygpt_net/plugin/base/plugin.py +26 -6
  206. pygpt_net/plugin/base/worker.py +37 -9
  207. pygpt_net/plugin/cmd_code_interpreter/__init__.py +39 -37
  208. pygpt_net/plugin/cmd_code_interpreter/runner.py +25 -12
  209. pygpt_net/plugin/cmd_web/__init__.py +46 -6
  210. pygpt_net/plugin/cmd_web/config.py +74 -48
  211. pygpt_net/plugin/cmd_web/websearch.py +61 -28
  212. pygpt_net/plugin/cmd_web/worker.py +79 -13
  213. pygpt_net/plugin/idx_llama_index/__init__.py +2 -2
  214. pygpt_net/plugin/real_time/__init__.py +2 -2
  215. pygpt_net/provider/core/config/patch.py +54 -1
  216. pygpt_net/provider/core/ctx/base.py +4 -1
  217. pygpt_net/provider/core/ctx/db_sqlite/__init__.py +10 -1
  218. pygpt_net/provider/core/ctx/db_sqlite/storage.py +22 -1
  219. pygpt_net/provider/gpt/assistants.py +10 -9
  220. pygpt_net/provider/gpt/audio.py +3 -2
  221. pygpt_net/provider/gpt/chat.py +8 -7
  222. pygpt_net/provider/gpt/completion.py +6 -4
  223. pygpt_net/provider/gpt/image.py +9 -2
  224. pygpt_net/provider/gpt/store.py +14 -13
  225. pygpt_net/provider/gpt/vision.py +6 -5
  226. pygpt_net/tools/__init__.py +9 -1
  227. pygpt_net/tools/base.py +15 -1
  228. pygpt_net/tools/code_interpreter/__init__.py +174 -75
  229. pygpt_net/tools/code_interpreter/ui/dialogs.py +21 -103
  230. pygpt_net/tools/code_interpreter/ui/widgets.py +284 -9
  231. pygpt_net/tools/html_canvas/__init__.py +78 -23
  232. pygpt_net/tools/html_canvas/ui/dialogs.py +46 -62
  233. pygpt_net/tools/html_canvas/ui/widgets.py +96 -3
  234. pygpt_net/ui/base/context_menu.py +2 -2
  235. pygpt_net/ui/layout/chat/input.py +10 -18
  236. pygpt_net/ui/layout/chat/output.py +26 -44
  237. pygpt_net/ui/layout/ctx/ctx_list.py +13 -4
  238. pygpt_net/ui/layout/toolbox/footer.py +18 -2
  239. pygpt_net/ui/main.py +2 -2
  240. pygpt_net/ui/menu/config.py +7 -11
  241. pygpt_net/ui/menu/debug.py +11 -1
  242. pygpt_net/ui/menu/theme.py +9 -2
  243. pygpt_net/ui/widget/filesystem/explorer.py +2 -2
  244. pygpt_net/ui/widget/lists/context.py +27 -5
  245. pygpt_net/ui/widget/tabs/Input.py +2 -2
  246. pygpt_net/ui/widget/tabs/body.py +2 -1
  247. pygpt_net/ui/widget/tabs/layout.py +195 -0
  248. pygpt_net/ui/widget/tabs/output.py +218 -55
  249. pygpt_net/ui/widget/textarea/html.py +11 -1
  250. pygpt_net/ui/widget/textarea/output.py +10 -1
  251. pygpt_net/ui/widget/textarea/search_input.py +4 -1
  252. pygpt_net/ui/widget/textarea/web.py +49 -9
  253. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/METADATA +72 -115
  254. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/RECORD +258 -250
  255. /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
  256. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/LICENSE +0 -0
  257. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/WHEEL +0 -0
  258. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/entry_points.txt +0 -0
@@ -6,10 +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.11.24 00:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Optional, List
13
+
12
14
  from PySide6.QtCore import QModelIndex
15
+ from PySide6.QtGui import QStandardItem
13
16
 
14
17
  from pygpt_net.core.events import Event, AppEvent, RenderEvent
15
18
  from pygpt_net.item.ctx import CtxItem
@@ -19,7 +22,7 @@ from .summarizer import Summarizer
19
22
  from .extra import Extra
20
23
 
21
24
  from pygpt_net.utils import trans
22
- from pygpt_net.core.tabs import Tab
25
+ from pygpt_net.core.tabs.tab import Tab
23
26
 
24
27
 
25
28
  class Ctx:
@@ -60,20 +63,6 @@ class Ctx:
60
63
  # if no ctx then get first ctx
61
64
  self.window.core.ctx.set_current(self.window.core.ctx.get_first())
62
65
 
63
- # restore previous ctx
64
- # 1) try to load from tabs data - if not exists, load from current
65
- tab = self.window.core.tabs.get_first_by_type(Tab.TAB_CHAT)
66
- loaded = False
67
- if tab is not None:
68
- meta_id = tab.data_id
69
- if meta_id is not None:
70
- self.load(meta_id)
71
- loaded = True
72
-
73
- # 2) load from current if not loaded yet
74
- if not loaded:
75
- self.load(self.window.core.ctx.get_current())
76
-
77
66
  # restore search string if exists
78
67
  if self.window.core.config.has("ctx.search.string"):
79
68
  string = self.window.core.config.get("ctx.search.string")
@@ -89,7 +78,12 @@ class Ctx:
89
78
  self.window.ui.nodes['ctx.list'].collapseAll() # collapse all items at start
90
79
  self.restore_expanded_groups() # restore expanded groups
91
80
 
92
- def update(self, reload: bool = True, all: bool = True, select: bool = True):
81
+ def update(
82
+ self,
83
+ reload: bool = True,
84
+ all: bool = True,
85
+ select: bool = True
86
+ ):
93
87
  """
94
88
  Update ctx list
95
89
 
@@ -122,7 +116,11 @@ class Ctx:
122
116
  # update additional context attachments
123
117
  self.window.controller.chat.attachment.update()
124
118
 
125
- def select(self, id: int, force: bool = False):
119
+ def select(
120
+ self,
121
+ id: int,
122
+ force: bool = False
123
+ ):
126
124
  """
127
125
  Select ctx by id
128
126
 
@@ -144,6 +142,19 @@ class Ctx:
144
142
  # update additional context attachments
145
143
  self.window.controller.chat.attachment.update()
146
144
 
145
+ def select_on_list_only(self, id: int):
146
+ """
147
+ Select ctx by id only on list
148
+
149
+ :param id: context meta id
150
+ """
151
+ self.window.core.ctx.select(id, restore_model=True)
152
+ self.window.core.ctx.set_current(id)
153
+ self.update_list(True)
154
+ self.select_by_current()
155
+ self.reload_config(all=False)
156
+ self.update()
157
+
147
158
  def select_by_idx(self, idx: int):
148
159
  """
149
160
  Select ctx by index
@@ -189,7 +200,7 @@ class Ctx:
189
200
  self.set_group(None)
190
201
  self.window.ui.nodes['ctx.list'].clearSelection()
191
202
 
192
- def set_group(self, group_id: int = None):
203
+ def set_group(self, group_id: Optional[int] = None):
193
204
  """
194
205
  Set current selected group
195
206
 
@@ -207,7 +218,11 @@ class Ctx:
207
218
  self.group_id = None
208
219
  self.new()
209
220
 
210
- def new(self, force: bool = False, group_id: int = None):
221
+ def new(
222
+ self,
223
+ force: bool = False,
224
+ group_id: Optional[int] = None
225
+ ):
211
226
  """
212
227
  Create new ctx
213
228
 
@@ -326,7 +341,11 @@ class Ctx:
326
341
  event = RenderEvent(RenderEvent.CTX_APPEND, data)
327
342
  self.window.dispatch(event)
328
343
 
329
- def load(self, id: int, restore_model: bool = True):
344
+ def load(
345
+ self,
346
+ id: int,
347
+ restore_model: bool = True
348
+ ):
330
349
  """
331
350
  Load ctx data
332
351
 
@@ -348,6 +367,21 @@ class Ctx:
348
367
  event = RenderEvent(RenderEvent.ON_LOAD, data)
349
368
  self.window.dispatch(event)
350
369
 
370
+ self.reload_config()
371
+
372
+ # reload ctx list and select current ctx on list, without reloading all
373
+ self.update(reload=False, all=True)
374
+
375
+ # update tab title
376
+ if meta is not None:
377
+ self.window.controller.ui.tabs.on_load_ctx(meta)
378
+
379
+ def reload_config(self, all: bool = True):
380
+ """
381
+ Reload config
382
+
383
+ :param all: reload all
384
+ """
351
385
  # get current settings stored in ctx
352
386
  thread = self.window.core.ctx.get_thread()
353
387
  mode = self.window.core.ctx.get_mode()
@@ -358,8 +392,9 @@ class Ctx:
358
392
  # restore thread from ctx
359
393
  self.window.core.config.set('assistant_thread', thread)
360
394
 
361
- # clear before output and append ctx to output
362
- self.refresh_output()
395
+ if all:
396
+ # clear before output and append ctx to output
397
+ self.refresh_output()
363
398
 
364
399
  # switch mode to ctx mode
365
400
  if mode is not None:
@@ -384,16 +419,9 @@ class Ctx:
384
419
  if model is not None and self.window.core.models.has_model(mode, model):
385
420
  self.window.controller.model.set(mode, model)
386
421
 
387
- # reload ctx list and select current ctx on list, without reloading all
388
- self.update(reload=False, all=True)
389
-
390
422
  # update current ctx label in UI
391
423
  self.common.update_label(mode, assistant_id)
392
424
 
393
- # update tab title
394
- if meta is not None:
395
- self.window.controller.ui.tabs.update_title_current(meta.name)
396
-
397
425
  def update_ctx(self):
398
426
  """Update current ctx mode if allowed"""
399
427
  mode = self.window.core.config.get('mode')
@@ -415,7 +443,11 @@ class Ctx:
415
443
  # update ctx label
416
444
  self.common.update_label(mode, id)
417
445
 
418
- def delete(self, id: int, force: int = False):
446
+ def delete(
447
+ self,
448
+ id: int,
449
+ force: bool = False
450
+ ):
419
451
  """
420
452
  Delete ctx by idx
421
453
 
@@ -469,7 +501,11 @@ class Ctx:
469
501
  for idx in list(meta.indexes[store_id]):
470
502
  self.window.core.ctx.idx.remove_meta_from_indexed(store_id, id, idx)
471
503
 
472
- def delete_item(self, id: int, force: bool = False):
504
+ def delete_item(
505
+ self,
506
+ id: int,
507
+ force: bool = False
508
+ ):
473
509
  """
474
510
  Delete ctx item by id
475
511
 
@@ -567,7 +603,11 @@ class Ctx:
567
603
  self.window.ui.dialog['rename'].show()
568
604
  self.update()
569
605
 
570
- def set_important(self, id: int, value: bool = True):
606
+ def set_important(
607
+ self,
608
+ id: int,
609
+ value: bool = True
610
+ ):
571
611
  """
572
612
  Set as important
573
613
 
@@ -593,7 +633,11 @@ class Ctx:
593
633
  return meta.important
594
634
  return False
595
635
 
596
- def set_label(self, id: int, label_id: int):
636
+ def set_label(
637
+ self,
638
+ id: int,
639
+ label_id: int
640
+ ):
597
641
  """
598
642
  Set color label for ctx by idx
599
643
 
@@ -694,7 +738,7 @@ class Ctx:
694
738
  self.window.ui.nodes['ctx.search'].setText(text)
695
739
  self.search_string_change(text) # make search
696
740
 
697
- def label_filters_changed(self, labels: list):
741
+ def label_filters_changed(self, labels: List[int]):
698
742
  """
699
743
  Filters labels change
700
744
 
@@ -726,7 +770,7 @@ class Ctx:
726
770
  """
727
771
  return self.window.controller.chat.input.generating
728
772
 
729
- def select_index_by_id(self, id):
773
+ def select_index_by_id(self, id: int):
730
774
  """
731
775
  Select item by ID on context list
732
776
 
@@ -737,7 +781,11 @@ class Ctx:
737
781
  self.window.ui.nodes['ctx.list'].setCurrentIndex(index)
738
782
  self.window.ui.nodes['ctx.list'].unlocked = False # tmp allow change if locked (disable)
739
783
 
740
- def find_index_by_id(self, item, id):
784
+ def find_index_by_id(
785
+ self,
786
+ item: QStandardItem,
787
+ id: int
788
+ ) -> QModelIndex:
741
789
  """
742
790
  Return index of item with given ID, searching recursively through the model.
743
791
 
@@ -753,7 +801,11 @@ class Ctx:
753
801
  return found_index
754
802
  return QModelIndex()
755
803
 
756
- def find_parent_index_by_id(self, item, id):
804
+ def find_parent_index_by_id(
805
+ self,
806
+ item: QStandardItem,
807
+ id: int
808
+ ) -> QModelIndex:
757
809
  """
758
810
  Return index of item with given ID, searching recursively through the model.
759
811
 
@@ -769,7 +821,7 @@ class Ctx:
769
821
  return found_index
770
822
  return QModelIndex()
771
823
 
772
- def get_parent_index_by_id(self, id):
824
+ def get_parent_index_by_id(self, id: int) -> QModelIndex:
773
825
  """
774
826
  Return QModelIndex of parent item based on its ID.
775
827
 
@@ -780,7 +832,11 @@ class Ctx:
780
832
  root = model.invisibleRootItem()
781
833
  return self.find_parent_index_by_id(root, id)
782
834
 
783
- def get_children_index_by_id(self, parent_id, child_id):
835
+ def get_children_index_by_id(
836
+ self,
837
+ parent_id: int,
838
+ child_id: int
839
+ ) -> QModelIndex:
784
840
  """
785
841
  Return QModelIndex of child item based on its ID and parent ID.
786
842
 
@@ -797,7 +853,11 @@ class Ctx:
797
853
  parent_item = model.itemFromIndex(parent_index)
798
854
  return self.find_index_by_id(parent_item, child_id)
799
855
 
800
- def find_child_index_by_id(self, root_item, child_id):
856
+ def find_child_index_by_id(
857
+ self,
858
+ root_item: QStandardItem,
859
+ child_id: int
860
+ ) -> QModelIndex:
801
861
  """
802
862
  Find and return QModelIndex of child based on its ID, recursively searching through the model.
803
863
 
@@ -814,7 +874,7 @@ class Ctx:
814
874
  return child_index
815
875
  return QModelIndex()
816
876
 
817
- def get_child_index_by_id(self, child_id):
877
+ def get_child_index_by_id(self, child_id: int) -> QModelIndex:
818
878
  """
819
879
  Return QModelIndex of child item based on its ID.
820
880
 
@@ -848,7 +908,12 @@ class Ctx:
848
908
  """Save visible ctx list items"""
849
909
  self.store_expanded_groups()
850
910
 
851
- def move_to_group(self, meta_id, group_id, update: bool = True):
911
+ def move_to_group(
912
+ self,
913
+ meta_id: int,
914
+ group_id: int,
915
+ update: bool = True
916
+ ):
852
917
  """
853
918
  Move ctx to group
854
919
 
@@ -871,7 +936,10 @@ class Ctx:
871
936
  self.group_id = None
872
937
  self.update()
873
938
 
874
- def new_group(self, meta_id = None):
939
+ def new_group(
940
+ self,
941
+ meta_id: Optional[int] = None
942
+ ):
875
943
  """
876
944
  Open new group dialog
877
945
 
@@ -883,7 +951,11 @@ class Ctx:
883
951
  self.window.ui.dialog['create'].show()
884
952
  self.window.ui.dialog['create'].input.setFocus()
885
953
 
886
- def create_group(self, name: str = None, meta_id = None):
954
+ def create_group(
955
+ self,
956
+ name: Optional[str] = None,
957
+ meta_id: Optional[int] = None
958
+ ):
887
959
  """
888
960
  Make directory
889
961
 
@@ -910,7 +982,11 @@ class Ctx:
910
982
  self.select_group(id)
911
983
  self.group_id = id
912
984
 
913
- def rename_group(self, id: int, force: bool = False):
985
+ def rename_group(
986
+ self,
987
+ id: int,
988
+ force: bool = False
989
+ ):
914
990
  """
915
991
  Rename group
916
992
 
@@ -926,7 +1002,12 @@ class Ctx:
926
1002
  self.window.ui.dialog['rename'].current = id
927
1003
  self.window.ui.dialog['rename'].show()
928
1004
 
929
- def update_group_name(self, id: int, name: str, close: bool = True):
1005
+ def update_group_name(
1006
+ self,
1007
+ id: int,
1008
+ name: str,
1009
+ close: bool = True
1010
+ ):
930
1011
  """
931
1012
  Update group name
932
1013
 
@@ -967,7 +1048,11 @@ class Ctx:
967
1048
  self.window.ui.nodes['ctx.list'].setCurrentIndex(index)
968
1049
  self.window.ui.nodes['ctx.list'].unlocked = False # tmp allow change if locked (disable)
969
1050
 
970
- def delete_group(self, id: int, force: bool = False):
1051
+ def delete_group(
1052
+ self,
1053
+ id: int,
1054
+ force: bool = False
1055
+ ):
971
1056
  """
972
1057
  Delete group only
973
1058
 
@@ -988,7 +1073,11 @@ class Ctx:
988
1073
  self.group_id = None
989
1074
  self.update()
990
1075
 
991
- def delete_group_all(self, id: int, force: bool = False):
1076
+ def delete_group_all(
1077
+ self,
1078
+ id: int,
1079
+ force: bool = False
1080
+ ):
992
1081
  """
993
1082
  Delete group with all items
994
1083
 
@@ -6,9 +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.11.23 00:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Optional
13
+
12
14
  from PySide6.QtWidgets import QApplication
13
15
 
14
16
  from pygpt_net.core.tabs.tab import Tab
@@ -53,7 +55,11 @@ class Common:
53
55
  # update ctx label
54
56
  self.window.controller.ui.update_ctx_label(label)
55
57
 
56
- def update_label(self, mode: str, assistant_id: str = None):
58
+ def update_label(
59
+ self,
60
+ mode: str,
61
+ assistant_id: Optional[str] = None
62
+ ):
57
63
  """
58
64
  Update ctx label
59
65
 
@@ -91,10 +97,11 @@ class Common:
91
97
 
92
98
  def focus_chat(self):
93
99
  """Focus chat"""
100
+ tabs = self.window.ui.layout.get_active_tabs()
94
101
  if self.window.controller.ui.tabs.get_current_type() != Tab.TAB_CHAT:
95
102
  idx = self.window.core.tabs.get_min_idx_by_type(Tab.TAB_CHAT)
96
103
  if idx is not None:
97
- self.window.ui.tabs['output'].setCurrentIndex(idx)
104
+ tabs.setCurrentIndex(idx)
98
105
 
99
106
  def restore_display_filter(self):
100
107
  """Restore display filter"""
@@ -159,7 +166,11 @@ class Common:
159
166
  self.window.controller.chat.common.append_to_input(value, separator=" ")
160
167
  QApplication.clipboard().setText(value)
161
168
 
162
- def reset(self, meta_id: int, force: bool = False):
169
+ def reset(
170
+ self,
171
+ meta_id: int,
172
+ force: bool = False
173
+ ):
163
174
  """
164
175
  Reset by meta id
165
176
 
@@ -6,7 +6,7 @@
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.11.20 21:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtWidgets import QApplication
@@ -144,7 +144,11 @@ class Extra:
144
144
  self.window.controller.ctx.edit_meta_id = None
145
145
  self.edit_hide()
146
146
 
147
- def replay_item(self, item_id: int, force: bool = False):
147
+ def replay_item(
148
+ self,
149
+ item_id: int,
150
+ force: bool = False
151
+ ):
148
152
  """
149
153
  Regenerate ctx item
150
154
 
@@ -203,7 +207,11 @@ class Extra:
203
207
  self.window.controller.audio.on_stop()
204
208
  self.audio_play_id = None
205
209
 
206
- def join_item(self, item_id: int, force: bool = False):
210
+ def join_item(
211
+ self,
212
+ item_id: int,
213
+ force: bool = False
214
+ ):
207
215
  """
208
216
  Join ctx items
209
217
 
@@ -6,7 +6,7 @@
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.01.25 19:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtCore import QObject, Signal, Slot
@@ -27,7 +27,11 @@ class Summarizer:
27
27
  """
28
28
  self.window = window
29
29
 
30
- def summarize(self, id: int, ctx: CtxItem):
30
+ def summarize(
31
+ self,
32
+ id: int,
33
+ ctx: CtxItem
34
+ ):
31
35
  """
32
36
  Summarize context
33
37
 
@@ -39,7 +43,13 @@ class Summarizer:
39
43
  ctx_copy.from_dict(ctx.to_dict())
40
44
  self.start_worker(id, ctx_copy)
41
45
 
42
- def summarizer(self, id: int, ctx: CtxItem, window, updated_signal: Signal):
46
+ def summarizer(
47
+ self,
48
+ id: int,
49
+ ctx: CtxItem,
50
+ window,
51
+ updated_signal: Signal
52
+ ):
43
53
  """
44
54
  Summarize worker callback
45
55
 
@@ -52,7 +62,11 @@ class Summarizer:
52
62
  if title:
53
63
  updated_signal.emit(id, ctx, title)
54
64
 
55
- def start_worker(self, id: int, ctx: CtxItem):
65
+ def start_worker(
66
+ self,
67
+ id: int,
68
+ ctx: CtxItem
69
+ ):
56
70
  """
57
71
  Handle worker thread
58
72
 
@@ -69,7 +83,12 @@ class Summarizer:
69
83
  self.window.threadpool.start(worker)
70
84
 
71
85
  @Slot(int, object, str)
72
- def handle_update(self, id: int, ctx: CtxItem, title: str):
86
+ def handle_update(
87
+ self,
88
+ id: int,
89
+ ctx: CtxItem,
90
+ title: str
91
+ ):
73
92
  """
74
93
  Handle update signal (make update)
75
94
 
@@ -6,15 +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.11.20 03:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from datetime import datetime
13
13
  from logging import ERROR, WARNING, INFO, DEBUG
14
+ from typing import Any
14
15
 
15
16
  from PySide6.QtCore import Slot, QObject
16
17
  from PySide6.QtGui import QTextCursor
17
18
 
19
+ from pygpt_net.core.events import RenderEvent
20
+
18
21
 
19
22
  class Debug(QObject):
20
23
  def __init__(self, window=None):
@@ -53,8 +56,17 @@ class Debug(QObject):
53
56
 
54
57
  def toggle_menu(self):
55
58
  """Toggle debug menu"""
56
- stage = self.window.core.config.get('debug')
57
- self.window.ui.menu['menu.debug'].menuAction().setVisible(stage)
59
+ state = self.window.core.config.get('debug')
60
+ self.window.ui.menu['menu.debug'].menuAction().setVisible(state)
61
+
62
+ def toggle_render(self):
63
+ """Toggle render debug"""
64
+ value = self.window.ui.menu['debug.render'].isChecked()
65
+ self.window.core.config.set('debug.render', value)
66
+ self.window.core.config.save()
67
+ event = RenderEvent(RenderEvent.ON_THEME_CHANGE)
68
+ self.window.dispatch(event)
69
+ self.window.controller.ctx.refresh()
58
70
 
59
71
  def set_log_level(self, level: str = 'error'):
60
72
  """
@@ -122,7 +134,12 @@ class Debug(QObject):
122
134
  signals.js_message.connect(self.handle_js_message)
123
135
 
124
136
  @Slot(int, str, str)
125
- def handle_js_message(self, line_number: int, message: str, source_id: str):
137
+ def handle_js_message(
138
+ self,
139
+ line_number: int,
140
+ message: str,
141
+ source_id: str
142
+ ):
126
143
  """
127
144
  Handle JS message
128
145
 
@@ -134,7 +151,7 @@ class Debug(QObject):
134
151
  self.log(data, window=True)
135
152
 
136
153
  @Slot(object)
137
- def handle_log(self, data: any):
154
+ def handle_log(self, data: Any):
138
155
  """
139
156
  Handle log message
140
157
 
@@ -142,7 +159,11 @@ class Debug(QObject):
142
159
  """
143
160
  self.log(data)
144
161
 
145
- def log(self, data: any, window: bool = True):
162
+ def log(
163
+ self,
164
+ data: Any,
165
+ window: bool = True
166
+ ):
146
167
  """
147
168
  Log message to console or logger window
148
169