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,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 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
+ from typing import Optional
13
14
 
14
15
  from packaging.version import Version
15
16
 
@@ -258,7 +259,7 @@ class Models:
258
259
  items = self.get_by_mode(mode)
259
260
  return model in items
260
261
 
261
- def get_default(self, mode: str) -> str | None:
262
+ def get_default(self, mode: str) -> Optional[str]:
262
263
  """
263
264
  Return default model for mode
264
265
 
@@ -295,7 +296,7 @@ class Models:
295
296
  return self.items[model].ctx
296
297
  return 4096
297
298
 
298
- def restore_default(self, model: str = None):
299
+ def restore_default(self, model: Optional[str] = None):
299
300
  """Restore default models"""
300
301
  # restore all models
301
302
  if model is None:
pygpt_net/core/notepad.py CHANGED
@@ -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.04.09 23:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import datetime
13
13
  import uuid
14
+ from typing import Optional
14
15
 
15
16
  from packaging.version import Version
16
17
 
@@ -49,7 +50,7 @@ class Notepad:
49
50
  """Reset provider data"""
50
51
  self.items = {}
51
52
 
52
- def get_by_id(self, idx: int) -> NotepadItem or None:
53
+ def get_by_id(self, idx: int) -> Optional[NotepadItem]:
53
54
  """
54
55
  Get notepad by idx
55
56
 
@@ -136,8 +137,12 @@ class Notepad:
136
137
  """Save all notepads"""
137
138
  self.provider.save_all(self.items)
138
139
 
139
- def import_from_db(self) -> dict or None:
140
- """Import notepad tabs from database"""
140
+ def import_from_db(self) -> Optional[dict]:
141
+ """
142
+ Import notepad tabs from database
143
+
144
+ :return: dict with tabs
145
+ """
141
146
  self.load_all()
142
147
  items = self.get_all()
143
148
  if len(items) == 0:
pygpt_net/core/plugins.py CHANGED
@@ -6,13 +6,14 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.11.18 21:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
13
  import configparser
14
14
  import io
15
15
  import os
16
+ from typing import Optional, Dict, List, Any
16
17
 
17
18
  from pygpt_net.provider.core.plugin_preset.json_file import JsonFileProvider
18
19
  from pygpt_net.plugin.base.plugin import BasePlugin
@@ -64,7 +65,7 @@ class Plugins:
64
65
  """
65
66
  return list(self.plugins.keys())
66
67
 
67
- def get(self, id: str) -> BasePlugin or None:
68
+ def get(self, id: str) -> Optional[BasePlugin]:
68
69
  """
69
70
  Get plugin by id
70
71
 
@@ -142,7 +143,7 @@ class Plugins:
142
143
  if removed:
143
144
  self.window.core.config.save()
144
145
 
145
- def register_options(self, id: str, options: dict):
146
+ def register_options(self, id: str, options: Dict[str, dict]):
146
147
  """
147
148
  Register plugin options
148
149
 
@@ -276,7 +277,7 @@ class Plugins:
276
277
  tooltip = trans('plugin.description', domain=domain)
277
278
  return tooltip
278
279
 
279
- def dump_locale(self, plugin, path: str):
280
+ def dump_locale(self, plugin: BasePlugin, path: str):
280
281
  """
281
282
  Dump locale
282
283
 
@@ -356,7 +357,7 @@ class Plugins:
356
357
  """
357
358
  return self.presets
358
359
 
359
- def reset_options(self, plugin_id: str, keys: list):
360
+ def reset_options(self, plugin_id: str, keys: List[str]):
360
361
  """
361
362
  Reset plugin options
362
363
 
@@ -430,7 +431,7 @@ class Plugins:
430
431
  if updated:
431
432
  self.save_presets()
432
433
 
433
- def update_preset_values(self, plugin_id:str, key: str, value: any):
434
+ def update_preset_values(self, plugin_id: str, key: str, value: Any):
434
435
  """
435
436
  Update preset value
436
437
 
pygpt_net/core/presets.py CHANGED
@@ -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 19:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
13
  import uuid
14
+ from typing import Optional, Tuple, Dict
14
15
 
15
16
  from packaging.version import Version
16
17
  from pygpt_net.core.types import (
@@ -47,7 +48,11 @@ class Presets:
47
48
  self.provider.install()
48
49
 
49
50
  def patch(self, app_version: Version):
50
- """Patch provider data"""
51
+ """
52
+ Patch provider data
53
+
54
+ :param app_version: app version
55
+ """
51
56
  self.provider.patch(app_version)
52
57
 
53
58
  def build(self) -> PresetItem:
@@ -197,7 +202,7 @@ class Presets:
197
202
  if id in self.items:
198
203
  self.items[id].enabled = False
199
204
 
200
- def get_first_mode(self, id: str) -> str or None:
205
+ def get_first_mode(self, id: str) -> Optional[str]:
201
206
  """
