pygpt-net 2.4.36.post1__py3-none-any.whl → 2.4.41__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. CHANGELOG.md +38 -1
  2. README.md +71 -114
  3. pygpt_net/CHANGELOG.txt +38 -1
  4. pygpt_net/__init__.py +3 -3
  5. pygpt_net/controller/__init__.py +7 -3
  6. pygpt_net/controller/access/control.py +1 -1
  7. pygpt_net/controller/access/voice.py +11 -5
  8. pygpt_net/controller/agent/experts.py +11 -6
  9. pygpt_net/controller/agent/legacy.py +8 -6
  10. pygpt_net/controller/agent/llama.py +4 -2
  11. pygpt_net/controller/assistant/__init__.py +9 -4
  12. pygpt_net/controller/assistant/batch.py +38 -21
  13. pygpt_net/controller/assistant/editor.py +7 -6
  14. pygpt_net/controller/assistant/files.py +23 -7
  15. pygpt_net/controller/assistant/store.py +20 -7
  16. pygpt_net/controller/assistant/threads.py +34 -8
  17. pygpt_net/controller/attachment.py +29 -10
  18. pygpt_net/controller/audio/__init__.py +25 -4
  19. pygpt_net/controller/calendar/__init__.py +23 -4
  20. pygpt_net/controller/calendar/note.py +57 -11
  21. pygpt_net/controller/camera.py +3 -2
  22. pygpt_net/controller/chat/__init__.py +5 -3
  23. pygpt_net/controller/chat/attachment.py +39 -44
  24. pygpt_net/controller/chat/command.py +4 -2
  25. pygpt_net/controller/chat/common.py +11 -4
  26. pygpt_net/controller/chat/files.py +10 -3
  27. pygpt_net/controller/chat/image.py +17 -5
  28. pygpt_net/controller/chat/input.py +10 -7
  29. pygpt_net/controller/chat/output.py +21 -6
  30. pygpt_net/controller/chat/render.py +100 -21
  31. pygpt_net/controller/chat/response.py +34 -7
  32. pygpt_net/controller/chat/stream.py +4 -2
  33. pygpt_net/controller/chat/text.py +6 -4
  34. pygpt_net/controller/command.py +11 -3
  35. pygpt_net/controller/config/__init__.py +34 -6
  36. pygpt_net/controller/config/field/checkbox.py +7 -4
  37. pygpt_net/controller/config/field/cmd.py +7 -5
  38. pygpt_net/controller/config/field/combo.py +14 -6
  39. pygpt_net/controller/config/field/dictionary.py +14 -11
  40. pygpt_net/controller/config/field/input.py +9 -6
  41. pygpt_net/controller/config/field/slider.py +11 -8
  42. pygpt_net/controller/config/field/textarea.py +8 -5
  43. pygpt_net/controller/config/placeholder.py +52 -21
  44. pygpt_net/controller/ctx/__init__.py +138 -49
  45. pygpt_net/controller/ctx/common.py +15 -4
  46. pygpt_net/controller/ctx/extra.py +11 -3
  47. pygpt_net/controller/ctx/summarizer.py +24 -5
  48. pygpt_net/controller/debug/__init__.py +27 -6
  49. pygpt_net/controller/dialogs/confirm.py +34 -7
  50. pygpt_net/controller/dialogs/debug.py +4 -2
  51. pygpt_net/controller/dialogs/info.py +7 -2
  52. pygpt_net/controller/files.py +48 -10
  53. pygpt_net/controller/finder.py +11 -5
  54. pygpt_net/controller/idx/__init__.py +10 -3
  55. pygpt_net/controller/idx/common.py +4 -2
  56. pygpt_net/controller/idx/indexer.py +25 -17
  57. pygpt_net/controller/idx/settings.py +9 -3
  58. pygpt_net/controller/kernel/__init__.py +34 -8
  59. pygpt_net/controller/kernel/reply.py +12 -3
  60. pygpt_net/controller/kernel/stack.py +5 -3
  61. pygpt_net/controller/lang/custom.py +2 -7
  62. pygpt_net/controller/lang/mapping.py +5 -3
  63. pygpt_net/controller/layout.py +2 -2
  64. pygpt_net/controller/mode.py +16 -4
  65. pygpt_net/controller/model/__init__.py +14 -3
  66. pygpt_net/controller/model/editor.py +8 -3
  67. pygpt_net/controller/notepad.py +26 -12
  68. pygpt_net/controller/painter/capture.py +23 -4
  69. pygpt_net/controller/painter/common.py +9 -7
  70. pygpt_net/controller/plugins/__init__.py +19 -5
  71. pygpt_net/controller/plugins/presets.py +15 -6
  72. pygpt_net/controller/plugins/settings.py +9 -3
  73. pygpt_net/controller/presets/__init__.py +55 -16
  74. pygpt_net/controller/presets/editor.py +26 -10
  75. pygpt_net/controller/settings/__init__.py +3 -2
  76. pygpt_net/controller/settings/editor.py +29 -7
  77. pygpt_net/controller/settings/profile.py +22 -5
  78. pygpt_net/controller/theme/__init__.py +54 -12
  79. pygpt_net/controller/theme/common.py +24 -2
  80. pygpt_net/controller/theme/markdown.py +32 -16
  81. pygpt_net/controller/theme/menu.py +26 -5
  82. pygpt_net/controller/theme/nodes.py +2 -5
  83. pygpt_net/controller/tools/__init__.py +40 -2
  84. pygpt_net/controller/ui/__init__.py +4 -6
  85. pygpt_net/controller/ui/tabs.py +363 -65
  86. pygpt_net/core/access/actions.py +6 -4
  87. pygpt_net/core/access/shortcuts.py +4 -3
  88. pygpt_net/core/access/voice.py +6 -5
  89. pygpt_net/core/agents/legacy.py +4 -2
  90. pygpt_net/core/agents/memory.py +7 -2
  91. pygpt_net/core/agents/observer/evaluation.py +15 -7
  92. pygpt_net/core/agents/provider.py +9 -4
  93. pygpt_net/core/agents/runner.py +61 -15
  94. pygpt_net/core/agents/tools.py +23 -5
  95. pygpt_net/core/assistants/__init__.py +6 -4
  96. pygpt_net/core/assistants/files.py +35 -12
  97. pygpt_net/core/assistants/store.py +20 -10
  98. pygpt_net/core/attachments/__init__.py +54 -15
  99. pygpt_net/core/attachments/context.py +217 -64
  100. pygpt_net/core/audio/__init__.py +71 -3
  101. pygpt_net/core/audio/context.py +7 -2
  102. pygpt_net/core/bridge/__init__.py +22 -6
  103. pygpt_net/core/bridge/context.py +5 -3
  104. pygpt_net/core/bridge/worker.py +16 -2
  105. pygpt_net/core/calendar/__init__.py +57 -11
  106. pygpt_net/core/chain/__init__.py +8 -2
  107. pygpt_net/core/chain/chat.py +10 -8
  108. pygpt_net/core/chain/completion.py +10 -7
  109. pygpt_net/core/command.py +62 -17
  110. pygpt_net/core/ctx/__init__.py +260 -58
  111. pygpt_net/core/ctx/bag.py +25 -4
  112. pygpt_net/core/ctx/container.py +28 -17
  113. pygpt_net/core/ctx/idx.py +45 -8
  114. pygpt_net/core/ctx/output.py +95 -74
  115. pygpt_net/core/ctx/reply.py +5 -2
  116. pygpt_net/core/db/__init__.py +8 -7
  117. pygpt_net/core/db/viewer.py +17 -11
  118. pygpt_net/core/debug/__init__.py +10 -9
  119. pygpt_net/core/debug/tabs.py +5 -2
  120. pygpt_net/core/docker/__init__.py +11 -5
  121. pygpt_net/core/docker/builder.py +11 -3
  122. pygpt_net/core/events/app.py +5 -3
  123. pygpt_net/core/events/base.py +11 -5
  124. pygpt_net/core/events/control.py +5 -3
  125. pygpt_net/core/events/event.py +18 -7
  126. pygpt_net/core/events/kernel.py +5 -3
  127. pygpt_net/core/events/render.py +5 -3
  128. pygpt_net/core/experts/__init__.py +5 -4
  129. pygpt_net/core/filesystem/__init__.py +52 -34
  130. pygpt_net/core/filesystem/actions.py +8 -5
  131. pygpt_net/core/filesystem/editor.py +13 -3
  132. pygpt_net/core/filesystem/types.py +12 -7
  133. pygpt_net/core/filesystem/url.py +7 -3
  134. pygpt_net/core/idx/__init__.py +34 -25
  135. pygpt_net/core/idx/chat.py +60 -38
  136. pygpt_net/core/idx/context.py +6 -2
  137. pygpt_net/core/idx/indexing.py +84 -35
  138. pygpt_net/core/idx/llm.py +11 -3
  139. pygpt_net/core/idx/metadata.py +13 -3
  140. pygpt_net/core/idx/types/ctx.py +32 -6
  141. pygpt_net/core/idx/types/external.py +41 -7
  142. pygpt_net/core/idx/types/files.py +31 -6
  143. pygpt_net/core/image.py +15 -4
  144. pygpt_net/core/llm/__init__.py +13 -3
  145. pygpt_net/core/locale.py +34 -8
  146. pygpt_net/core/models.py +4 -3
  147. pygpt_net/core/notepad.py +9 -4
  148. pygpt_net/core/plugins.py +7 -6
  149. pygpt_net/core/presets.py +19 -10
  150. pygpt_net/core/profile.py +12 -6
  151. pygpt_net/core/prompt/__init__.py +10 -3
  152. pygpt_net/core/prompt/custom.py +7 -6
  153. pygpt_net/core/prompt/template.py +9 -3
  154. pygpt_net/core/render/base.py +117 -22
  155. pygpt_net/core/render/markdown/body.py +27 -7
  156. pygpt_net/core/render/markdown/renderer.py +119 -22
  157. pygpt_net/core/render/plain/body.py +22 -5
  158. pygpt_net/core/render/plain/renderer.py +97 -21
  159. pygpt_net/core/render/web/body.py +75 -25
  160. pygpt_net/core/render/web/renderer.py +313 -63
  161. pygpt_net/core/settings.py +9 -4
  162. pygpt_net/core/tabs/__init__.py +290 -103
  163. pygpt_net/core/tabs/tab.py +17 -4
  164. pygpt_net/core/tokens.py +44 -11
  165. pygpt_net/core/updater/__init__.py +20 -7
  166. pygpt_net/core/vision/analyzer.py +29 -6
  167. pygpt_net/core/web.py +130 -2
  168. pygpt_net/data/config/config.json +19 -6
  169. pygpt_net/data/config/models.json +3 -3
  170. pygpt_net/data/config/modes.json +3 -3
  171. pygpt_net/data/config/settings.json +81 -10
  172. pygpt_net/data/config/settings_section.json +3 -0
  173. pygpt_net/data/css/style.light.css +1 -0
  174. pygpt_net/data/css/{web.css → web-blocks.css} +162 -133
  175. pygpt_net/data/css/{web.light.css → web-blocks.light.css} +7 -0
  176. pygpt_net/data/css/web-chatgpt.css +350 -0
  177. pygpt_net/data/css/web-chatgpt.dark.css +64 -0
  178. pygpt_net/data/css/web-chatgpt.light.css +75 -0
  179. pygpt_net/data/css/web-chatgpt_wide.css +350 -0
  180. pygpt_net/data/css/web-chatgpt_wide.dark.css +64 -0
  181. pygpt_net/data/css/web-chatgpt_wide.light.css +75 -0
  182. pygpt_net/data/icons/split_screen.svg +1 -0
  183. pygpt_net/data/locale/locale.de.ini +19 -3
  184. pygpt_net/data/locale/locale.en.ini +30 -11
  185. pygpt_net/data/locale/locale.es.ini +19 -3
  186. pygpt_net/data/locale/locale.fr.ini +19 -3
  187. pygpt_net/data/locale/locale.it.ini +19 -3
  188. pygpt_net/data/locale/locale.pl.ini +20 -4
  189. pygpt_net/data/locale/locale.uk.ini +19 -3
  190. pygpt_net/data/locale/locale.zh.ini +20 -4
  191. pygpt_net/data/locale/plugin.cmd_web.de.ini +2 -0
  192. pygpt_net/data/locale/plugin.cmd_web.en.ini +20 -10
  193. pygpt_net/data/locale/plugin.cmd_web.es.ini +2 -0
  194. pygpt_net/data/locale/plugin.cmd_web.fr.ini +2 -0
  195. pygpt_net/data/locale/plugin.cmd_web.it.ini +2 -0
  196. pygpt_net/data/locale/plugin.cmd_web.pl.ini +2 -0
  197. pygpt_net/data/locale/plugin.cmd_web.uk.ini +2 -0
  198. pygpt_net/data/locale/plugin.cmd_web.zh.ini +2 -0
  199. pygpt_net/icons.qrc +1 -0
  200. pygpt_net/icons_rc.py +165 -136
  201. pygpt_net/item/ctx.py +46 -24
  202. pygpt_net/plugin/audio_input/simple.py +21 -5
  203. pygpt_net/plugin/audio_output/__init__.py +4 -1
  204. pygpt_net/plugin/base/config.py +4 -2
  205. pygpt_net/plugin/base/plugin.py +26 -6
  206. pygpt_net/plugin/base/worker.py +37 -9
  207. pygpt_net/plugin/cmd_code_interpreter/__init__.py +39 -37
  208. pygpt_net/plugin/cmd_code_interpreter/runner.py +25 -12
  209. pygpt_net/plugin/cmd_web/__init__.py +46 -6
  210. pygpt_net/plugin/cmd_web/config.py +74 -48
  211. pygpt_net/plugin/cmd_web/websearch.py +61 -28
  212. pygpt_net/plugin/cmd_web/worker.py +79 -13
  213. pygpt_net/plugin/idx_llama_index/__init__.py +2 -2
  214. pygpt_net/plugin/real_time/__init__.py +2 -2
  215. pygpt_net/provider/core/config/patch.py +54 -1
  216. pygpt_net/provider/core/ctx/base.py +4 -1
  217. pygpt_net/provider/core/ctx/db_sqlite/__init__.py +10 -1
  218. pygpt_net/provider/core/ctx/db_sqlite/storage.py +22 -1
  219. pygpt_net/provider/gpt/assistants.py +10 -9
  220. pygpt_net/provider/gpt/audio.py +3 -2
  221. pygpt_net/provider/gpt/chat.py +8 -7
  222. pygpt_net/provider/gpt/completion.py +6 -4
  223. pygpt_net/provider/gpt/image.py +9 -2
  224. pygpt_net/provider/gpt/store.py +14 -13
  225. pygpt_net/provider/gpt/vision.py +6 -5
  226. pygpt_net/tools/__init__.py +9 -1
  227. pygpt_net/tools/base.py +15 -1
  228. pygpt_net/tools/code_interpreter/__init__.py +174 -75
  229. pygpt_net/tools/code_interpreter/ui/dialogs.py +21 -103
  230. pygpt_net/tools/code_interpreter/ui/widgets.py +284 -9
  231. pygpt_net/tools/html_canvas/__init__.py +78 -23
  232. pygpt_net/tools/html_canvas/ui/dialogs.py +46 -62
  233. pygpt_net/tools/html_canvas/ui/widgets.py +96 -3
  234. pygpt_net/ui/base/context_menu.py +2 -2
  235. pygpt_net/ui/layout/chat/input.py +10 -18
  236. pygpt_net/ui/layout/chat/output.py +26 -44
  237. pygpt_net/ui/layout/ctx/ctx_list.py +13 -4
  238. pygpt_net/ui/layout/toolbox/footer.py +18 -2
  239. pygpt_net/ui/main.py +2 -2
  240. pygpt_net/ui/menu/config.py +7 -11
  241. pygpt_net/ui/menu/debug.py +11 -1
  242. pygpt_net/ui/menu/theme.py +9 -2
  243. pygpt_net/ui/widget/filesystem/explorer.py +2 -2
  244. pygpt_net/ui/widget/lists/context.py +27 -5
  245. pygpt_net/ui/widget/tabs/Input.py +2 -2
  246. pygpt_net/ui/widget/tabs/body.py +2 -1
  247. pygpt_net/ui/widget/tabs/layout.py +195 -0
  248. pygpt_net/ui/widget/tabs/output.py +218 -55
  249. pygpt_net/ui/widget/textarea/html.py +11 -1
  250. pygpt_net/ui/widget/textarea/output.py +10 -1
  251. pygpt_net/ui/widget/textarea/search_input.py +4 -1
  252. pygpt_net/ui/widget/textarea/web.py +49 -9
  253. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/METADATA +72 -115
  254. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/RECORD +258 -250
  255. /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
  256. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/LICENSE +0 -0
  257. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/WHEEL +0 -0
  258. {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.41.dist-info}/entry_points.txt +0 -0
