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.
Files changed (255) hide show
  1. CHANGELOG.md +29 -0
  2. README.md +44 -115
  3. pygpt_net/CHANGELOG.txt +29 -0
  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 +34 -7
  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 +92 -29
  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/calendar/__init__.py +57 -11
  105. pygpt_net/core/chain/__init__.py +8 -2
  106. pygpt_net/core/chain/chat.py +10 -8
  107. pygpt_net/core/chain/completion.py +10 -7
  108. pygpt_net/core/command.py +62 -17
  109. pygpt_net/core/ctx/__init__.py +260 -58
  110. pygpt_net/core/ctx/bag.py +25 -4
  111. pygpt_net/core/ctx/container.py +28 -17
  112. pygpt_net/core/ctx/idx.py +45 -8
  113. pygpt_net/core/ctx/output.py +95 -74
  114. pygpt_net/core/ctx/reply.py +5 -2
  115. pygpt_net/core/db/__init__.py +8 -7
  116. pygpt_net/core/db/viewer.py +17 -11
  117. pygpt_net/core/debug/__init__.py +10 -9
  118. pygpt_net/core/debug/tabs.py +5 -2
  119. pygpt_net/core/docker/__init__.py +11 -5
  120. pygpt_net/core/docker/builder.py +11 -3
  121. pygpt_net/core/events/app.py +5 -3
  122. pygpt_net/core/events/base.py +11 -5
  123. pygpt_net/core/events/control.py +5 -3
  124. pygpt_net/core/events/event.py +17 -7
  125. pygpt_net/core/events/kernel.py +5 -3
  126. pygpt_net/core/events/render.py +5 -3
  127. pygpt_net/core/experts/__init__.py +5 -4
  128. pygpt_net/core/filesystem/__init__.py +52 -34
  129. pygpt_net/core/filesystem/actions.py +8 -5
  130. pygpt_net/core/filesystem/editor.py +13 -3
  131. pygpt_net/core/filesystem/types.py +12 -7
  132. pygpt_net/core/filesystem/url.py +7 -3
  133. pygpt_net/core/idx/__init__.py +34 -25
  134. pygpt_net/core/idx/chat.py +40 -16
  135. pygpt_net/core/idx/context.py +6 -2
  136. pygpt_net/core/idx/indexing.py +84 -35
  137. pygpt_net/core/idx/llm.py +11 -3
  138. pygpt_net/core/idx/metadata.py +13 -3
  139. pygpt_net/core/idx/types/ctx.py +32 -6
  140. pygpt_net/core/idx/types/external.py +41 -7
  141. pygpt_net/core/idx/types/files.py +31 -6
  142. pygpt_net/core/image.py +15 -4
  143. pygpt_net/core/llm/__init__.py +13 -3
  144. pygpt_net/core/locale.py +34 -8
  145. pygpt_net/core/models.py +4 -3
  146. pygpt_net/core/notepad.py +9 -4
  147. pygpt_net/core/plugins.py +7 -6
  148. pygpt_net/core/presets.py +19 -10
  149. pygpt_net/core/profile.py +12 -6
  150. pygpt_net/core/prompt/__init__.py +10 -3
  151. pygpt_net/core/prompt/custom.py +7 -6
  152. pygpt_net/core/prompt/template.py +9 -3
  153. pygpt_net/core/render/base.py +117 -22
  154. pygpt_net/core/render/markdown/body.py +27 -7
  155. pygpt_net/core/render/markdown/renderer.py +119 -22
  156. pygpt_net/core/render/plain/body.py +22 -5
  157. pygpt_net/core/render/plain/renderer.py +97 -21
  158. pygpt_net/core/render/web/body.py +75 -25
  159. pygpt_net/core/render/web/renderer.py +313 -63
  160. pygpt_net/core/settings.py +9 -4
  161. pygpt_net/core/tabs/__init__.py +290 -103
  162. pygpt_net/core/tabs/tab.py +17 -4
  163. pygpt_net/core/tokens.py +44 -11
  164. pygpt_net/core/updater/__init__.py +20 -7
  165. pygpt_net/core/vision/analyzer.py +29 -6
  166. pygpt_net/core/web.py +130 -2
  167. pygpt_net/data/config/config.json +15 -4
  168. pygpt_net/data/config/models.json +3 -3
  169. pygpt_net/data/config/modes.json +3 -3
  170. pygpt_net/data/config/settings.json +55 -10
  171. pygpt_net/data/config/settings_section.json +3 -0
  172. pygpt_net/data/css/style.light.css +1 -0
  173. pygpt_net/data/css/{web.css → web-blocks.css} +162 -133
  174. pygpt_net/data/css/{web.light.css → web-blocks.light.css} +7 -0
  175. pygpt_net/data/css/web-chatgpt.css +350 -0
  176. pygpt_net/data/css/web-chatgpt.dark.css +64 -0
  177. pygpt_net/data/css/web-chatgpt.light.css +75 -0
  178. pygpt_net/data/css/web-chatgpt_wide.css +350 -0
  179. pygpt_net/data/css/web-chatgpt_wide.dark.css +64 -0
  180. pygpt_net/data/css/web-chatgpt_wide.light.css +75 -0
  181. pygpt_net/data/icons/split_screen.svg +1 -0
  182. pygpt_net/data/locale/locale.de.ini +12 -0
  183. pygpt_net/data/locale/locale.en.ini +17 -2
  184. pygpt_net/data/locale/locale.es.ini +12 -0
  185. pygpt_net/data/locale/locale.fr.ini +12 -0
  186. pygpt_net/data/locale/locale.it.ini +12 -0
  187. pygpt_net/data/locale/locale.pl.ini +12 -0
  188. pygpt_net/data/locale/locale.uk.ini +12 -0
  189. pygpt_net/data/locale/locale.zh.ini +12 -0
  190. pygpt_net/data/locale/plugin.cmd_web.de.ini +2 -0
  191. pygpt_net/data/locale/plugin.cmd_web.en.ini +20 -10
  192. pygpt_net/data/locale/plugin.cmd_web.es.ini +2 -0
  193. pygpt_net/data/locale/plugin.cmd_web.fr.ini +2 -0
  194. pygpt_net/data/locale/plugin.cmd_web.it.ini +2 -0
  195. pygpt_net/data/locale/plugin.cmd_web.pl.ini +2 -0
  196. pygpt_net/data/locale/plugin.cmd_web.uk.ini +2 -0
  197. pygpt_net/data/locale/plugin.cmd_web.zh.ini +2 -0
  198. pygpt_net/icons.qrc +1 -0
  199. pygpt_net/icons_rc.py +165 -136
  200. pygpt_net/item/ctx.py +46 -24
  201. pygpt_net/plugin/audio_input/simple.py +21 -5
  202. pygpt_net/plugin/audio_output/__init__.py +4 -1
  203. pygpt_net/plugin/base/config.py +4 -2
  204. pygpt_net/plugin/base/plugin.py +26 -6
  205. pygpt_net/plugin/base/worker.py +37 -9
  206. pygpt_net/plugin/cmd_code_interpreter/__init__.py +39 -37
  207. pygpt_net/plugin/cmd_code_interpreter/runner.py +25 -12
  208. pygpt_net/plugin/cmd_web/__init__.py +46 -6
  209. pygpt_net/plugin/cmd_web/config.py +74 -48
  210. pygpt_net/plugin/cmd_web/websearch.py +61 -28
  211. pygpt_net/plugin/cmd_web/worker.py +79 -13
  212. pygpt_net/provider/core/config/patch.py +43 -1
  213. pygpt_net/provider/core/ctx/base.py +4 -1
  214. pygpt_net/provider/core/ctx/db_sqlite/__init__.py +10 -1
  215. pygpt_net/provider/core/ctx/db_sqlite/storage.py +22 -1
  216. pygpt_net/provider/gpt/assistants.py +10 -9
  217. pygpt_net/provider/gpt/audio.py +3 -2
  218. pygpt_net/provider/gpt/chat.py +8 -7
  219. pygpt_net/provider/gpt/completion.py +6 -4
  220. pygpt_net/provider/gpt/image.py +9 -2
  221. pygpt_net/provider/gpt/store.py +14 -13
  222. pygpt_net/provider/gpt/vision.py +6 -5
  223. pygpt_net/tools/__init__.py +9 -1
  224. pygpt_net/tools/base.py +15 -1
  225. pygpt_net/tools/code_interpreter/__init__.py +174 -75
  226. pygpt_net/tools/code_interpreter/ui/dialogs.py +21 -103
  227. pygpt_net/tools/code_interpreter/ui/widgets.py +284 -9
  228. pygpt_net/tools/html_canvas/__init__.py +78 -23
  229. pygpt_net/tools/html_canvas/ui/dialogs.py +46 -62
  230. pygpt_net/tools/html_canvas/ui/widgets.py +96 -3
  231. pygpt_net/ui/base/context_menu.py +2 -2
  232. pygpt_net/ui/layout/chat/input.py +10 -18
  233. pygpt_net/ui/layout/chat/output.py +26 -44
  234. pygpt_net/ui/layout/ctx/ctx_list.py +13 -4
  235. pygpt_net/ui/layout/toolbox/footer.py +18 -2
  236. pygpt_net/ui/main.py +2 -2
  237. pygpt_net/ui/menu/config.py +7 -11
  238. pygpt_net/ui/menu/debug.py +11 -1
  239. pygpt_net/ui/menu/theme.py +9 -2
  240. pygpt_net/ui/widget/filesystem/explorer.py +2 -2
  241. pygpt_net/ui/widget/lists/context.py +27 -5
  242. pygpt_net/ui/widget/tabs/Input.py +2 -2
  243. pygpt_net/ui/widget/tabs/body.py +2 -1
  244. pygpt_net/ui/widget/tabs/layout.py +195 -0
  245. pygpt_net/ui/widget/tabs/output.py +218 -55
  246. pygpt_net/ui/widget/textarea/html.py +11 -1
  247. pygpt_net/ui/widget/textarea/output.py +10 -1
  248. pygpt_net/ui/widget/textarea/search_input.py +4 -1
  249. pygpt_net/ui/widget/textarea/web.py +49 -9
  250. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/METADATA +45 -116
  251. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/RECORD +255 -247
  252. /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
  253. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/LICENSE +0 -0
  254. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/WHEEL +0 -0
  255. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.41.dist-info}/entry_points.txt +0 -0