202
207
  Return first mode for preset
203
208
 
@@ -253,7 +258,7 @@ class Presets:
253
258
  presets = self.get_by_mode(mode)
254
259
  return list(presets.keys())[idx]
255
260
 
256
- def get_by_id(self, mode: str, id: str) -> PresetItem or None:
261
+ def get_by_id(self, mode: str, id: str) -> Optional[PresetItem]:
257
262
  """
258
263
  Return preset by id
259
264
 
@@ -266,7 +271,7 @@ class Presets:
266
271
  return presets[id]
267
272
  return None
268
273
 
269
- def get_by_uuid(self, uuid: str) -> PresetItem or None:
274
+ def get_by_uuid(self, uuid: str) -> Optional[PresetItem]:
270
275
  """
271
276
  Return preset by UUID
272
277
 
@@ -278,7 +283,7 @@ class Presets:
278
283
  return self.items[id]
279
284
  return None
280
285
 
281
- def get_by_mode(self, mode: str) -> dict:
286
+ def get_by_mode(self, mode: str) -> Dict[str, PresetItem]:
282
287
  """
283
288
  Return presets for mode
284
289
 
@@ -317,7 +322,7 @@ class Presets:
317
322
  i += 1
318
323
  return 0
319
324
 
320
- def get_default(self, mode: str) -> str or None:
325
+ def get_default(self, mode: str) -> Optional[str]:
321
326
  """
322
327
  Return default preset for mode
323
328
 
@@ -329,7 +334,7 @@ class Presets:
329
334
  return None
330
335
  return list(presets.keys())[0]
331
336
 
332
- def get_duplicate_name(self, id: str) -> (str, str):
337
+ def get_duplicate_name(self, id: str) -> Tuple[str, str]:
333
338
  """
334
339
  Prepare name for duplicated preset
335
340
 
@@ -423,8 +428,12 @@ class Presets:
423
428
  self.items[id] = base[id]
424
429
  self.save(id)
425
430
 
426
- def load_base(self):
427
- """Load base presets"""
431
+ def load_base(self) -> dict:
432
+ """
433
+ Load base presets
434
+
435
+ :return: base presets
436
+ """
428
437
  return self.provider.load_base()
429
438
 
430
439
  def load(self):
pygpt_net/core/profile.py CHANGED
@@ -6,12 +6,13 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.04.09 23:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
13
13
  import os
14
14
  from pathlib import Path
15
+ from typing import Optional, Dict
15
16
  from uuid import uuid4
16
17
 
17
18
 
@@ -44,7 +45,7 @@ class Profile:
44
45
  self.load()
45
46
  self.update_path()
46
47
 
47
- def set_base_workdir(self, workdir):
48
+ def set_base_workdir(self, workdir: str):
48
49
  """
49
50
  Set base workdir
50
51
 
@@ -162,7 +163,12 @@ class Profile:
162
163
  return True
163
164
  return False
164
165
 
165
- def update_profile(self, uuid: str, name: str, workdir: str) -> bool:
166
+ def update_profile(
167
+ self,
168
+ uuid: str,
169
+ name: str,
170
+ workdir: str
171
+ ) -> bool:
166
172
  """
167
173
  Update profile
168
174
 
@@ -188,7 +194,7 @@ class Profile:
188
194
  """
189
195
  return self.current
190
196
 
191
- def get(self, uuid: str) -> dict or None:
197
+ def get(self, uuid: str) -> Optional[dict]:
192
198
  """
193
199
  Get profile by uuid
194
200
 
@@ -199,7 +205,7 @@ class Profile:
199
205
  return self.profiles[uuid]
200
206
  return None
201
207
 
202
- def get_all(self) -> dict:
208
+ def get_all(self) -> Dict[str, Dict]:
203
209
  """
204
210
  Get all profiles
205
211
 