@@ -6,9 +6,11 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.11.20 03:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import List, Dict
13
+
12
14
  from pygpt_net.core.events import ControlEvent, AppEvent
13
15
 
14
16
 
@@ -21,7 +23,7 @@ class Actions:
21
23
  """
22
24
  self.window = window
23
25
 
24
- def get_access_choices(self) -> list:
26
+ def get_access_choices(self) -> List[Dict[str, str]]:
25
27
  """
26
28
  Get app access events choices
27
29
 
@@ -74,7 +76,7 @@ class Actions:
74
76
  choices.append({event: f"event.control.{event}"})
75
77
  return choices
76
78
 
77
- def get_speech_synthesis_choices(self) -> list:
79
+ def get_speech_synthesis_choices(self) -> List[Dict[str, str]]:
78
80
  """
79
81
  Get app access events choices
80
82
 
@@ -115,7 +117,7 @@ class Actions:
115
117
  choices.append({event: f"event.audio.{event}"})
116
118
  return choices
117
119
 
118
- def get_voice_control_choices(self) -> list:
120
+ def get_voice_control_choices(self) -> List[Dict[str, str]]:
119
121
  """
120
122
  Get voice control choices
121
123
 
@@ -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 List, Dict
13
14
 
14
15
  from PySide6 import QtCore
