pygpt-net 2.4.37__py3-none-any.whl → 2.4.42__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 (340) hide show
  1. CHANGELOG.md +37 -0
  2. README.md +176 -182
  3. pygpt_net/CHANGELOG.txt +37 -0
  4. pygpt_net/__init__.py +3 -3
  5. pygpt_net/app.py +3 -1
  6. pygpt_net/controller/__init__.py +7 -3
  7. pygpt_net/controller/access/control.py +1 -1
  8. pygpt_net/controller/access/voice.py +11 -5
  9. pygpt_net/controller/agent/experts.py +11 -6
  10. pygpt_net/controller/agent/legacy.py +8 -6
  11. pygpt_net/controller/agent/llama.py +4 -2
  12. pygpt_net/controller/assistant/__init__.py +9 -4
  13. pygpt_net/controller/assistant/batch.py +38 -21
  14. pygpt_net/controller/assistant/editor.py +7 -6
  15. pygpt_net/controller/assistant/files.py +23 -7
  16. pygpt_net/controller/assistant/store.py +20 -7
  17. pygpt_net/controller/assistant/threads.py +34 -8
  18. pygpt_net/controller/attachment.py +29 -10
  19. pygpt_net/controller/audio/__init__.py +26 -5
  20. pygpt_net/controller/calendar/__init__.py +23 -4
  21. pygpt_net/controller/calendar/note.py +57 -11
  22. pygpt_net/controller/camera.py +4 -12
  23. pygpt_net/controller/chat/__init__.py +5 -3
  24. pygpt_net/controller/chat/attachment.py +34 -7
  25. pygpt_net/controller/chat/audio.py +2 -2
  26. pygpt_net/controller/chat/command.py +4 -2
  27. pygpt_net/controller/chat/common.py +11 -4
  28. pygpt_net/controller/chat/files.py +10 -3
  29. pygpt_net/controller/chat/image.py +17 -5
  30. pygpt_net/controller/chat/input.py +10 -7
  31. pygpt_net/controller/chat/output.py +21 -6
  32. pygpt_net/controller/chat/render.py +100 -21
  33. pygpt_net/controller/chat/response.py +34 -7
  34. pygpt_net/controller/chat/stream.py +4 -2
  35. pygpt_net/controller/chat/text.py +6 -4
  36. pygpt_net/controller/command.py +11 -3
  37. pygpt_net/controller/config/__init__.py +34 -6
  38. pygpt_net/controller/config/field/checkbox.py +7 -4
  39. pygpt_net/controller/config/field/cmd.py +7 -5
  40. pygpt_net/controller/config/field/combo.py +14 -6
  41. pygpt_net/controller/config/field/dictionary.py +14 -11
  42. pygpt_net/controller/config/field/input.py +9 -6
  43. pygpt_net/controller/config/field/slider.py +11 -8
  44. pygpt_net/controller/config/field/textarea.py +8 -5
  45. pygpt_net/controller/config/placeholder.py +66 -21
  46. pygpt_net/controller/ctx/__init__.py +138 -49
  47. pygpt_net/controller/ctx/common.py +15 -4
  48. pygpt_net/controller/ctx/extra.py +11 -3
  49. pygpt_net/controller/ctx/summarizer.py +24 -5
  50. pygpt_net/controller/debug/__init__.py +27 -6
  51. pygpt_net/controller/dialogs/confirm.py +34 -7
  52. pygpt_net/controller/dialogs/debug.py +4 -2
  53. pygpt_net/controller/dialogs/info.py +7 -2
  54. pygpt_net/controller/files.py +48 -10
  55. pygpt_net/controller/finder.py +11 -5
  56. pygpt_net/controller/idx/__init__.py +10 -3
  57. pygpt_net/controller/idx/common.py +4 -2
  58. pygpt_net/controller/idx/indexer.py +25 -17
  59. pygpt_net/controller/idx/settings.py +9 -3
  60. pygpt_net/controller/kernel/__init__.py +34 -8
  61. pygpt_net/controller/kernel/reply.py +12 -3
  62. pygpt_net/controller/kernel/stack.py +5 -3
  63. pygpt_net/controller/lang/custom.py +2 -7
  64. pygpt_net/controller/lang/mapping.py +5 -3
  65. pygpt_net/controller/layout.py +2 -2
  66. pygpt_net/controller/mode.py +16 -4
  67. pygpt_net/controller/model/__init__.py +14 -3
  68. pygpt_net/controller/model/editor.py +8 -3
  69. pygpt_net/controller/notepad.py +26 -12
  70. pygpt_net/controller/painter/capture.py +23 -4
  71. pygpt_net/controller/painter/common.py +9 -7
  72. pygpt_net/controller/plugins/__init__.py +19 -5
  73. pygpt_net/controller/plugins/presets.py +15 -6
  74. pygpt_net/controller/plugins/settings.py +9 -3
  75. pygpt_net/controller/presets/__init__.py +55 -16
  76. pygpt_net/controller/presets/editor.py +26 -10
  77. pygpt_net/controller/settings/__init__.py +3 -2
  78. pygpt_net/controller/settings/editor.py +29 -7
  79. pygpt_net/controller/settings/profile.py +22 -5
  80. pygpt_net/controller/theme/__init__.py +54 -12
  81. pygpt_net/controller/theme/common.py +24 -2
  82. pygpt_net/controller/theme/markdown.py +32 -16
  83. pygpt_net/controller/theme/menu.py +26 -5
  84. pygpt_net/controller/theme/nodes.py +2 -5
  85. pygpt_net/controller/tools/__init__.py +40 -2
  86. pygpt_net/controller/ui/__init__.py +4 -6
  87. pygpt_net/controller/ui/mode.py +16 -21
  88. pygpt_net/controller/ui/tabs.py +363 -65
  89. pygpt_net/core/access/actions.py +6 -4
  90. pygpt_net/core/access/shortcuts.py +4 -3
  91. pygpt_net/core/access/voice.py +6 -5
  92. pygpt_net/core/agents/legacy.py +4 -2
  93. pygpt_net/core/agents/memory.py +7 -2
  94. pygpt_net/core/agents/observer/evaluation.py +15 -7
  95. pygpt_net/core/agents/provider.py +9 -4
  96. pygpt_net/core/agents/runner.py +61 -15
  97. pygpt_net/core/agents/tools.py +23 -5
  98. pygpt_net/core/assistants/__init__.py +6 -4
  99. pygpt_net/core/assistants/files.py +35 -12
  100. pygpt_net/core/assistants/store.py +20 -10
  101. pygpt_net/core/attachments/__init__.py +54 -15
  102. pygpt_net/core/attachments/context.py +92 -29
  103. pygpt_net/core/audio/__init__.py +74 -3
  104. pygpt_net/core/audio/context.py +7 -2
  105. pygpt_net/core/audio/whisper.py +37 -0
  106. pygpt_net/core/bridge/__init__.py +22 -6
  107. pygpt_net/core/bridge/context.py +5 -3
  108. pygpt_net/core/bridge/worker.py +2 -2
  109. pygpt_net/core/calendar/__init__.py +57 -11
  110. pygpt_net/core/chain/__init__.py +8 -2
  111. pygpt_net/core/chain/chat.py +10 -8
  112. pygpt_net/core/chain/completion.py +10 -7
  113. pygpt_net/core/command.py +62 -17
  114. pygpt_net/core/ctx/__init__.py +260 -58
  115. pygpt_net/core/ctx/bag.py +25 -4
  116. pygpt_net/core/ctx/container.py +28 -17
  117. pygpt_net/core/ctx/idx.py +45 -8
  118. pygpt_net/core/ctx/output.py +95 -74
  119. pygpt_net/core/ctx/reply.py +5 -2
  120. pygpt_net/core/db/__init__.py +8 -7
  121. pygpt_net/core/db/viewer.py +17 -11
  122. pygpt_net/core/debug/__init__.py +10 -9
  123. pygpt_net/core/debug/events.py +22 -10
  124. pygpt_net/core/debug/tabs.py +9 -3
  125. pygpt_net/core/docker/__init__.py +11 -5
  126. pygpt_net/core/docker/builder.py +11 -3
  127. pygpt_net/core/events/app.py +5 -3
  128. pygpt_net/core/events/base.py +11 -5
  129. pygpt_net/core/events/control.py +5 -3
  130. pygpt_net/core/events/event.py +17 -7
  131. pygpt_net/core/events/kernel.py +5 -3
  132. pygpt_net/core/events/render.py +5 -3
  133. pygpt_net/core/experts/__init__.py +5 -4
  134. pygpt_net/core/filesystem/__init__.py +52 -34
  135. pygpt_net/core/filesystem/actions.py +8 -5
  136. pygpt_net/core/filesystem/editor.py +13 -3
  137. pygpt_net/core/filesystem/types.py +12 -7
  138. pygpt_net/core/filesystem/url.py +7 -3
  139. pygpt_net/core/history.py +3 -2
  140. pygpt_net/core/idx/__init__.py +48 -27
  141. pygpt_net/core/idx/chat.py +51 -17
  142. pygpt_net/core/idx/context.py +6 -2
  143. pygpt_net/core/idx/indexing.py +107 -42
  144. pygpt_net/core/idx/llm.py +11 -3
  145. pygpt_net/core/idx/metadata.py +13 -3
  146. pygpt_net/core/idx/types/ctx.py +32 -6
  147. pygpt_net/core/idx/types/external.py +41 -7
  148. pygpt_net/core/idx/types/files.py +31 -6
  149. pygpt_net/core/image.py +15 -4
  150. pygpt_net/core/installer.py +2 -4
  151. pygpt_net/core/llm/__init__.py +13 -3
  152. pygpt_net/core/locale.py +34 -8
  153. pygpt_net/core/models.py +63 -17
  154. pygpt_net/core/modes.py +11 -13
  155. pygpt_net/core/notepad.py +10 -5
  156. pygpt_net/core/plugins.py +31 -19
  157. pygpt_net/core/presets.py +37 -17
  158. pygpt_net/core/profile.py +21 -7
  159. pygpt_net/core/prompt/__init__.py +10 -3
  160. pygpt_net/core/prompt/custom.py +7 -6
  161. pygpt_net/core/prompt/template.py +9 -3
  162. pygpt_net/core/render/base.py +117 -22
  163. pygpt_net/core/render/markdown/body.py +27 -7
  164. pygpt_net/core/render/markdown/renderer.py +119 -22
  165. pygpt_net/core/render/plain/body.py +22 -5
  166. pygpt_net/core/render/plain/renderer.py +97 -21
  167. pygpt_net/core/render/web/body.py +75 -25
  168. pygpt_net/core/render/web/parser.py +3 -1
  169. pygpt_net/core/render/web/renderer.py +313 -63
  170. pygpt_net/core/settings.py +10 -5
  171. pygpt_net/core/tabs/__init__.py +290 -103
  172. pygpt_net/core/tabs/tab.py +26 -5
  173. pygpt_net/core/tokens.py +47 -12
  174. pygpt_net/core/updater/__init__.py +20 -7
  175. pygpt_net/core/vision/analyzer.py +29 -6
  176. pygpt_net/core/{web.py → web/__init__.py} +29 -7
  177. pygpt_net/core/web/helpers.py +237 -0
  178. pygpt_net/data/config/config.json +15 -4
  179. pygpt_net/data/config/models.json +3 -3
  180. pygpt_net/data/config/modes.json +3 -3
  181. pygpt_net/data/config/settings.json +55 -10
  182. pygpt_net/data/config/settings_section.json +3 -0
  183. pygpt_net/data/css/style.light.css +1 -0
  184. pygpt_net/data/css/{web.css → web-blocks.css} +162 -133
  185. pygpt_net/data/css/{web.light.css → web-blocks.light.css} +7 -0
  186. pygpt_net/data/css/web-chatgpt.css +350 -0
  187. pygpt_net/data/css/web-chatgpt.dark.css +64 -0
  188. pygpt_net/data/css/web-chatgpt.light.css +75 -0
  189. pygpt_net/data/css/web-chatgpt_wide.css +350 -0
  190. pygpt_net/data/css/web-chatgpt_wide.dark.css +64 -0
  191. pygpt_net/data/css/web-chatgpt_wide.light.css +75 -0
  192. pygpt_net/data/icons/split_screen.svg +1 -0
  193. pygpt_net/data/locale/locale.de.ini +12 -0
  194. pygpt_net/data/locale/locale.en.ini +18 -2
  195. pygpt_net/data/locale/locale.es.ini +12 -0
  196. pygpt_net/data/locale/locale.fr.ini +12 -0
  197. pygpt_net/data/locale/locale.it.ini +12 -0
  198. pygpt_net/data/locale/locale.pl.ini +12 -0
  199. pygpt_net/data/locale/locale.uk.ini +12 -0
  200. pygpt_net/data/locale/locale.zh.ini +12 -0
  201. pygpt_net/data/locale/plugin.cmd_web.de.ini +2 -0
  202. pygpt_net/data/locale/plugin.cmd_web.en.ini +22 -10
  203. pygpt_net/data/locale/plugin.cmd_web.es.ini +2 -0
  204. pygpt_net/data/locale/plugin.cmd_web.fr.ini +2 -0
  205. pygpt_net/data/locale/plugin.cmd_web.it.ini +2 -0
  206. pygpt_net/data/locale/plugin.cmd_web.pl.ini +2 -0
  207. pygpt_net/data/locale/plugin.cmd_web.uk.ini +2 -0
  208. pygpt_net/data/locale/plugin.cmd_web.zh.ini +2 -0
  209. pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
  210. pygpt_net/icons.qrc +1 -0
  211. pygpt_net/icons_rc.py +165 -136
  212. pygpt_net/item/ctx.py +58 -25
  213. pygpt_net/plugin/agent/__init__.py +7 -2
  214. pygpt_net/plugin/audio_input/simple.py +21 -5
  215. pygpt_net/plugin/audio_output/__init__.py +9 -1
  216. pygpt_net/plugin/base/config.py +4 -2
  217. pygpt_net/plugin/base/plugin.py +75 -23
  218. pygpt_net/plugin/base/worker.py +42 -11
  219. pygpt_net/plugin/cmd_code_interpreter/__init__.py +39 -37
  220. pygpt_net/plugin/cmd_code_interpreter/runner.py +25 -12
  221. pygpt_net/plugin/cmd_history/config.py +2 -2
  222. pygpt_net/plugin/cmd_web/__init__.py +48 -9
  223. pygpt_net/plugin/cmd_web/config.py +135 -41
  224. pygpt_net/plugin/cmd_web/websearch.py +74 -33
  225. pygpt_net/plugin/cmd_web/worker.py +142 -13
  226. pygpt_net/plugin/idx_llama_index/config.py +3 -3
  227. pygpt_net/plugin/mailer/__init__.py +123 -0
  228. pygpt_net/plugin/mailer/config.py +149 -0
  229. pygpt_net/plugin/mailer/runner.py +285 -0
  230. pygpt_net/plugin/mailer/worker.py +123 -0
  231. pygpt_net/provider/agents/base.py +5 -2
  232. pygpt_net/provider/agents/openai.py +4 -2
  233. pygpt_net/provider/agents/openai_assistant.py +4 -2
  234. pygpt_net/provider/agents/planner.py +4 -2
  235. pygpt_net/provider/agents/react.py +4 -2
  236. pygpt_net/provider/audio_output/openai_tts.py +5 -11
  237. pygpt_net/provider/core/assistant/base.py +5 -3
  238. pygpt_net/provider/core/assistant/json_file.py +8 -5
  239. pygpt_net/provider/core/assistant_file/base.py +4 -3
  240. pygpt_net/provider/core/assistant_file/db_sqlite/__init__.py +4 -3
  241. pygpt_net/provider/core/assistant_file/db_sqlite/storage.py +3 -2
  242. pygpt_net/provider/core/assistant_store/base.py +6 -4
  243. pygpt_net/provider/core/assistant_store/db_sqlite/__init__.py +5 -4
  244. pygpt_net/provider/core/assistant_store/db_sqlite/storage.py +5 -3
  245. pygpt_net/provider/core/attachment/base.py +5 -3
  246. pygpt_net/provider/core/attachment/json_file.py +4 -3
  247. pygpt_net/provider/core/calendar/base.py +5 -3
  248. pygpt_net/provider/core/calendar/db_sqlite/__init__.py +6 -5
  249. pygpt_net/provider/core/calendar/db_sqlite/storage.py +5 -4
  250. pygpt_net/provider/core/config/base.py +8 -6
  251. pygpt_net/provider/core/config/json_file.py +9 -7
  252. pygpt_net/provider/core/config/patch.py +43 -1
  253. pygpt_net/provider/core/ctx/base.py +30 -25
  254. pygpt_net/provider/core/ctx/db_sqlite/__init__.py +59 -34
  255. pygpt_net/provider/core/ctx/db_sqlite/storage.py +62 -30
  256. pygpt_net/provider/core/ctx/db_sqlite/utils.py +11 -9
  257. pygpt_net/provider/core/index/base.py +129 -23
  258. pygpt_net/provider/core/index/db_sqlite/__init__.py +130 -23
  259. pygpt_net/provider/core/index/db_sqlite/storage.py +130 -23
  260. pygpt_net/provider/core/index/db_sqlite/utils.py +4 -2
  261. pygpt_net/provider/core/mode/base.py +5 -3
  262. pygpt_net/provider/core/mode/json_file.py +7 -6
  263. pygpt_net/provider/core/model/base.py +6 -4
  264. pygpt_net/provider/core/model/json_file.py +9 -7
  265. pygpt_net/provider/core/notepad/base.py +5 -3
  266. pygpt_net/provider/core/notepad/db_sqlite/__init__.py +5 -4
  267. pygpt_net/provider/core/notepad/db_sqlite/storage.py +4 -3
  268. pygpt_net/provider/core/plugin_preset/base.py +4 -2
  269. pygpt_net/provider/core/plugin_preset/json_file.py +5 -3
  270. pygpt_net/provider/core/preset/base.py +6 -4
  271. pygpt_net/provider/core/preset/json_file.py +9 -9
  272. pygpt_net/provider/core/prompt/base.py +6 -3
  273. pygpt_net/provider/core/prompt/json_file.py +11 -6
  274. pygpt_net/provider/gpt/assistants.py +21 -11
  275. pygpt_net/provider/gpt/audio.py +6 -5
  276. pygpt_net/provider/gpt/chat.py +10 -7
  277. pygpt_net/provider/gpt/completion.py +11 -5
  278. pygpt_net/provider/gpt/image.py +9 -2
  279. pygpt_net/provider/gpt/store.py +53 -18
  280. pygpt_net/provider/gpt/vision.py +17 -11
  281. pygpt_net/provider/llms/anthropic.py +7 -2
  282. pygpt_net/provider/llms/azure_openai.py +26 -5
  283. pygpt_net/provider/llms/base.py +47 -9
  284. pygpt_net/provider/llms/google.py +7 -2
  285. pygpt_net/provider/llms/hugging_face.py +13 -3
  286. pygpt_net/provider/llms/hugging_face_api.py +18 -4
  287. pygpt_net/provider/llms/local.py +7 -2
  288. pygpt_net/provider/llms/ollama.py +30 -6
  289. pygpt_net/provider/llms/openai.py +32 -6
  290. pygpt_net/provider/vector_stores/__init__.py +45 -14
  291. pygpt_net/provider/vector_stores/base.py +35 -8
  292. pygpt_net/provider/vector_stores/chroma.py +13 -3
  293. pygpt_net/provider/vector_stores/ctx_attachment.py +31 -12
  294. pygpt_net/provider/vector_stores/elasticsearch.py +12 -3
  295. pygpt_net/provider/vector_stores/pinecode.py +12 -3
  296. pygpt_net/provider/vector_stores/redis.py +12 -3
  297. pygpt_net/provider/vector_stores/simple.py +12 -3
  298. pygpt_net/provider/vector_stores/temp.py +16 -4
  299. pygpt_net/provider/web/base.py +10 -3
  300. pygpt_net/provider/web/google_custom_search.py +9 -3
  301. pygpt_net/provider/web/microsoft_bing.py +9 -3
  302. pygpt_net/tools/__init__.py +20 -4
  303. pygpt_net/tools/audio_transcriber/__init__.py +4 -3
  304. pygpt_net/tools/base.py +28 -7
  305. pygpt_net/tools/code_interpreter/__init__.py +177 -77
  306. pygpt_net/tools/code_interpreter/ui/dialogs.py +21 -103
  307. pygpt_net/tools/code_interpreter/ui/widgets.py +284 -9
  308. pygpt_net/tools/html_canvas/__init__.py +81 -25
  309. pygpt_net/tools/html_canvas/ui/dialogs.py +46 -62
  310. pygpt_net/tools/html_canvas/ui/widgets.py +96 -3
  311. pygpt_net/tools/image_viewer/__init__.py +10 -4
  312. pygpt_net/tools/indexer/__init__.py +8 -7
  313. pygpt_net/tools/media_player/__init__.py +4 -3
  314. pygpt_net/tools/text_editor/__init__.py +36 -10
  315. pygpt_net/ui/base/context_menu.py +2 -2
  316. pygpt_net/ui/layout/chat/input.py +10 -18
  317. pygpt_net/ui/layout/chat/output.py +27 -45
  318. pygpt_net/ui/layout/ctx/ctx_list.py +13 -4
  319. pygpt_net/ui/layout/toolbox/footer.py +18 -2
  320. pygpt_net/ui/main.py +2 -2
  321. pygpt_net/ui/menu/audio.py +12 -1
  322. pygpt_net/ui/menu/config.py +7 -11
  323. pygpt_net/ui/menu/debug.py +11 -1
  324. pygpt_net/ui/menu/theme.py +9 -2
  325. pygpt_net/ui/widget/filesystem/explorer.py +2 -2
  326. pygpt_net/ui/widget/lists/context.py +27 -5
  327. pygpt_net/ui/widget/tabs/Input.py +2 -2
  328. pygpt_net/ui/widget/tabs/body.py +2 -1
  329. pygpt_net/ui/widget/tabs/layout.py +195 -0
  330. pygpt_net/ui/widget/tabs/output.py +218 -55
  331. pygpt_net/ui/widget/textarea/html.py +11 -1
  332. pygpt_net/ui/widget/textarea/output.py +10 -1
  333. pygpt_net/ui/widget/textarea/search_input.py +4 -1
  334. pygpt_net/ui/widget/textarea/web.py +49 -9
  335. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/METADATA +177 -183
  336. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/RECORD +340 -325
  337. /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
  338. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/LICENSE +0 -0
  339. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/WHEEL +0 -0
  340. {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/entry_points.txt +0 -0
@@ -6,9 +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.02.27 04:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Optional
13
+
14
+
12
15
  class Ctx:
13
16
  def __init__(self, window=None, provider=None):
14
17
  """
@@ -43,7 +46,12 @@ class Ctx:
43
46
  doc_id=doc_id,
44
47
  )
45
48
 
46
- def exists(self, store_id: str, idx: str, meta_id: int) -> bool:
49
+ def exists(
50
+ self,
51
+ store_id: str,
52
+ idx: str,
53
+ meta_id: int
54
+ ) -> bool:
47
55
  """
48
56
  Check if ctx meta is indexed
49
57
 
@@ -58,7 +66,12 @@ class Ctx:
58
66
  meta_id=meta_id,
59
67
  )