@@ -6,9 +6,10 @@
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
+ from typing import Optional, Any
12
13
 
13
14
  from PySide6.QtWidgets import QApplication, QFileDialog
14
15
 
@@ -95,7 +96,11 @@ class Batch:
95
96
  self.window.core.debug.log(e)
96
97
  self.window.ui.dialogs.alert(e)
97
98
 
98
- def import_store_files(self, store_id: str, force: bool = False):
99
+ def import_store_files(
100
+ self,
101
+ store_id: str,
102
+ force: bool = False
103
+ ):
99
104
  """
100
105
  Sync files with API (store)
101
106
 
@@ -123,7 +128,7 @@ class Batch:
123
128
  """
124
129
  Truncate all files in API
125
130
 
126
- :param force: if true, imports without confirmation
131
+ :param force: if True, imports without confirmation
127
132
  """
128
133
  if not force:
129
134
  self.window.ui.dialogs.confirm(
@@ -142,7 +147,7 @@ class Batch:
142
147
  Truncate all files in API (store)
143
148
 
144
149
  :param idx: store index
145
- :param force: if true, imports without confirmation
150
+ :param force: if True, imports without confirmation
146
151
  """
147
152
  store_id = self.window.controller.assistant.store.get_by_tab_idx(idx)
148
153
  self.truncate_store_files(store_id, force)