15
16
  from PySide6.QtCore import QObject, QEvent
@@ -26,7 +27,7 @@ class Shortcuts:
26
27
  """
27
28
  self.window = window
28
29
 
29
- def get_keys_choices(self) -> list:
30
+ def get_keys_choices(self) -> List[Dict[str, str]]:
30
31
  """
31
32
  Get keys choices with identical key and value.
32
33
 
@@ -43,7 +44,7 @@ class Shortcuts:
43
44
  keys.extend([{name: name} for name in symbols])
44
45
  return keys
45
46
 
46
- def get_modifiers_choices(self) -> list:
47
+ def get_modifiers_choices(self) -> List[Dict[str, str]]:
47
48
  """
48
49
  Get modifiers choices with identical key and value.
49
50
 
@@ -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 json
13
13
  import re
14
+ from typing import Optional, Dict, List, Any
14
15
 
15
16
  from pygpt_net.core.bridge.context import BridgeContext
16
17
 
@@ -96,7 +97,7 @@ class Voice:
96
97
  AppEvent.TAB_SELECTED, # notepad tabs can have custom names
97
98
  ]
98
99
 
99
- def get_commands(self) -> dict:
100
+ def get_commands(self) -> Dict[str, str]:
100
101
  """
101
102
  Get available commands