60
68
 
61
- def get_doc_id(self, store_id: str, idx: str, meta_id: int) -> str:
69
+ def get_doc_id(
70
+ self,
71
+ store_id: str,
72
+ idx: str,
73
+ meta_id: int
74
+ ) -> str:
62
75
  """
63
76
  Get indexed document id by meta id
64
77
 
@@ -73,7 +86,11 @@ class Ctx:
73
86
  meta_id=meta_id,
74
87
  )
75
88
 
76
- def update(self, meta_id: int, doc_id: str) -> bool:
89
+ def update(
90
+ self,
91
+ meta_id: int,
92
+ doc_id: str
93
+ ) -> bool:
77
94
  """
78
95
  Update timestamp of indexed ctx meta
79
96
 
@@ -86,7 +103,12 @@ class Ctx:
86
103
  doc_id=doc_id,
87
104
  )
88
105
 
89
- def remove(self, store_id: str, idx: str, meta_id: str):
106
+ def remove(
107
+ self,
108
+ store_id: str,
109
+ idx: str,
110
+ meta_id: str
111
+ ):
90
112
  """
91
113
  Remove document from index db
92
114
 
@@ -100,7 +122,11 @@ class Ctx:
100
122
  meta_id=meta_id,
101
123
  )
102
124
 
103
- def truncate(self, store_id: str = None, idx: str = None):
125
+ def truncate(
126
+ self,
127
+ store_id: Optional[str] = None,
128
+ idx: Optional[str] = None
129
+ ):
104
130
  """