@@ -222,7 +228,7 @@ class Profile:
222
228
  return tmp_dir
223
229
  return self.base_workdir
224
230
 
225
- def append(self, uuid: str, profile: dict):
231
+ def append(self, uuid: str, profile: Dict):
226
232
  """
227
233
  Append profile
228
234
 
@@ -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 pygpt_net.core.events import Event
@@ -41,6 +41,12 @@ class Prompt:
41
41
  return ""
42
42
 
43
43
  def build_final_system_prompt(self, prompt: str) -> str:
44
+ """
45
+ Build final system prompt
46
+
47
+ :param prompt: prompt
48
+ :return: final system prompt
49
+ """
44
50
  # tmp dispatch event: system prompt
45
51
  event = Event(Event.SYSTEM_PROMPT, {
46
52
  'mode': self.window.core.config.get('mode'),
@@ -50,7 +56,8 @@ class Prompt:
50
56
  self.window.dispatch(event)
51
57
  prompt = event.data['value']
52
58
 
53
- if self.window.core.config.get('cmd') or self.window.controller.plugins.is_type_enabled("cmd.inline"):
59
+ if (self.window.core.config.get('cmd')
60
+ or self.window.controller.plugins.is_type_enabled("cmd.inline")):
54
61
 
55
62
  # abort if native func call enabled
56
63
  if self.window.core.command.is_native_enabled():
@@ -88,7 +95,7 @@ class Prompt:
88
95
  internal: bool,
89
96
  is_expert: bool = False,
90
97
  disable_native_tool_calls: bool = False,
91
- ):
98
+ ) -> str:
92
99
  """
93
100
  Prepare system prompt
94
101
 
@@ -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.08.29 05:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
+ from typing import Optional
13
14
 
14
15
  from PySide6.QtGui import QAction, QIcon
15
16
  from packaging.version import Version
@@ -70,7 +71,7 @@ class Custom:
70
71
  """
71
72
  return list(self.items.keys())
72
73
 
73
- def get_id_by_idx(self, idx: int) -> str or None:
74
+ def get_id_by_idx(self, idx: int) -> Optional[str]:
74
75
  """
75
76
  Get ID by index
76
77
 
@@ -83,7 +84,7 @@ class Custom:
83
84
  return id
84
85
  i += 1
85
86
 
86
- def get_by_id(self, id: str) -> PromptItem or None:
87
+ def get_by_id(self, id: str) -> Optional[PromptItem]:
87
88
  """
88
89
  Return prompt by ID
89
90
 
@@ -93,7 +94,7 @@ class Custom:
93
94
  if id in self.items:
94
95
  return self.items[id]
95
96
 
96
- def get_by_idx(self, idx: int) -> PromptItem or None:
97
+ def get_by_idx(self, idx: int) -> Optional[PromptItem]:
97
98
  """
98
99
  Return item by index
99
100
 
@@ -114,8 +115,8 @@ class Custom:
114
115
 
115
116
  def new(
116
117
  self,
117
- name: str = None,
118
- content: str = None,
118
+ name: Optional[str] = None,
119
+ content: Optional[str] = None,
119
120
  auto_save: bool = True
120
121
  ) -> PromptItem:
121
122
  """
@@ -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.08.25 04:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import os
13
13
  import csv
14
+ from typing import Optional
14
15
 
15
16
  from PySide6.QtGui import QAction
16
17
  from pygpt_net.utils import trans
@@ -62,7 +63,12 @@ class Template:
62
63
  self.prompts = dict(sorted(self.prompts.items(), key=lambda item: item[1]['name']))
63
64
 
64
65
  def to_menu_options(self, menu, parent: str = "global"):
65
- """Convert prompts to menu options"""
66
+ """
67
+ Convert prompts to menu options
68
+
69
+ :param menu: Menu
70
+ :param parent: Parent menu
71
+ """
66
72
  self.init()
67
73
  menu.addSeparator()
68
74
  submenu = menu.addMenu(trans("preset.prompt.paste_template"))
@@ -82,7 +88,7 @@ class Template:
82
88
  action.setToolTip(value['prompt'])
83
89
  letter_submenus[letter].addAction(action)
84
90
 
85
- def get_by_id(self, id: int) -> dict or None:
91
+ def get_by_id(self, id: int) -> Optional[dict]:
86
92
  """
87
93
  Get prompt by id
88
94