102
103
 
@@ -152,7 +153,7 @@ class Voice:
152
153
 
153
154
  return prompt.strip()
154
155
 
155
- def get_inline_prompt(self, prefix: str = None) -> str:
156
+ def get_inline_prompt(self, prefix: Optional[str] = None) -> str:
156
157
  """
157
158
  Get prompt for inline voice command recognition
158
159
 
@@ -174,7 +175,7 @@ class Voice:
174
175
 
175
176
  return prompt.strip()
176
177
 
177
- def extract_json(self, text: str) -> list:
178
+ def extract_json(self, text: str) -> List[Dict[str, Any]]:
178
179
  """
179
180
  Extract JSON from text
180
181
 
@@ -206,7 +207,7 @@ class Voice:
206
207
  self.window.core.debug.log(e)
207
208
  return cmds
208
209
 
209
- def recognize_commands(self, text: str) -> list:
210
+ def recognize_commands(self, text: str) -> List[Dict[str, Any]]:
210
211
  """
211
212
  Recognize voice command
212
213
 
@@ -6,9 +6,11 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.11.26 19:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import List
13
+
12
14
  from pygpt_net.core.types import (
13
15
  MODE_CHAT,
14
16
  MODE_COMPLETION,
@@ -35,7 +37,7 @@ class Legacy:
35
37
  MODE_AUDIO,
36
38
  ]
37
39
 
38
- def get_allowed_modes(self) -> list:
40
+ def get_allowed_modes(self) -> List[str]:
39
41
  """