105
131
  Truncate ctx meta from index db
106
132
 
@@ -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.02.27 04:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import datetime
13
13
  import time
14
+ from typing import Optional
14
15
 
15
16
 
16
17
  class External:
@@ -54,7 +55,13 @@ class External:
54
55
  data=data,
55
56
  )
56
57
 
57
- def get_doc_id(self, store_id: str, idx: str, content: str, type: str) -> str:
58
+ def get_doc_id(
59
+ self,
60
+ store_id: str,
61
+ idx: str,
62
+ content: str,
63
+ type: str
64
+ ) -> str:
58
65
  """
59
66
  Get indexed document id by content
60
67
 
@@ -71,7 +78,13 @@ class External:
71
78
  type=type,
72
79
  )
73
80
 
74
- def exists(self, store_id: str, idx: str, content: str, type: str) -> bool:
81
+ def exists(
82
+ self,
83
+ store_id: str,
84
+ idx: str,
85
+ content: str,
86
+ type: str
87
+ ) -> bool:
75
88
  """
76
89
  Check if content is indexed
77
90
 
@@ -88,7 +101,13 @@ class External:
88
101
  type=type,
89
102
  )
90
103
 
91
- def update(self, content: str, type: str, doc_id: str, ts: int) -> bool:
104
+ def update(
105
+ self,
106
+ content: str,
107
+ type: str,
108
+ doc_id: str,
109
+ ts: int
110
+ ) -> bool:
92
111
  """
93
112
  Update timestamp of indexed external content
94
113
 
@@ -105,7 +124,12 @@ class External:
105
124
  ts=ts,
106
125
  )
107
126
 
108
- def remove(self, store_id: str, idx: str, doc_id: str):
127
+ def remove(
128
+ self,
129
+ store_id: str,
130
+ idx: str,
131
+ doc_id: str
132
+ ):
109
133
  """