@@ -152,7 +157,7 @@ class Batch:
152
157
  Truncate all files in API (store)
153
158
 
154
159
  :param store_id: store ID
155
- :param force: if true, imports without confirmation
160
+ :param force: if True, imports without confirmation
156
161
  """
157
162
  if store_id is None:
158
163
  self.window.ui.dialogs.alert(trans("dialog.assistant.store.alert.select"))
@@ -170,22 +175,30 @@ class Batch:
170
175
  QApplication.processEvents()
171
176
  self.window.core.gpt.assistants.importer.truncate_files(store_id) # remove all files from API
172
177
 
173
- def clear_store_files_by_idx(self, idx: int, force: bool = False):
178
+ def clear_store_files_by_idx(
179
+ self,
180
+ idx: int,
181
+ force: bool = False
182
+ ):
174
183
  """
175
184
  Clear files (store, local only)
176
185
 
177
186
  :param idx: store index
178
- :param force: if true, clears without confirmation
187
+ :param force: if True, clears without confirmation
179
188
  """
180
189
  store_id = self.window.controller.assistant.store.get_by_tab_idx(idx)
181
190
  self.clear_store_files(store_id, force)
182
191
 
183
- def clear_store_files(self, store_id: str = None, force: bool = False):
192
+ def clear_store_files(
193
+ self,
194
+ store_id: Optional[str] = None,
195
+ force: bool = False
196
+ ):
184
197
  """