40
42
  Get allowed modes
41
43
 
@@ -6,9 +6,11 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.11.23 00:00:00 #
9
+ # Updated Date: 2024.12.14 00:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import List
13
+
12
14
  from llama_index.core.llms import ChatMessage, MessageRole
13
15
  from pygpt_net.core.bridge.context import BridgeContext
14
16
 
@@ -22,7 +24,10 @@ class Memory:
22
24
  """
23
25
  self.window = window
24
26
 
25
- def prepare(self, context: BridgeContext) -> list[ChatMessage]:
27
+ def prepare(
28
+ self,
29
+ context: BridgeContext
30
+ ) -> List[ChatMessage]:
26
31
  """
27
32
  Prepare history for agent
28
33
 
@@ -6,11 +6,15 @@
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.17 03:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import List
13
+
12
14
  from llama_index.core.tools import FunctionTool
13
15
 
16
+ from pygpt_net.item.ctx import CtxItem
17
+
14
18
 
15
19
  class Evaluation:
16
20
  def __init__(self, window=None):
@@ -67,7 +71,7 @@ class Evaluation:
67
71
  - Do not repeat the suggested improvements if they have already been correctly included in the agent's response.
68
72
  """
69
73
 
70
- def get_last_user_input(self, history) -> str:
74
+ def get_last_user_input(self, history: List[CtxItem]) -> str:
71
75
  """
72
76
  Get the last user input from the history
73
77
 
@@ -84,7 +88,7 @@ class Evaluation:
84
88
  input = ctx.input
85
89
  return input
86
90
 
87
- def get_main_task(self, history) -> str:
91
+ def get_main_task(self, history: List[CtxItem]) -> str:
88
92
  """
89
93
  Get the main task from the history
90
94
 
@@ -97,7 +101,7 @@ class Evaluation:
97
101
  task = first.input
98
102
  return task
99
103
 
100
- def get_final_response(self, history) -> str:
104
+ def get_final_response(self, history: List[CtxItem]) -> str:
101
105
  """
102
106
  Get the final response from the agent
103
107
 
@@ -111,7 +115,7 @@ class Evaluation:
111
115
  output = ctx.output
112
116
  return output
113
117
 
114
- def get_prompt(self, history) -> str:
118
+ def get_prompt(self, history: List[CtxItem]) -> str:
115
119
  """
116
120
  Return the evaluation prompt
117
121
 
@@ -128,7 +132,7 @@ class Evaluation:
128
132
  output=final_response
129
133
  )
130
134
 
131
- def get_tools(self) -> list:
135
+ def get_tools(self) -> List[FunctionTool]:
132
136
  """
133
137
  Get the tools for evaluating the result
134
138
 
@@ -144,7 +148,11 @@ class Evaluation:
144
148
  tools.append(tool)
145
149
  return tools
146
150
 
147
- def handle_evaluation(self, instruction: str, score: int):
151
+ def handle_evaluation(
152
+ self,
153
+ instruction: str,
154
+ score: int
155
+ ):
148
156
  """
149
157
  Update the evaluation values of the agent response
150
158
 
@@ -6,9 +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.15 00:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import List
13
+
14
+ from pygpt_net.provider.agents.base import BaseAgent
15
+
16
+
12
17
  class Provider:
13
18
  def __init__(self, window=None):
14
19
  """
@@ -19,7 +24,7 @@ class Provider:
19
24
  self.window = window
20
25
  self.agents = {}
21
26
 