110
134
  Remove document from index
111
135
 
@@ -119,7 +143,11 @@ class External:
119
143
  doc_id=doc_id,
120
144
  )
121
145
 
122
- def truncate(self, store_id: str = None, idx: str = None):
146
+ def truncate(
147
+ self,
148
+ store_id: Optional[str] = None,
149
+ idx: Optional[str] = None
150
+ ):
123
151
  """
124
152
  Truncate external data from index
125
153
 
@@ -131,7 +159,13 @@ class External:
131
159
  idx=idx,
132
160
  )
133
161
 
134
- def set_indexed(self, content: str, type: str, idx: str, doc_id: str) -> bool:
162
+ def set_indexed(
163
+ self,
164
+ content: str,
165
+ type: str,
166
+ idx: str,
167
+ doc_id: str
168
+ ) -> bool:
135
169
  """
136
170
  Set external content as indexed
137
171
 
@@ -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.02.27 04:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import datetime
13
13
  import os.path
14
+ from typing import Optional
14
15
 
15
16
 
16
17
  class Files:
@@ -67,7 +68,12 @@ class Files:
67
68
  path = path.replace("\\", "/").strip(r'\/')
68
69
  return path
69
70
 
70
- def get_doc_id(self, store_id: str, idx: str, file_id: str) -> str:
71
+ def get_doc_id(
72
+ self,
73
+ store_id: str,
74
+ idx: str,
75
+ file_id: str
76
+ ) -> str:
71
77
  """
72
78
  Get indexed document id by file
73
79
 
@@ -82,7 +88,12 @@ class Files:
82
88
  file_id=file_id,
83
89
  )
84
90
 
85
- def exists(self, store_id: str, idx: str, file_id: str) -> bool:
91
+ def exists(
92
+ self,
93
+ store_id: str,
94
+ idx: str,
95
+ file_id: str
96
+ ) -> bool:
86
97
  """