185
198
  Clear files (store, local only)
186
199
 
187
200
  :param store_id: store ID
188
- :param force: if true, clears without confirmation
201
+ :param force: if True, clears without confirmation
189
202
  """
190
203
  if store_id is None:
191
204
  self.window.ui.dialogs.alert(trans("dialog.assistant.store.alert.select"))
@@ -209,7 +222,7 @@ class Batch:
209
222
  """
210
223
  Clear files (all, local only)
211
224
 
212
- :param force: if true, clears without confirmation
225
+ :param force: if True, clears without confirmation
213
226
  """
214
227
  if not force:
215
228
  self.window.ui.dialogs.confirm(
@@ -229,7 +242,7 @@ class Batch:
229
242
  """
230
243
  Clear vector stores (local only)
231
244
 
232
- :param force: if true, clears without confirmation
245
+ :param force: if True, clears without confirmation
233
246
  """
234
247
  if not force:
235
248
  self.window.ui.dialogs.confirm(
@@ -251,7 +264,7 @@ class Batch:
251
264
  """
252
265
  Truncate vector stores in API
253
266
 
254
- :param force: if true, truncates without confirmation
267
+ :param force: if True, truncates without confirmation
255
268
  """
256
269
  if not force:
257
270
  self.window.ui.dialogs.confirm(
@@ -274,7 +287,7 @@ class Batch:
274
287
  """
275
288
  Refresh all vector stores
276
289
 
277
- :param force: if true, refresh without confirmation
290
+ :param force: if True, refresh without confirmation
278
291
  """
279
292
  if not force:
280
293
  self.window.ui.dialogs.confirm(
@@ -299,7 +312,7 @@ class Batch:
299
312
  self.window.update_status("OK. Imported assistants: " + str(num) + ".")
300
313
  self.window.ui.dialogs.alert(trans("status.finished"))
301
314
 
302
- def handle_imported_assistants_failed(self, error: any):
315
+ def handle_imported_assistants_failed(self, error: Any):
303
316
  """
304
317
  Handle error on importing assistants
305
318
 
@@ -322,7 +335,7 @@ class Batch:
322
335
  self.window.ui.dialogs.alert(trans("status.finished"))
323
336
  self.window.update_status("OK. All stores refreshed.")
324
337
 
325
- def handle_refreshed_stores_failed(self, error: any):
338
+ def handle_refreshed_stores_failed(self, error: Any):
326
339
  """
327
340
  Handle error on refreshing stores
328
341
 
@@ -347,7 +360,7 @@ class Batch:
347
360
  # alert on files import after stores
348
361
  # self.window.ui.dialogs.alert(trans("status.finished"))
349
362
 
350
- def handle_imported_stores_failed(self, error: any):
363
+ def handle_imported_stores_failed(self, error: Any):
351
364
  """
352
365
  Handle error on importing stores
353
366
 
@@ -375,7 +388,7 @@ class Batch:
375
388
  self.window.update_status("OK. Removed stores: " + str(num) + ".")
376
389
  self.window.ui.dialogs.alert(trans("status.finished"))
377
390
 
378
- def handle_truncated_stores_failed(self, error: any):
391
+ def handle_truncated_stores_failed(self, error: Any):
379
392
  """
380
393
  Handle error on truncating stores
381
394
 
@@ -398,7 +411,7 @@ class Batch:
398
411
  self.window.update_status("OK. Imported files: " + str(num) + ".")
399
412
  self.window.ui.dialogs.alert(trans("status.finished"))
400
413
 
401
- def handle_imported_files_failed(self, error: any):
414
+ def handle_imported_files_failed(self, error: Any):
402
415
  """