22
- def get_ids(self) -> list:
27
+ def get_ids(self) -> List[str]:
23
28
  """
24
29
  Get agent providers ids
25
30
 
@@ -36,7 +41,7 @@ class Provider:
36
41
  """
37
42
  return id in self.agents
38
43
 
39
- def get(self, id: str):
44
+ def get(self, id: str) -> BaseAgent:
40
45
  """
41
46
  Get agent provider
42
47
 
@@ -54,7 +59,7 @@ class Provider:
54
59
  """
55
60
  self.agents[id] = agent
56
61
 
57
- def get_providers(self) -> list:
62
+ def get_providers(self) -> List[str]:
58
63
  """
59
64
  Get agent providers list
60
65
 
@@ -6,9 +6,13 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.11.21 20:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Optional, Dict, Any, List
13
+
14
+ from llama_index.core.tools import FunctionTool
15
+
12
16
  from pygpt_net.core.bridge.context import BridgeContext
13
17
  from pygpt_net.core.bridge.worker import BridgeSignals
14
18
  from pygpt_net.core.events import Event, KernelEvent
@@ -32,7 +36,7 @@ class Runner:
32
36
  def call(
33
37
  self,
34
38
  context: BridgeContext,
35
- extra: dict,
39
+ extra: Dict[str, Any],
36
40
  signals: BridgeSignals
37
41
  ) -> bool:
38
42
  """
@@ -104,7 +108,7 @@ class Runner:
104
108
 