87
98
  Check if file is indexed
88
99
 
@@ -97,7 +108,12 @@ class Files:
97
108
  file_id=file_id,
98
109
  )
99
110
 
100
- def update(self, id: int, doc_id: str, ts: int) -> bool:
111
+ def update(
112
+ self,
113
+ id: int,
114
+ doc_id: str,
115
+ ts: int
116
+ ) -> bool:
101
117
  """
102
118
  Update timestamp of indexed file
103
119
 
@@ -112,7 +128,12 @@ class Files:
112
128
  ts=ts,
113
129
  )
114
130
 
115
- def remove(self, store_id: str, idx: str, doc_id: str):
131
+ def remove(
132
+ self,
133
+ store_id: str,
134
+ idx: str,
135
+ doc_id: str
136
+ ):
116
137
  """
117
138
  Remove document from index
118
139
 
@@ -126,7 +147,11 @@ class Files:
126
147
  doc_id=doc_id,
127
148
  )
128
149
 
129
- def truncate(self, store_id: str = None, idx: str = None):
150
+ def truncate(
151
+ self,
152
+ store_id: Optional[str] = None,
153
+ idx: Optional[str] = None
154
+ ):
130
155
  """
131
156
  Truncate files from index
132
157
 
pygpt_net/core/image.py CHANGED
@@ -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 List
13
14
 
14
15
  from PySide6.QtCore import Slot, QObject
15
16
 
@@ -34,7 +35,12 @@ class Image(QObject):
34
35
  os.makedirs(img_dir, exist_ok=True)
35
36
 
36
37
  @Slot(object, list, str)
37
- def handle_finished(self, ctx: CtxItem, paths: list, prompt: str):
38
+ def handle_finished(
39
+ self,
40
+ ctx: CtxItem,
41
+ paths: List[str],
42
+ prompt: str
43
+ ):
38
44
  """