403
416
  Handle error on importing files
404
417
 
@@ -410,7 +423,11 @@ class Batch:
410
423
  self.window.update_status("Error importing files.")
411
424
  self.window.ui.dialogs.alert(error)
412
425
 
413
- def handle_truncated_files(self, store_id: str = None, num: int = 0):
426
+ def handle_truncated_files(
427
+ self,
428
+ store_id: Optional[str] = None,
429
+ num: int = 0
430
+ ):
414
431
  """
415
432
  Handle truncated (in API) files
416
433
 
@@ -423,7 +440,7 @@ class Batch:
423
440
  self.window.controller.assistant.files.update()
424
441
  self.window.ui.dialogs.alert(trans("status.finished"))
425
442
 
426
- def handle_truncated_files_failed(self, error: any):
443
+ def handle_truncated_files_failed(self, error: Any):
427
444
  """
428
445
  Handle error on truncated files
429
446
 
@@ -536,7 +553,7 @@ class Batch:
536
553
  self.window.update_status("OK. Uploaded files: " + str(num) + ".")
537
554
  self.window.ui.dialogs.alert("OK. Uploaded files: " + str(num) + ".")
538
555
 
539
- def handle_uploaded_files_failed(self, error: any):
556
+ def handle_uploaded_files_failed(self, error: Any):
540
557
  """
541
558
  Handle error on uploading files
542
559
 
@@ -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.11.20 21:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
+ from typing import Optional
13
14
 
14
15
  from PySide6.QtWidgets import QApplication
15
16
 
@@ -133,7 +134,7 @@ class Editor:
133
134
  value="",
134
135
  )
135
136
 
136
- def get_selected_store_id(self) -> str or None:
137
+ def get_selected_store_id(self) -> Optional[str]:
137
138
  """
138
139
  Return current selected vector store ID
139
140
 
@@ -149,7 +150,7 @@ class Editor:
149
150
  return self.window.ui.config[self.id]['vector_store'].combo.itemData(idx)
150
151
  return None
151
152
 
152
- def get_choice_idx_by_id(self, store_id) -> int:
153
+ def get_choice_idx_by_id(self, store_id: str) -> int:
153
154
  """
154
155
  Return combo choice index by vector store ID
155
156
 
@@ -166,7 +167,7 @@ class Editor:
166
167
  i += 1
167
168
  return 0 # none
168
169
 
169
- def edit(self, idx: int = None):
170
+ def edit(self, idx: Optional[int] = None):
170
171
  """
171
172
  Open assistant editor
172
173
 
@@ -183,7 +184,7 @@ class Editor:
183
184
  """Close assistant editor"""
184
185
  self.window.ui.dialogs.close('editor.assistants')
185
186
 
186
- def init(self, id: str = None):
187
+ def init(self, id: Optional[str] = None):
187
188
  """
188
189
  Initialize assistant editor
189
190
 
@@ -379,7 +380,7 @@ class Editor:
379
380
  """
380
381
  Assign data from fields to assistant
381
382
 
382
- :param assistant: assistant
383
+ :param assistant: assistant item
383
384
  """
384
385
  model = self.window.controller.config.get_value(
385
386
  parent_id=self.id,
@@ -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.11.20 21:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import os
13
+ from typing import Optional, Dict, List
13
14
 
14
15
  from PySide6.QtWidgets import QApplication
15
16
 
@@ -50,7 +51,10 @@ class Files:
50
51
  file_id = self.window.core.assistants.files.get_file_id_by_idx(idx, assistant.vector_store, thread_id)
51
52
  self.window.core.assistants.current_file = file_id
52
53
 
53
- def count_upload(self, attachments: dict) -> int:
54
+ def count_upload(
55
+ self,
56
+ attachments: Dict[str, AttachmentItem]
57
+ ) -> int:
54
58
  """
55
59
  Count attachments for upload
56
60
 
@@ -64,7 +68,7 @@ class Files:
64
68
  num += 1 # increment uploaded files counter if file is not uploaded yet
65
69
  return num
66
70
 