105
109
  def run_steps(
106
110
  self,
107
- agent,
111
+ agent: Any,
108
112
  ctx: CtxItem,
109
113
  prompt: str,
110
114
  signals: BridgeSignals,
@@ -202,7 +206,7 @@ class Runner:
202
206
 
203
207
  def run_assistant(
204
208
  self,
205
- agent,
209
+ agent: Any,
206
210
  ctx: CtxItem,
207
211
  prompt: str,
208
212
  signals: BridgeSignals,
@@ -250,7 +254,7 @@ class Runner:
250
254
 
251
255
  def run_plan(
252
256
  self,
253
- agent,
257
+ agent: Any,
254
258
  ctx: CtxItem,
255
259
  prompt: str,
256
260
  signals: BridgeSignals,
@@ -408,7 +412,12 @@ class Runner:
408
412
 
409
413
  return True
410
414
 
411
- def copy_step_results(self, step_ctx: CtxItem, ctx: CtxItem, tools_output: list):
415
+ def copy_step_results(
416
+ self,
417
+ step_ctx: CtxItem,
418
+ ctx: CtxItem,
419
+ tools_output: List[Dict[str, Any]]
420
+ ):
412
421
  """
413
422
  Copy step results from base context item
414
423
 
@@ -433,7 +442,12 @@ class Runner:
433
442
  if k != "agent_input":
434
443
  del ctx.extra[k]
435
444
 
436
- def run_once(self, input: str, tools: list, model_name) -> str:
445
+ def run_once(
446
+ self,
447
+ input: str,
448
+ tools: List[FunctionTool],
449
+ model_name: Optional[str] = None
450
+ ) -> str:
437
451
  """
438
452
  Run agent once (quick call to ReAct agent)
439
453
 
@@ -460,7 +474,12 @@ class Runner:
460
474
  agent = provider.get_agent(self.window, kwargs)
461
475
  return agent.chat(self.prepare_input(input))
462
476
 
463
- def run_next(self, context: BridgeContext, extra: dict, signals: BridgeSignals) -> bool:
477
+ def run_next(
478
+ self,
479
+ context: BridgeContext,
480
+ extra: dict,
481
+ signals: BridgeSignals
482
+ ) -> bool:
464
483
  """
465
484
  Evaluate a response and run next step
466
485
 
@@ -484,7 +503,13 @@ class Runner:
484
503
  self.run_once(prompt, tools, ctx.model) # tool will update evaluation
485
504
  return self.handle_evaluation(ctx, self.next_instruction, self.prev_score, signals)
486
505
 
487
- def handle_evaluation(self, ctx: CtxItem, instruction: str, score: int, signals: BridgeSignals):
506
+ def handle_evaluation(
507
+ self,
508
+ ctx: CtxItem,
509
+ instruction: str,
510
+ score: int,
511
+ signals: BridgeSignals
512
+ ):
488
513
  """
489
514
  Handle evaluation
490
515
 
@@ -548,7 +573,10 @@ class Runner:
548
573
  context.model = self.window.core.models.get(self.window.core.config.get('model'))
549
574
  return self.call(context, extra, signals)
550
575
 
551
- def add_ctx(self, from_ctx: CtxItem) -> CtxItem:
576
+ def add_ctx(
577
+ self,
578
+ from_ctx: CtxItem
579
+ ) -> CtxItem:
552
580
  """
553
581
  Add context item
554
582
 
@@ -568,7 +596,13 @@ class Runner:
568
596
  ctx.live = True
569
597
  return ctx
570
598
 
571
- def send_response(self, ctx: CtxItem, signals: BridgeSignals, event_name: str, **kwargs):
599
+ def send_response(
600
+ self,
601
+ ctx: CtxItem,
602
+ signals: BridgeSignals,
603
+ event_name: str,
604
+ **kwargs
605
+ ):
572
606
  """
573
607
  Send async response to chat window (BridgeSignals)
574
608
 
@@ -585,7 +619,11 @@ class Runner:
585
619
  })
586
620
  signals.response.emit(event)
587
621
 
588
- def set_busy(self, signals: BridgeSignals, **kwargs):
622
+ def set_busy(
623
+ self,
624
+ signals: BridgeSignals,
625
+ **kwargs
626
+ ):
589
627
  """
590
628
  Set busy status
591
629
 
@@ -600,7 +638,11 @@ class Runner:
600
638
  data.update(kwargs)
601
639
  signals.response.emit(event)
602
640
 
603
- def set_idle(self, signals: BridgeSignals, **kwargs):
641
+ def set_idle(
642
+ self,
643
+ signals: BridgeSignals,
644
+ **kwargs
645
+ ):
604
646
  """
605
647
  Set idle status
606
648
 
@@ -614,7 +656,11 @@ class Runner:
614
656
  data.update(kwargs)
615
657
  signals.response.emit(event)
616
658
 
617
- def set_status(self, signals: BridgeSignals, msg: str):
659
+ def set_status(
660
+ self,
661
+ signals: BridgeSignals,
662
+ msg: str
663
+ ):
618
664
  """
619
665
  Set busy status
620
666
 
@@ -647,7 +693,7 @@ class Runner:
647
693
  """
648
694
  return self.window.controller.kernel.stopped()
649
695
 
650
- def get_error(self) -> Exception or None:
696
+ def get_error(self) -> Optional[Exception]:
651
697
  """
652
698
  Get last error
653
699
 
@@ -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 03:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
13
+ from typing import List, Dict, Any
13
14
 
14
15
  from llama_index.core.chat_engine.types import AgentChatResponse
15
16
  from llama_index.core.tools import BaseTool, FunctionTool, QueryEngineTool, ToolMetadata
@@ -29,7 +30,12 @@ class Tools:
29
30
  self.cmd_blacklist = []
30
31
  self.verbose = False
31
32
 
32
- def prepare(self, context: BridgeContext, extra: dict, verbose: bool = False) -> list[BaseTool]:
33
+ def prepare(
34
+ self,
35
+ context: BridgeContext,
36
+ extra: Dict[str, Any],
37
+ verbose: bool = False
38
+ ) -> List[BaseTool]:
33
39
  """
34
40
  Prepare tools for agent
35
41
 
@@ -66,7 +72,11 @@ class Tools:
66
72
  tools.extend(query_engine_tools)
67
73
  return tools
68
74
 
69
- def get_plugin_functions(self, ctx: CtxItem, verbose: bool = False) -> list:
75
+ def get_plugin_functions(
76
+ self,
77
+ ctx: CtxItem,
78
+ verbose: bool = False
79
+ ) -> list:
70
80
  """
71
81
  Parse plugin functions
72
82
 
@@ -114,7 +124,10 @@ class Tools:
114
124
  print(e)
115
125
  return tools
116
126
 
117
- def export_sources(self, response: AgentChatResponse) -> list[dict]:
127
+ def export_sources(
128
+ self,
129
+ response: AgentChatResponse
130
+ ) -> List[dict]:
118
131
  """
119
132
  Export sources from response
120
133
 
@@ -148,7 +161,12 @@ class PluginToolMetadata(ToolMetadata):
148
161
  super().__init__(name=name, description=description)
149
162
  self.schema = None
150
163
 
151
- def get_parameters_dict(self) -> dict:
164
+ def get_parameters_dict(self) -> Dict[str, Any]:
165
+ """
166
+ Get parameters dictionary
167
+
168
+ :return: parameters
169
+ """
152
170
  parameters = {
153
171
  k: v
154
172
  for k, v in self.schema.items()
@@ -6,9 +6,11 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.04.26 23:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Optional, Dict
13
+
12
14
  from pygpt_net.item.assistant import AssistantItem
13
15
  from pygpt_net.item.attachment import AttachmentItem
14
16
  from pygpt_net.provider.core.assistant.json_file import JsonFileProvider
@@ -58,7 +60,7 @@ class Assistants:
58
60
  assistants = self.get_all()
59
61
  return list(assistants.keys())[idx]
60
62
 
61
- def get_by_id(self, id: str) -> AssistantItem | None:
63
+ def get_by_id(self, id: str) -> Optional[AssistantItem]:
62
64
  """
63
65
  Return assistant by ID
64
66
 
@@ -70,7 +72,7 @@ class Assistants:
70
72
  return None
71
73
  return assistants[id]
72
74
 
73
- def get_all(self) -> dict:
75
+ def get_all(self) -> Dict[str, AssistantItem]:
74
76
  """
75
77
  Return assistants
76
78
 
@@ -143,7 +145,7 @@ class Assistants:
143
145
  del assistant.attachments[old_id]
144
146
  self.save()
145
147
 
146
- def get_default_assistant(self) -> str | None:
148
+ def get_default_assistant(self) -> Optional[str]:
147
149
  """
148
150
  Return default assistant ID or None
149
151
 
@@ -6,9 +6,11 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.04.30 04:00:00 #
9
+ # Updated Date: 2024.12.14 08:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Optional, List, Dict
13
+
12
14
  from packaging.version import Version
13
15
 
14
16
  from pygpt_net.item.assistant import AssistantFileItem, AssistantItem
@@ -49,7 +51,7 @@ class Files:
49
51
  if id in self.items:
50
52
  return self.items[id]
51
53
 
52
- def get_ids(self) -> list:
54
+ def get_ids(self) -> List[str]:
53
55
  """
54
56
  Return all loaded file IDs
55
57
 
@@ -58,7 +60,7 @@ class Files:
58
60
  return list(self.items.keys())
59
61
 
60
62
 
61
- def get_all(self) -> dict:
63
+ def get_all(self) -> Dict[str, AssistantFileItem]:
62
64
  """
63
65
  Return all files
64
66
 
@@ -103,7 +105,7 @@ class Files:
103
105
  file_id: str,
104
106
  name: str,
105
107
  path: str,
106
- size: int) -> AssistantFileItem or None:
108
+ size: int) -> Optional[AssistantFileItem]:
107
109
  """
108
110
  Create new file
109
111
 
@@ -128,7 +130,10 @@ class Files:
128
130
  self.items[file.id] = file
129
131
  return file
130
132
 
131
- def update(self, file: AssistantFileItem) -> AssistantFileItem or None:
133
+ def update(
134
+ self,
135
+ file: AssistantFileItem
136
+ ) -> Optional[AssistantFileItem]:
132
137
  """
133
138
  Update file
134
139
 
@@ -139,7 +144,7 @@ class Files:
139
144
  self.provider.save(file)
140
145
  return file
141
146
 
142
- def get_names(self) -> dict:
147
+ def get_names(self) -> Dict[str, str]:
143
148
  """
144
149
  Get file name mapping id <> name
145
150
 
@@ -151,7 +156,11 @@ class Files:
151
156
  names[id] = file.name
152
157
  return names
153
158
 
154
- def get_by_store_or_thread(self, store_id: str, thread_id: str) -> dict:
159
+ def get_by_store_or_thread(
160
+ self,
161
+ store_id: str,
162
+ thread_id: str
163
+ ) -> Dict[str, AssistantFileItem]:
155
164
  """
156
165
  Get files by store or thread
157
166
 
@@ -161,7 +170,11 @@ class Files:
161
170
  """
162
171
  return self.provider.get_by_store_or_thread(store_id, thread_id)
163
172
 
164
- def count_by_store_or_thread(self, store_id: str, thread_id: str) -> int:
173
+ def count_by_store_or_thread(
174
+ self,
175
+ store_id: str,
176
+ thread_id: str
177
+ ) -> int:
165
178
  """
166
179
  Count files by store or thread
167
180
 
@@ -171,7 +184,12 @@ class Files:
171
184
  """
172
185
  return self.provider.count_by_store_or_thread(store_id, thread_id)
173
186
 
174
- def get_file_by_idx(self, idx: int, store_id: str, thread_id: str) -> AssistantFileItem or None:
187
+ def get_file_by_idx(
188
+ self,
189
+ idx: int,
190
+ store_id: str,
191
+ thread_id: str
192
+ ) -> Optional[AssistantFileItem]:
175
193
  """
176
194
  Get file by list index
177
195
 
@@ -185,7 +203,12 @@ class Files:
185
203
  return None
186
204
  return list(files.values())[idx]
187
205
 
188
- def get_file_id_by_idx(self, idx: int, store_id: str, thread_id: str) -> str or None:
206
+ def get_file_id_by_idx(
207
+ self,
208
+ idx: int,
209
+ store_id: str,
210
+ thread_id: str
211
+ ) -> Optional[str]:
189
212
  """
190
213
  Get file by list index
191
214
 
@@ -259,7 +282,7 @@ class Files:
259
282
  self.items[record_id].name = name
260
283
  return True
261
284
 
262
- def truncate(self, store_id: str = None) -> bool:
285
+ def truncate(self, store_id: Optional[str] = None) -> bool:
263
286
  """
264
287
  Truncate all files
265
288
 
@@ -272,7 +295,7 @@ class Files:
272
295
  self.window.core.gpt.store.remove_from_stores() # remove files from all vector stores
273
296
  return self.truncate_local(store_id) # truncate files in DB
274
297
 
275
- def truncate_local(self, store_id: str = None) -> bool:
298
+ def truncate_local(self, store_id: Optional[str] = None) -> bool:
276
299
  """
277
300
  Truncate all files (local only)
278
301