39
45
  Handle finished image generation
40
46
 
@@ -45,7 +51,12 @@ class Image(QObject):
45
51
  self.window.controller.chat.image.handle_response(ctx, paths, prompt)
46
52
 
47
53
  @Slot(object, list, str)
48
- def handle_finished_inline(self, ctx: CtxItem, paths: list, prompt: str):
54
+ def handle_finished_inline(
55
+ self,
56
+ ctx: CtxItem,
57
+ paths: List[str],
58
+ prompt: str
59
+ ):
49
60
  """
50
61
  Handle finished image generation
51
62
 
@@ -86,7 +97,7 @@ class Image(QObject):
86
97
  self.window.update_status(msg)
87
98
  self.window.core.debug.log(msg)
88
99
 
89
- def save_image(self, path: str, image: any) -> bool:
100
+ def save_image(self, path: str, image: bytes) -> bool:
90
101
  """
91
102
  Save image to file
92
103
 
@@ -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: 2023.12.31 04:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from pathlib import Path
@@ -23,9 +23,7 @@ class Installer:
23
23
  self.window = window
24
24
 
25
25
  def install(self):
26
- """
27
- Install db, config data and directories
28
- """
26
+ """Install db, config data and directories"""
29
27
  try:
30
28
  # create user config directory
31
29
  path = Path(self.window.core.config.path)