67
- def import_files(self, store_id: str = None):
71
+ def import_files(self, store_id: Optional[str] = None):
68
72
  """
69
73
  Import assistant files from API
70
74
 
@@ -239,11 +243,15 @@ class Files:
239
243
  self.window.core.assistants.save()
240
244
  self.update()
241
245
 
242
- def upload(self, mode: str, attachments: dict) -> int:
246
+ def upload(
247
+ self,
248
+ mode: str,
249
+ attachments: Dict[str, AttachmentItem]
250
+ ) -> int:
243
251
  """
244
252
  Upload attachments to assistant
245
253
 
246
- :param mode: mode
254
+ :param mode: work mode
247
255
  :param attachments: attachments dict
248
256
  :return: number of uploaded files
249
257
  """
@@ -334,7 +342,11 @@ class Files:
334
342
 
335
343
  return num
336
344
 
337
- def append(self, assistant: AssistantItem, attachment: AttachmentItem):
345
+ def append(
346
+ self,
347
+ assistant: AssistantItem,
348
+ attachment: AttachmentItem
349
+ ):
338
350
  """
339
351
  Append attachment to assistant
340
352
 
@@ -375,7 +387,11 @@ class Files:
375
387
  suffix = f' ({num_files})'
376
388
  self.window.ui.tabs['input'].setTabText(2, trans('attachments_uploaded.tab') + suffix)
377
389
 
378
- def handle_received_ids(self, ids: list, ext: str = None) -> list:
390
+ def handle_received_ids(
391
+ self,
392
+ ids: List[str],
393
+ ext: Optional[str] = None
394
+ ) -> list:
379
395
  """
380
396
  Handle (download) received message files
381
397
 
@@ -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.11.20 21:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
13
  import json
14
+ from typing import Optional
14
15
 
15
16
  from PySide6.QtWidgets import QApplication
16
17
 
@@ -65,7 +66,7 @@ class VectorStore:
65
66
  """
66
67
  return self.options
67
68
 
68
- def get_option(self, key: str) -> dict or None:
69
+ def get_option(self, key: str) -> Optional[dict]:
69
70
  """
70
71
  Get option by key
71
72
 
@@ -157,7 +158,11 @@ class VectorStore:
157
158
  self.window.update_status(trans('status.assistant.saved'))
158
159
  self.update() # update stores list in assistant dialog
159
160
 
160
- def refresh_store(self, store: AssistantStoreItem, update: bool = True):
161
+ def refresh_store(
162
+ self,
163
+ store: AssistantStoreItem,
164
+ update: bool = True
165
+ ):
161
166
  """
162
167
  Refresh store by ID
163
168
 
@@ -301,7 +306,11 @@ class VectorStore:
301
306
  self.restore_selection()
302
307
  self.refresh_by_store_id(store.id)
303
308
 
304
- def delete_by_idx(self, idx: int, force: bool = False):
309
+ def delete_by_idx(
310
+ self,
311
+ idx: int,
312
+ force: bool = False
313
+ ):
305
314
  """
306
315
  Delete store by idx
307
316
 
@@ -311,7 +320,11 @@ class VectorStore:
311
320
  store_id = self.get_by_tab_idx(idx)
312
321
  self.delete(store_id, force=force)
313
322
 
314
- def delete(self, store_id: str = None, force: bool = False):
323
+ def delete(
324
+ self,
325
+ store_id: Optional[str] = None,
326
+ force: bool = False
327
+ ):
315
328
  """
316
329
  Delete store by idx
317
330
 
@@ -413,7 +426,7 @@ class VectorStore:
413
426
  i += 1
414
427
  return idx
415
428
 
416
- def get_by_tab_idx(self, idx: int) -> str or None:
429
+ def get_by_tab_idx(self, idx: int) -> Optional[str]:
417
430
  """
418
431
  Get key by list index (including hidden)
419
432
 
@@ -429,7 +442,7 @@ class VectorStore:
429
442
  store_idx += 1
430
443
  return None
431
444
 
432
- def get_first_visible(self) -> str or None:
445
+ def get_first_visible(self) -> Optional[str]:
433
446
  """
434
447
  Get first visible store ID (including hidden)
435
448
 
@@ -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.11.24 00:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
13
13
  import time
14
+ from typing import Optional, Any, List, Dict
14
15
 
15
16
  from PySide6.QtCore import QObject, Signal, Slot, QRunnable
16
17
 