@@ -6,9 +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.01.14 04:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Optional, List
13
+
14
+
12
15
  class LLM:
13
16
  def __init__(self, window=None):
14
17
  """
@@ -19,7 +22,10 @@ class LLM:
19
22
  self.window = window
20
23
  self.llms = {}
21
24
 
22
- def get_ids(self, type: str = None) -> list:
25
+ def get_ids(
26
+ self,
27
+ type: Optional[str] = None
28
+ ) -> List[str]:
23
29
  """
24
30
  Get providers ids
25
31
 
@@ -30,7 +36,11 @@ class LLM:
30
36
  return [id for id in self.llms.keys() if type in self.llms[id].type]
31
37
  return list(self.llms.keys())
32
38
 
33
- def register(self, id: str, llm):
39
+ def register(
40
+ self,
41
+ id: str,
42
+ llm
43
+ ):
34
44
  """
35
45
  Register LLM provider
36
46
 
pygpt_net/core/locale.py CHANGED
@@ -6,18 +6,23 @@
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.15 10:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import os
13
13
  import configparser
14
14
  import io
15
+ from typing import Optional
15
16
 
16
17
  from pygpt_net.config import Config
17
18
 
18
19
 
19
20
  class Locale:
20
- def __init__(self, domain: str = None, config=None):
21
+ def __init__(
22
+ self,
23
+ domain: Optional[str] = None,
24
+ config: Optional[Config] = None
25
+ ):
21
26
  """
22
27
  Locale loader
23
28
 
@@ -47,7 +52,7 @@ class Locale:
47
52
  self.lang = self.config.get_lang()
48
53
  self.load(self.lang)
49
54
 
50
- def reload(self, domain: str = None):
55
+ def reload(self, domain: Optional[str] = None):
51
56
  """
52
57
  Reload translations for domain
53
58
 
@@ -70,7 +75,11 @@ class Locale:
70
75
  ini.read_string(data.read())
71
76
  return dict(ini.items(self.ini_key))
72
77
 
73
- def load_by_lang(self, lang: str, domain: str = None):
78
+ def load_by_lang(
79
+ self,
80
+ lang: str,
81
+ domain: Optional[str] = None
82
+ ):
74
83
  """
75
84
  Load translation data by language code
76
85
 
@@ -96,7 +105,11 @@ class Locale:
96
105
  except Exception as e:
97
106
  print(e)
98
107
 
99
- def load(self, lang: str, domain: str = None):
108
+ def load(
109
+ self,
110
+ lang: str,
111
+ domain: Optional[str] = None
112
+ ):
100
113
  """
101
114
  Load translation data
102
115
 
@@ -109,7 +122,12 @@ class Locale:
109
122
  self.load_by_lang(self.fallback, domain) # load fallback first
110
123
  self.load_by_lang(lang, domain)
111
124
 
112
- def get(self, key: str, domain: str = None, params: dict = None) -> str:
125
+ def get(
126
+ self,
127
+ key: str,
128
+ domain: Optional[str] = None,
129
+ params: Optional[dict] = None
130
+ ) -> str:
113
131
  """
114
132
  Return translation for key and domain
115
133
 
@@ -133,7 +151,11 @@ class Locale:
133
151
  else:
134
152
  return key
135
153
 
136
- def get_base_path(self, domain: str, lang: str) -> str:
154
+ def get_base_path(
155
+ self,
156
+ domain: str,
157
+ lang: str
158
+ ) -> str:
137
159
  """
138
160
  Get base path for locale file
139
161
 
@@ -143,7 +165,11 @@ class Locale:
143
165
  """
144
166
  return os.path.join(self.config.get_app_path(), 'data', 'locale', domain + '.' + lang + '.ini')
145
167
 
146
- def get_user_path(self, domain: str, lang: str) -> str:
168
+ def get_user_path(
169
+ self,
170
+ domain: str,
171
+ lang: str
172
+ ) -> str:
147
173
  """
148
174
  Get user path for locale file (overwrites base path)
149
175
 
pygpt_net/core/models.py CHANGED
@@ -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.21 20:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
+ from typing import Optional, List, Dict
13
14
 
14
15
  from packaging.version import Version
15
16
 
@@ -91,7 +92,7 @@ class Models:
91
92
  if key in self.items:
92
93
  return self.items[key]
93
94
 
94
- def get_ids(self) -> list:
95
+ def get_ids(self) -> List[str]:
95
96
  """