@@ -46,7 +47,11 @@ class Threads(QObject):
46
47
  self.window.core.ctx.append_thread(thread_id)
47
48
  return thread_id
48
49
 
49
- def handle_output_message(self, ctx: CtxItem, stream: bool = False):
50
+ def handle_output_message(
51
+ self,
52
+ ctx: CtxItem,
53
+ stream: bool = False
54
+ ):
50
55
  """
51
56
  Handle output message (not stream ONLY)
52
57
 
@@ -92,7 +97,12 @@ class Threads(QObject):
92
97
 
93
98
  self.log("Handled output message.")
94
99
 
95
- def handle_message_data(self, ctx: CtxItem, msg, stream: bool = False):
100
+ def handle_message_data(
101
+ self,
102
+ ctx: CtxItem,
103
+ msg,
104
+ stream: bool = False
105
+ ):
96
106
  """
97
107
  Handle message data (files, images, text) - stream and not-stream
98
108
 
@@ -286,7 +296,10 @@ class Threads(QObject):
286
296
  })
287
297
  self.window.dispatch(event)
288
298
 
289
- def handle_tool_outputs(self, ctx: CtxItem) -> list:
299
+ def handle_tool_outputs(
300
+ self,
301
+ ctx: CtxItem
302
+ ) -> List[Dict[str, Any]]:
290
303
  """
291
304
  Handle tool outputs
292
305
 
@@ -304,7 +317,10 @@ class Threads(QObject):
304
317
  return tools_outputs
305
318
 
306
319
 
307
- def apply_outputs(self, ctx: CtxItem) -> list:
320
+ def apply_outputs(
321
+ self,
322
+ ctx: CtxItem
323
+ ) -> List[Dict[str, Any]]:
308
324
  """
309
325
  Apply tool call outputs
310
326
 
@@ -316,7 +332,12 @@ class Threads(QObject):
316
332
  ctx.tool_calls = self.tool_calls # set previous tool calls
317
333
  return self.window.core.command.get_tool_calls_outputs(ctx)
318
334
 
319
- def handle_run_created(self, ctx: CtxItem, run, stream: bool = False):
335
+ def handle_run_created(
336
+ self,
337
+ ctx: CtxItem,
338
+ run,
339
+ stream: bool = False
340
+ ):
320
341
  """
321
342
  Handle run created (stream and not stream)
322
343
 
@@ -330,7 +351,7 @@ class Threads(QObject):
330
351
  self.window.core.ctx.append_run(ctx.run_id) # get run ID and store in ctx
331
352
  self.handle_run(ctx, run, stream) # handle assistant run
332
353
 
333
- def handle_run_error(self, ctx: CtxItem, err):
354
+ def handle_run_error(self, ctx: CtxItem, err: Any):
334
355
  """
335
356
  Handle run created (stream and not stream)
336
357
 
@@ -354,7 +375,12 @@ class Threads(QObject):
354
375
  self.window.controller.chat.common.unlock_input() # unlock input
355
376
  # self.handle_stream_end(ctx)
356
377
 
357
- def handle_run(self, ctx: CtxItem, run, stream: bool = False):
378
+ def handle_run(
379
+ self,
380
+ ctx: CtxItem,
381
+ run,
382
+ stream: bool = False
383
+ ):
358
384
  """
359
385
  Handle assistant's run (not stream ONLY)
360
386
 
@@ -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.11.26 02:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import os
13
13
  from datetime import datetime
14
+ from typing import Optional
14
15
  from urllib.parse import urlparse
15
16
 
16
17
  from PySide6.QtGui import QImage
@@ -112,7 +113,12 @@ class Attachment:
112
113
  # TODO: implement this
113
114
  pass
114
115
 
115
- def delete(self, idx: int, force: bool = False, remove_local: bool = False):
116
+ def delete(
117
+ self,
118
+ idx: int,
119
+ force: bool = False,
120
+ remove_local: bool = False
121
+ ):
116
122
  """
117
123
  Delete attachment
118
124
 
@@ -196,7 +202,11 @@ class Attachment:
196
202
  self.window.ui.dialog['rename'].close()
197
203
  self.update()
198
204
 
199
- def add(self, mode: str, attachment: AttachmentItem):
205
+ def add(
206
+ self,
207
+ mode: str,
208
+ attachment: AttachmentItem
209
+ ):
200
210
  """
201
211
  Add attachment item to list
202
212
 
@@ -210,7 +220,12 @@ class Attachment:
210
220
  self.is_consumed = False # reset consumed flag
211
221
  self.update()
212
222
 
213
- def clear(self, force: bool = False, remove_local=False, auto: bool = False):
223
+ def clear(
224
+ self,
225
+ force: bool = False,
226
+ remove_local: bool = False,
227
+ auto: bool = False
228
+ ):
214
229
  """
215
230
  Clear attachments list
216
231
 
@@ -240,9 +255,7 @@ class Attachment:
240
255
  self.window.dispatch(AppEvent(AppEvent.CTX_ATTACHMENTS_CLEAR))
241
256
 
242
257
  def clear_silent(self):
243
- """
244
- Clear attachments list
245
- """
258
+ """Clear attachments list without confirmation"""
246
259
  # delete all from attachments for current mode
247
260
  mode = self.window.core.config.get('mode')
248
261
  self.window.core.attachments.delete_all(
@@ -407,9 +420,13 @@ class Attachment:
407
420
  self.window.core.config.get_user_dir('data'),
408
421
  file_name,
409
422
  )
410
- return path
423
+ return str(path)
411
424
 
412
- def download(self, file_id: str, ext: str = None) -> str or None:
425
+ def download(
426
+ self,
427
+ file_id: str,
428
+ ext: Optional[str] = None
429
+ ) -> Optional[str]:
413
430
  """
414
431
  Download file
415
432
 
@@ -501,6 +518,8 @@ class Attachment:
501
518
  def from_clipboard_image(self, image):
502
519
  """
503
520
  Handle image from clipboard
521
+
522
+ :param image: image data
504
523
  """
505
524
  now = datetime.now()
506
525
  dt = now.strftime("%Y-%m-%d_%H-%M-%S")
@@ -509,7 +528,7 @@ class Attachment:
509
528
  image.save(path, "PNG")
510
529
  self.from_clipboard_url(path)
511
530
 
512
- def from_clipboard_url(self, url, all: bool = False):
531
+ def from_clipboard_url(self, url: str, all: bool = False):
513
532
  """
514
533
  Handle image from clipboard url
515
534
 
@@ -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.11.26 19:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import os
13
+ from typing import Optional
13
14
 
14
15
  from pygpt_net.core.events import Event, BaseEvent
15
16
  from pygpt_net.item.ctx import CtxItem
@@ -29,7 +30,11 @@ class Audio:
29
30
  """Setup controller"""
30
31
  self.update()
31
32
 
32
- def toggle_input(self, state: bool, btn: bool = True):
33
+ def toggle_input(
34
+ self,
35
+ state: bool,
36
+ btn: bool = True
37
+ ):
33
38
  """
34
39
  Toggle audio input
35
40
 
@@ -155,7 +160,11 @@ class Audio:
155
160
  else:
156
161
  self.window.ui.menu['audio.control.global'].setChecked(False)
157
162
 
158
- def read_text(self, text: str, cache_file: str = None):
163
+ def read_text(
164
+ self,
165
+ text: str,
166
+ cache_file: Optional[str] = None
167
+ ):
159
168
  """
160
169
  Read text using audio output plugins
161
170
 
@@ -200,6 +209,14 @@ class Audio:
200
209
  }
201
210
  self.window.dispatch(event, all=True)
202
211
 
212
+ def stop_audio(self):
213
+ """Stop audio playback"""
214
+ ctx = CtxItem()
215
+ event = Event(Event.AUDIO_OUTPUT_STOP)
216
+ event.ctx = ctx
217
+ event.data = {}
218
+ self.window.dispatch(event, all=True)
219
+
203
220
  def play_sound(self, filename: str):
204
221
  """
205
222
  Play sound
@@ -210,7 +227,11 @@ class Audio:
210
227
  if path:
211
228
  self.play_audio(path)
212
229
 
213
- def play_event(self, text: str, event: BaseEvent = None):
230
+ def play_event(
231
+ self,
232
+ text: str,
233
+ event: Optional[BaseEvent] = None
234
+ ):
214
235
  """
215
236
  Play event (read text or play cached audio file)
216
237