96
97
  Return models ids
97
98
 
@@ -117,7 +118,11 @@ class Models:
117
118
  """
118
119
  return model in self.items
119
120
 
120
- def is_allowed(self, model: str, mode: str) -> bool:
121
+ def is_allowed(
122
+ self,
123
+ model: str,
124
+ mode: str
125
+ ) -> bool:
121
126
  """
122
127
  Check if model is allowed for mode
123
128
 
@@ -129,7 +134,10 @@ class Models:
129
134
  return mode in self.items[model].mode
130
135
  return False
131
136
 
132
- def get_id(self, key: str) -> str:
137
+ def get_id(
138
+ self,
139
+ key: str
140
+ ) -> str:
133
141
  """
134
142
  Return model internal ID
135
143
 
@@ -139,7 +147,11 @@ class Models:
139
147
  if key in self.items:
140
148
  return self.items[key].id
141
149
 
142
- def get_by_idx(self, idx: int, mode: str) -> str:
150
+ def get_by_idx(
151
+ self,
152
+ idx: int,
153
+ mode: str
154
+ ) -> str:
143
155
  """
144
156
  Return model by index
145
157
 
@@ -150,7 +162,10 @@ class Models:
150
162
  items = self.get_by_mode(mode)
151
163
  return list(items.keys())[idx]
152
164
 
153
- def get_by_mode(self, mode: str) -> dict:
165
+ def get_by_mode(
166
+ self,
167
+ mode: str
168
+ ) -> Dict[str, ModelItem]:
154
169
  """
155
170
  Return models for mode
156
171
 
@@ -163,7 +178,11 @@ class Models:
163
178
  items[key] = self.items[key]
164
179
  return items
165
180
 
166
- def get_next(self, model: str, mode: str) -> str:
181
+ def get_next(
182
+ self,
183
+ model: str,
184
+ mode: str
185
+ ) -> str:
167
186
  """
168
187
  Return next model
169
188
 
@@ -178,7 +197,11 @@ class Models:
178
197
  return keys[idx + 1]
179
198
  return keys[0]
180
199
 
181
- def get_prev(self, model: str, mode: str) -> str:
200
+ def get_prev(
201
+ self,
202
+ model: str,
203
+ mode: str
204
+ ) -> str:
182
205
  """
183
206
  Return previous model
184
207
 
@@ -217,7 +240,7 @@ class Models:
217
240
  self.items[id] = model
218
241
  return model
219
242
 
220
- def get_all(self) -> dict:
243
+ def get_all(self) -> Dict[str, ModelItem]:
221
244
  """
222
245
  Return all models
223
246
 
@@ -247,7 +270,11 @@ class Models:
247
270
  if model in self.items:
248
271
  del self.items[model]
249
272
 
250
- def has_model(self, mode: str, model: str) -> bool:
273
+ def has_model(
274
+ self,
275
+ mode: str,
276
+ model: str
277
+ ) -> bool:
251
278
  """
252
279
  Check if model exists for mode
253
280
 
@@ -258,7 +285,7 @@ class Models:
258
285
  items = self.get_by_mode(mode)
259
286
  return model in items
260
287
 
261
- def get_default(self, mode: str) -> str | None:
288
+ def get_default(self, mode: str) -> Optional[str]:
262
289
  """
263
290
  Return default model for mode
264
291
 
@@ -295,8 +322,15 @@ class Models:
295
322
  return self.items[model].ctx
296
323
  return 4096
297
324
 
298
- def restore_default(self, model: str = None):
299
- """Restore default models"""
325
+ def restore_default(
326
+ self,
327
+ model: Optional[str] = None
328
+ ):
329
+ """
330
+ Restore default models
331
+
332
+ :param model: model name
333
+ """
300
334
  # restore all models
301
335
  if model is None:
302
336
  self.load_base()
@@ -307,8 +341,12 @@ class Models:
307
341
  if model in items:
308
342
  self.items[model] = items[model]
309
343
 
310
- def get_base(self) -> dict:
311
- """Get base models"""
344
+ def get_base(self) -> Dict[str, ModelItem]:
345
+ """
346
+ Get base models
347
+
348
+ :return: base models
349
+ """
312
350
  return self.provider.load_base()
313
351
 
314
352
  def load_base(self):
@@ -329,7 +367,11 @@ class Models:
329
367
  """Save models"""
330
368
  self.provider.save(self.items)
331
369
 
332
- def get_supported_mode(self, model: ModelItem, mode: str) -> str:
370
+ def get_supported_mode(
371
+ self,
372
+ model: ModelItem,
373
+ mode: str
374
+ ) -> str:
333
375
  """
334
376
  Get supported mode
335
377
 
@@ -352,5 +394,9 @@ class Models:
352
394
  return mode
353
395
 
354
396
  def get_version(self) -> str:
355
- """Get config version"""
397
+ """
398
+ Get config version
399
+
400
+ :return: config version
401
+ """
356
402
  return self.provider.get_version()