pygpt-net 2.6.20__py3-none-any.whl → 2.6.22__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 (221) hide show
  1. pygpt_net/CHANGELOG.txt +13 -0
  2. pygpt_net/__init__.py +3 -3
  3. pygpt_net/app.py +3 -1
  4. pygpt_net/controller/__init__.py +4 -8
  5. pygpt_net/controller/access/voice.py +2 -2
  6. pygpt_net/controller/agent/agent.py +130 -2
  7. pygpt_net/controller/agent/experts.py +93 -96
  8. pygpt_net/controller/agent/llama.py +2 -1
  9. pygpt_net/controller/assistant/assistant.py +18 -1
  10. pygpt_net/controller/assistant/batch.py +2 -3
  11. pygpt_net/controller/assistant/editor.py +2 -2
  12. pygpt_net/controller/assistant/files.py +2 -3
  13. pygpt_net/controller/assistant/store.py +2 -2
  14. pygpt_net/controller/attachment/attachment.py +17 -1
  15. pygpt_net/controller/audio/audio.py +2 -2
  16. pygpt_net/controller/camera/camera.py +15 -7
  17. pygpt_net/controller/chat/chat.py +2 -2
  18. pygpt_net/controller/chat/common.py +50 -33
  19. pygpt_net/controller/chat/image.py +67 -77
  20. pygpt_net/controller/chat/input.py +94 -166
  21. pygpt_net/controller/chat/output.py +83 -140
  22. pygpt_net/controller/chat/response.py +83 -102
  23. pygpt_net/controller/chat/text.py +116 -149
  24. pygpt_net/controller/ctx/common.py +2 -1
  25. pygpt_net/controller/ctx/ctx.py +87 -6
  26. pygpt_net/controller/files/files.py +13 -1
  27. pygpt_net/controller/idx/idx.py +26 -2
  28. pygpt_net/controller/idx/indexer.py +85 -76
  29. pygpt_net/controller/kernel/reply.py +53 -66
  30. pygpt_net/controller/kernel/stack.py +16 -16
  31. pygpt_net/controller/lang/lang.py +52 -34
  32. pygpt_net/controller/model/importer.py +3 -2
  33. pygpt_net/controller/model/model.py +62 -3
  34. pygpt_net/controller/notepad/notepad.py +86 -84
  35. pygpt_net/controller/plugins/settings.py +3 -4
  36. pygpt_net/controller/settings/editor.py +4 -4
  37. pygpt_net/controller/settings/profile.py +105 -124
  38. pygpt_net/controller/theme/menu.py +154 -57
  39. pygpt_net/controller/theme/nodes.py +51 -44
  40. pygpt_net/controller/theme/theme.py +33 -9
  41. pygpt_net/controller/tools/tools.py +2 -2
  42. pygpt_net/controller/ui/tabs.py +2 -3
  43. pygpt_net/controller/ui/ui.py +16 -2
  44. pygpt_net/core/agents/observer/evaluation.py +3 -3
  45. pygpt_net/core/agents/provider.py +25 -3
  46. pygpt_net/core/agents/runner.py +4 -1
  47. pygpt_net/core/agents/runners/llama_workflow.py +19 -7
  48. pygpt_net/core/agents/runners/loop.py +3 -1
  49. pygpt_net/core/agents/runners/openai_workflow.py +17 -3
  50. pygpt_net/core/agents/tools.py +4 -1
  51. pygpt_net/core/bridge/context.py +34 -37
  52. pygpt_net/core/ctx/container.py +13 -12
  53. pygpt_net/core/ctx/ctx.py +1 -1
  54. pygpt_net/core/ctx/output.py +7 -4
  55. pygpt_net/core/db/database.py +2 -2
  56. pygpt_net/core/debug/console/console.py +2 -2
  57. pygpt_net/core/debug/debug.py +12 -1
  58. pygpt_net/core/dispatcher/dispatcher.py +24 -1
  59. pygpt_net/core/events/app.py +7 -7
  60. pygpt_net/core/events/control.py +26 -26
  61. pygpt_net/core/events/event.py +6 -3
  62. pygpt_net/core/events/kernel.py +2 -2
  63. pygpt_net/core/events/render.py +13 -13
  64. pygpt_net/core/experts/experts.py +76 -82
  65. pygpt_net/core/experts/worker.py +12 -12
  66. pygpt_net/core/filesystem/actions.py +1 -2
  67. pygpt_net/core/models/models.py +5 -1
  68. pygpt_net/core/models/ollama.py +14 -5
  69. pygpt_net/core/render/plain/helpers.py +2 -5
  70. pygpt_net/core/render/plain/renderer.py +26 -30
  71. pygpt_net/core/render/web/body.py +1 -1
  72. pygpt_net/core/render/web/helpers.py +2 -2
  73. pygpt_net/core/render/web/renderer.py +4 -4
  74. pygpt_net/core/settings/settings.py +43 -13
  75. pygpt_net/core/tabs/tabs.py +20 -13
  76. pygpt_net/core/types/__init__.py +2 -1
  77. pygpt_net/core/types/agent.py +4 -4
  78. pygpt_net/core/types/base.py +19 -0
  79. pygpt_net/core/types/console.py +6 -6
  80. pygpt_net/core/types/mode.py +8 -8
  81. pygpt_net/core/types/multimodal.py +3 -3
  82. pygpt_net/core/types/openai.py +2 -1
  83. pygpt_net/data/config/config.json +5 -5
  84. pygpt_net/data/config/models.json +19 -3
  85. pygpt_net/data/config/settings.json +14 -14
  86. pygpt_net/data/locale/locale.de.ini +4 -1
  87. pygpt_net/data/locale/locale.en.ini +6 -3
  88. pygpt_net/data/locale/locale.es.ini +4 -1
  89. pygpt_net/data/locale/locale.fr.ini +4 -1
  90. pygpt_net/data/locale/locale.it.ini +4 -1
  91. pygpt_net/data/locale/locale.pl.ini +5 -4
  92. pygpt_net/data/locale/locale.uk.ini +4 -1
  93. pygpt_net/data/locale/locale.zh.ini +4 -1
  94. pygpt_net/item/ctx.py +256 -240
  95. pygpt_net/item/model.py +59 -116
  96. pygpt_net/item/preset.py +122 -105
  97. pygpt_net/plugin/twitter/plugin.py +2 -2
  98. pygpt_net/provider/agents/llama_index/workflow/planner.py +3 -3
  99. pygpt_net/provider/agents/openai/agent.py +4 -12
  100. pygpt_net/provider/agents/openai/agent_b2b.py +10 -15
  101. pygpt_net/provider/agents/openai/agent_planner.py +4 -4
  102. pygpt_net/provider/agents/openai/agent_with_experts.py +3 -7
  103. pygpt_net/provider/agents/openai/agent_with_experts_feedback.py +4 -8
  104. pygpt_net/provider/agents/openai/agent_with_feedback.py +4 -8
  105. pygpt_net/provider/agents/openai/bot_researcher.py +2 -18
  106. pygpt_net/provider/agents/openai/bots/__init__.py +0 -0
  107. pygpt_net/provider/agents/openai/bots/research_bot/__init__.py +0 -0
  108. pygpt_net/provider/agents/openai/bots/research_bot/agents/__init__.py +0 -0
  109. pygpt_net/provider/agents/openai/bots/research_bot/agents/planner_agent.py +1 -1
  110. pygpt_net/provider/agents/openai/bots/research_bot/agents/search_agent.py +1 -0
  111. pygpt_net/provider/agents/openai/bots/research_bot/agents/writer_agent.py +1 -1
  112. pygpt_net/provider/agents/openai/bots/research_bot/manager.py +1 -10
  113. pygpt_net/provider/agents/openai/evolve.py +5 -9
  114. pygpt_net/provider/agents/openai/supervisor.py +4 -8
  115. pygpt_net/provider/core/config/patch.py +10 -3
  116. pygpt_net/provider/core/ctx/db_sqlite/utils.py +43 -43
  117. pygpt_net/provider/core/model/patch.py +11 -1
  118. pygpt_net/provider/core/preset/json_file.py +47 -49
  119. pygpt_net/provider/gpt/agents/experts.py +2 -2
  120. pygpt_net/tools/audio_transcriber/ui/dialogs.py +44 -54
  121. pygpt_net/tools/code_interpreter/body.py +1 -2
  122. pygpt_net/tools/code_interpreter/tool.py +7 -4
  123. pygpt_net/tools/code_interpreter/ui/html.py +1 -3
  124. pygpt_net/tools/code_interpreter/ui/widgets.py +2 -3
  125. pygpt_net/tools/html_canvas/ui/widgets.py +1 -3
  126. pygpt_net/tools/image_viewer/ui/dialogs.py +40 -37
  127. pygpt_net/tools/indexer/ui/widgets.py +2 -4
  128. pygpt_net/tools/media_player/tool.py +2 -5
  129. pygpt_net/tools/media_player/ui/widgets.py +60 -36
  130. pygpt_net/tools/text_editor/ui/widgets.py +18 -19
  131. pygpt_net/tools/translator/ui/widgets.py +39 -35
  132. pygpt_net/ui/base/context_menu.py +9 -4
  133. pygpt_net/ui/dialog/db.py +1 -3
  134. pygpt_net/ui/dialog/models.py +1 -3
  135. pygpt_net/ui/dialog/models_importer.py +2 -4
  136. pygpt_net/ui/dialogs.py +34 -30
  137. pygpt_net/ui/layout/chat/attachments.py +72 -84
  138. pygpt_net/ui/layout/chat/attachments_ctx.py +40 -44
  139. pygpt_net/ui/layout/chat/attachments_uploaded.py +36 -39
  140. pygpt_net/ui/layout/chat/calendar.py +100 -70
  141. pygpt_net/ui/layout/chat/chat.py +23 -17
  142. pygpt_net/ui/layout/chat/input.py +95 -118
  143. pygpt_net/ui/layout/chat/output.py +100 -162
  144. pygpt_net/ui/layout/chat/painter.py +89 -61
  145. pygpt_net/ui/layout/ctx/ctx_list.py +43 -52
  146. pygpt_net/ui/layout/status.py +23 -14
  147. pygpt_net/ui/layout/toolbox/agent.py +27 -38
  148. pygpt_net/ui/layout/toolbox/agent_llama.py +42 -45
  149. pygpt_net/ui/layout/toolbox/assistants.py +42 -38
  150. pygpt_net/ui/layout/toolbox/computer_env.py +32 -23
  151. pygpt_net/ui/layout/toolbox/footer.py +13 -16
  152. pygpt_net/ui/layout/toolbox/image.py +18 -21
  153. pygpt_net/ui/layout/toolbox/indexes.py +46 -89
  154. pygpt_net/ui/layout/toolbox/mode.py +20 -7
  155. pygpt_net/ui/layout/toolbox/model.py +12 -10
  156. pygpt_net/ui/layout/toolbox/presets.py +68 -52
  157. pygpt_net/ui/layout/toolbox/prompt.py +31 -58
  158. pygpt_net/ui/layout/toolbox/toolbox.py +25 -21
  159. pygpt_net/ui/layout/toolbox/vision.py +20 -22
  160. pygpt_net/ui/main.py +2 -4
  161. pygpt_net/ui/menu/about.py +64 -84
  162. pygpt_net/ui/menu/audio.py +87 -63
  163. pygpt_net/ui/menu/config.py +121 -127
  164. pygpt_net/ui/menu/debug.py +69 -76
  165. pygpt_net/ui/menu/file.py +32 -35
  166. pygpt_net/ui/menu/menu.py +2 -3
  167. pygpt_net/ui/menu/plugins.py +69 -33
  168. pygpt_net/ui/menu/theme.py +45 -46
  169. pygpt_net/ui/menu/tools.py +56 -60
  170. pygpt_net/ui/menu/video.py +20 -25
  171. pygpt_net/ui/tray.py +1 -2
  172. pygpt_net/ui/widget/audio/bar.py +1 -3
  173. pygpt_net/ui/widget/audio/input_button.py +3 -4
  174. pygpt_net/ui/widget/calendar/select.py +1 -2
  175. pygpt_net/ui/widget/dialog/base.py +12 -9
  176. pygpt_net/ui/widget/dialog/editor_file.py +20 -23
  177. pygpt_net/ui/widget/dialog/find.py +25 -24
  178. pygpt_net/ui/widget/dialog/profile.py +57 -53
  179. pygpt_net/ui/widget/draw/painter.py +62 -93
  180. pygpt_net/ui/widget/element/button.py +42 -30
  181. pygpt_net/ui/widget/element/checkbox.py +23 -15
  182. pygpt_net/ui/widget/element/group.py +6 -5
  183. pygpt_net/ui/widget/element/labels.py +1 -2
  184. pygpt_net/ui/widget/filesystem/explorer.py +93 -102
  185. pygpt_net/ui/widget/image/display.py +1 -2
  186. pygpt_net/ui/widget/lists/assistant.py +1 -2
  187. pygpt_net/ui/widget/lists/attachment.py +1 -2
  188. pygpt_net/ui/widget/lists/attachment_ctx.py +1 -2
  189. pygpt_net/ui/widget/lists/context.py +2 -4
  190. pygpt_net/ui/widget/lists/index.py +1 -2
  191. pygpt_net/ui/widget/lists/model.py +1 -2
  192. pygpt_net/ui/widget/lists/model_editor.py +1 -2
  193. pygpt_net/ui/widget/lists/model_importer.py +1 -2
  194. pygpt_net/ui/widget/lists/preset.py +1 -2
  195. pygpt_net/ui/widget/lists/preset_plugins.py +1 -2
  196. pygpt_net/ui/widget/lists/profile.py +1 -2
  197. pygpt_net/ui/widget/lists/uploaded.py +1 -2
  198. pygpt_net/ui/widget/option/checkbox.py +2 -4
  199. pygpt_net/ui/widget/option/checkbox_list.py +1 -4
  200. pygpt_net/ui/widget/option/cmd.py +1 -4
  201. pygpt_net/ui/widget/option/dictionary.py +25 -28
  202. pygpt_net/ui/widget/option/input.py +1 -3
  203. pygpt_net/ui/widget/tabs/Input.py +16 -12
  204. pygpt_net/ui/widget/tabs/body.py +5 -3
  205. pygpt_net/ui/widget/tabs/layout.py +36 -25
  206. pygpt_net/ui/widget/tabs/output.py +96 -74
  207. pygpt_net/ui/widget/textarea/calendar_note.py +1 -2
  208. pygpt_net/ui/widget/textarea/editor.py +41 -73
  209. pygpt_net/ui/widget/textarea/find.py +11 -10
  210. pygpt_net/ui/widget/textarea/html.py +3 -6
  211. pygpt_net/ui/widget/textarea/input.py +63 -64
  212. pygpt_net/ui/widget/textarea/notepad.py +54 -38
  213. pygpt_net/ui/widget/textarea/output.py +65 -54
  214. pygpt_net/ui/widget/textarea/search_input.py +5 -4
  215. pygpt_net/ui/widget/textarea/web.py +2 -4
  216. pygpt_net/ui/widget/vision/camera.py +2 -31
  217. {pygpt_net-2.6.20.dist-info → pygpt_net-2.6.22.dist-info}/METADATA +25 -154
  218. {pygpt_net-2.6.20.dist-info → pygpt_net-2.6.22.dist-info}/RECORD +218 -217
  219. {pygpt_net-2.6.20.dist-info → pygpt_net-2.6.22.dist-info}/LICENSE +0 -0
  220. {pygpt_net-2.6.20.dist-info → pygpt_net-2.6.22.dist-info}/WHEEL +0 -0
  221. {pygpt_net-2.6.20.dist-info → pygpt_net-2.6.22.dist-info}/entry_points.txt +0 -0
@@ -58,7 +58,7 @@ class Footer:
58
58
 
59
59
  # bottom
60
60
  option = dict(self.window.controller.settings.editor.get_options()["temperature"])
61
- self.window.ui.nodes['temperature.label'] = QLabel(trans("toolbox.temperature.label"))
61
+ self.window.ui.nodes['temperature.label'] = QLabel(trans("toolbox.temperature.label"), self.window)
62
62
  self.window.ui.config['global']['current_temperature'] = \
63
63
  OptionSlider(self.window, 'global', 'current_temperature', option)
64
64
  self.window.ui.add_hook("update.global.current_temperature", self.window.controller.mode.hook_global_temperature)
@@ -68,7 +68,8 @@ class Footer:
68
68
  self.window.ui.nodes['voice.control.btn'].setVisible(False)
69
69
 
70
70
  # per mode options
71
- rows = QVBoxLayout()
71
+ widget = QWidget(self.window)
72
+ rows = QVBoxLayout(widget)
72
73
  # rows.addWidget(self.window.ui.nodes['temperature.label'])
73
74
  # rows.addWidget(self.window.ui.config['global']['current_temperature'])
74
75
  rows.addWidget(self.agent.setup())
@@ -83,21 +84,20 @@ class Footer:
83
84
  self.window.ui.nodes['layout.split'] = ToggleLabel(trans('layout.split'), label_position="left",
84
85
  icon=":/icons/split_screen.svg",
85
86
  parent=self.window)
86
- self.window.ui.nodes['layout.split'].box.stateChanged.connect(
87
- lambda: self.window.controller.ui.tabs.toggle_split_screen(self.window.ui.nodes['layout.split'].box.isChecked())
87
+ self.window.ui.nodes['layout.split'].box.toggled.connect(
88
+ self.window.controller.ui.tabs.toggle_split_screen
88
89
  )
89
- split_layout = QHBoxLayout()
90
+ split_widget = QWidget(widget)
91
+ split_layout = QHBoxLayout(split_widget)
90
92
 
91
- split_layout.addWidget(QLabel(""))
93
+ split_layout.addWidget(QLabel("", split_widget))
92
94
  split_layout.addStretch(1)
93
95
  split_layout.addWidget(self.window.ui.nodes['layout.split'])
94
96
  split_layout.setContentsMargins(5, 0, 15, 0)
95
- split_widget = QWidget()
96
- split_widget.setLayout(split_layout)
97
97
  rows.addWidget(split_widget)
98
98
 
99
99
  # logo
100
- logo_button = self.setup_logo()
100
+ # logo_button = self.setup_logo()
101
101
 
102
102
  # bottom (options and logo)
103
103
  # bottom = QHBoxLayout()
@@ -113,9 +113,6 @@ class Footer:
113
113
  # layout.addLayout(names_layout)
114
114
  # layout.addWidget(bottom_widget)
115
115
 
116
- widget = QWidget()
117
- widget.setLayout(rows)
118
-
119
116
  return widget
120
117
 
121
118
  def setup_name_input(self, id: str, title: str) -> QVBoxLayout:
@@ -127,7 +124,7 @@ class Footer:
127
124
  :return: QVBoxLayout
128
125
  """
129
126
  label_key = 'toolbox.' + id + '.label'
130
- self.window.ui.nodes[label_key] = QLabel(title)
127
+ self.window.ui.nodes[label_key] = QLabel(title, self.window)
131
128
  self.window.ui.nodes[id] = NameInput(self.window, id)
132
129
 
133
130
  layout = QVBoxLayout()
@@ -144,11 +141,11 @@ class Footer:
144
141
  """
145
142
  path = os.path.abspath(os.path.join(self.window.core.config.get_app_path(), 'data', 'logo.png'))
146
143
 
147
- button = QPushButton()
144
+ button = QPushButton(self.window)
148
145
  button.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
149
146
  button.setIcon(QIcon(path))
150
147
  button.setIconSize(QSize(100, 28))
151
148
  button.setFlat(True)
152
- button.clicked.connect(lambda: self.window.controller.dialogs.info.goto_website())
149
+ button.clicked.connect(self.window.controller.dialogs.info.goto_website)
153
150
 
154
- return button
151
+ return button
@@ -6,7 +6,7 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.01.19 19:00:00 #
9
+ # Updated Date: 2025.08.24 23:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtWidgets import QVBoxLayout, QLabel, QHBoxLayout, QWidget, QCheckBox
@@ -31,7 +31,6 @@ class Image:
31
31
  :return: QWidget
32
32
  :rtype: QWidget
33
33
  """
34
- # img variants
35
34
  option = {
36
35
  "type": "int",
37
36
  "slider": True,
@@ -42,32 +41,30 @@ class Image:
42
41
  "value": 1,
43
42
  "multiplier": 1,
44
43
  }
45
- self.window.ui.nodes['img_variants.label'] = QLabel(trans("toolbox.img_variants.label"))
46
- self.window.ui.config['global']['img_variants'] = \
47
- OptionSlider(self.window, 'global', 'img_variants', option)
48
44
 
49
- # img raw
50
- self.window.ui.config['global']['img_raw'] = QCheckBox(trans("img.raw"))
51
- self.window.ui.config['global']['img_raw'].stateChanged.connect(
52
- lambda:
53
- self.window.controller.chat.common.img_toggle_raw(self.window.ui.config['global']['img_raw'].isChecked()))
45
+ ui = self.window.ui
46
+ conf_global = ui.config['global']
54
47
 
55
- # label
56
- label = QLabel(trans("toolbox.img_variants.label"))
48
+ container = QWidget()
49
+ ui.nodes['dalle.options'] = container
50
+
51
+ label_text = trans("toolbox.img_variants.label")
52
+ ui.nodes['img_variants.label'] = QLabel(label_text, parent=container)
53
+
54
+ conf_global['img_variants'] = OptionSlider(self.window, 'global', 'img_variants', option)
55
+ conf_global['img_raw'] = QCheckBox(trans("img.raw"), parent=container)
56
+ conf_global['img_raw'].toggled.connect(self.window.controller.chat.common.img_toggle_raw)
57
57
 
58
- # options
59
58
  cols = QHBoxLayout()
60
- cols.addWidget(self.window.ui.config['global']['img_raw'])
61
- cols.addWidget(self.window.ui.config['global']['img_variants'])
59
+ cols.addWidget(conf_global['img_raw'])
60
+ cols.addWidget(conf_global['img_variants'])
62
61
 
63
- # rows
64
62
  rows = QVBoxLayout()
65
- rows.addWidget(label)
63
+ rows.addWidget(ui.nodes['img_variants.label'])
66
64
  rows.addLayout(cols)
67
65
  rows.setContentsMargins(2, 5, 5, 5)
68
66
 
69
- self.window.ui.nodes['dalle.options'] = QWidget()
70
- self.window.ui.nodes['dalle.options'].setLayout(rows)
71
- self.window.ui.nodes['dalle.options'].setContentsMargins(2, 0, 0, 0)
67
+ container.setLayout(rows)
68
+ container.setContentsMargins(2, 0, 0, 0)
72
69
 
73
- return self.window.ui.nodes['dalle.options']
70
+ return container
@@ -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.08.27 22:00:00 #
9
+ # Updated Date: 2025.08.24 23:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtGui import QStandardItemModel, Qt, QIcon
@@ -17,7 +17,6 @@ from pygpt_net.ui.widget.lists.index import IndexList
17
17
  from pygpt_net.ui.widget.lists.index_combo import IndexCombo
18
18
  from pygpt_net.ui.widget.lists.llama_mode_combo import LlamaModeCombo
19
19
  from pygpt_net.utils import trans
20
- import pygpt_net.icons_rc
21
20
 
22
21
 
23
22
  class Indexes:
@@ -29,6 +28,8 @@ class Indexes:
29
28
  """
30
29
  self.window = window
31
30
  self.id = 'indexes'
31
+ self._settings_icon = QIcon(":/icons/settings.svg")
32
+ self._last_combo_signature = None
32
33
 
33
34
  def setup(self) -> QWidget:
34
35
  """
@@ -37,12 +38,13 @@ class Indexes:
37
38
  :return: QWidget
38
39
  """
39
40
  layout = self.setup_idx()
41
+ nodes = self.window.ui.nodes
40
42
 
41
- self.window.ui.nodes['indexes.widget'] = QWidget()
42
- self.window.ui.nodes['indexes.widget'].setLayout(layout)
43
- self.window.ui.nodes['indexes.widget'].setMinimumHeight(150)
43
+ nodes['indexes.widget'] = QWidget()
44
+ nodes['indexes.widget'].setLayout(layout)
45
+ nodes['indexes.widget'].setMinimumHeight(150)
44
46
 
45
- return self.window.ui.nodes['indexes.widget']
47
+ return nodes['indexes.widget']
46
48
 
47
49
  def setup_idx(self) -> QVBoxLayout:
48
50
  """
@@ -50,40 +52,31 @@ class Indexes:
50
52
 
51
53
  :return: QVBoxLayout
52
54
  """
53
- # new
54
- self.window.ui.nodes['indexes.new'] = QPushButton(QIcon(":/icons/settings.svg"), "")
55
- self.window.ui.nodes['indexes.new'].clicked.connect(
56
- lambda: self.window.controller.settings.open_section('llama-index'))
55
+ nodes = self.window.ui.nodes
56
+ nodes['indexes.new'] = QPushButton(self._settings_icon, "")
57
+ nodes['indexes.new'].clicked.connect(self._open_llama_index_settings)
57
58
 
58
- # label
59
- self.window.ui.nodes['indexes.label'] = TitleLabel(trans("toolbox.indexes.label"))
59
+ nodes['indexes.label'] = TitleLabel(trans("toolbox.indexes.label"))
60
60
 
61
- # header
62
61
  header = QHBoxLayout()
63
- header.addWidget(self.window.ui.nodes['indexes.label'])
62
+ header.addWidget(nodes['indexes.label'])
64
63
  header.addStretch(1)
65
- header.addWidget(self.window.ui.nodes['indexes.new'], alignment=Qt.AlignRight)
64
+ header.addWidget(nodes['indexes.new'], alignment=Qt.AlignRight)
66
65
  header.setContentsMargins(5, 0, 0, 0)
67
- header_widget = QWidget()
68
- header_widget.setLayout(header)
69
66
 
70
- # list
71
- self.window.ui.nodes[self.id] = IndexList(self.window, self.id)
72
- self.window.ui.nodes[self.id].selection_locked = self.window.controller.idx.change_locked
73
- self.window.ui.nodes[self.id].setMinimumWidth(40)
67
+ nodes[self.id] = IndexList(self.window, self.id)
68
+ nodes[self.id].selection_locked = self.window.controller.idx.change_locked
69
+ nodes[self.id].setMinimumWidth(40)
74
70
 
75
- self.window.ui.nodes['tip.toolbox.indexes'] = HelpLabel(trans('tip.toolbox.indexes'), self.window)
71
+ nodes['tip.toolbox.indexes'] = HelpLabel(trans('tip.toolbox.indexes'), self.window)
76
72
 
77
- # rows
78
73
  layout = QVBoxLayout()
79
- layout.addWidget(header_widget)
74
+ layout.addLayout(header)
80
75
  layout.addWidget(self.window.ui.nodes[self.id])
81
76
  layout.setContentsMargins(2, 5, 5, 5)
82
- #layout.addWidget(self.window.ui.nodes['tip.toolbox.indexes'])
83
77
 
84
- # model
85
78
  self.window.ui.models[self.id] = self.create_model(self.window)
86
- self.window.ui.nodes[self.id].setModel(self.window.ui.models[self.id])
79
+ nodes[self.id].setModel(self.window.ui.models[self.id])
87
80
 
88
81
  return layout
89
82
 
@@ -94,100 +87,69 @@ class Indexes:
94
87
  :return: QWidget
95
88
  :rtype: QWidget
96
89
  """
97
- # idx query only
98
- """
99
- self.window.ui.config['global']['llama.idx.raw'] = QCheckBox(trans("idx.query.raw"))
100
- self.window.ui.config['global']['llama.idx.raw'].stateChanged.connect(
101
- lambda: self.window.controller.idx.common.toggle_raw(
102
- self.window.ui.config['global']['llama.idx.raw'].isChecked()
103
- )
104
- )
105
- """
106
-
107
- # label
108
- # label = QLabel(trans("toolbox.llama_index.label"))
109
-
110
- # add options
111
- # cols = QHBoxLayout()
112
- # cols.addWidget(self.window.ui.config['global']['llama.idx.raw'])
113
-
114
- # indexes combo
90
+ nodes = self.window.ui.nodes
115
91
  option = {
116
92
  "name": "current_index",
117
93
  "label": "toolbox.llama_index.current_index",
118
94
  "keys": [],
119
95
  "value": None,
120
96
  }
121
- self.window.ui.nodes['indexes.select'] = IndexCombo(
97
+ nodes['indexes.select'] = IndexCombo(
122
98
  self.window,
123
99
  'global',
124
100
  'current_index',
125
101
  option,
126
102
  )
127
- self.window.ui.nodes['indexes.select'].setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
103
+ nodes['indexes.select'].setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
128
104
 
129
- # mode select combo
130
105
  option = {
131
106
  "name": "llama.idx.mode",
132
107
  "label": "toolbox.llama_index.mode",
133
108
  "keys": self.window.controller.idx.get_modes_keys(),
134
109
  "value": "chat",
135
110
  }
136
- self.window.ui.nodes['llama_index.mode.select'] = LlamaModeCombo(
111
+ nodes['llama_index.mode.select'] = LlamaModeCombo(
137
112
  self.window,
138
113
  'global',
139
114
  'llama.idx.mode',
140
115
  option,
141
116
  )
142
- self.window.ui.nodes['indexes.select'].setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
143
- self.window.ui.nodes['llama_index.mode.select'].setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
144
-
145
- # tip
146
- # self.window.ui.nodes['tip.toolbox.indexes'] = HelpLabel(trans('tip.toolbox.indexes'), self.window)
117
+ nodes['llama_index.mode.select'].setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
147
118
 
148
- # new
149
- self.window.ui.nodes['indexes.new'] = QPushButton(QIcon(":/icons/settings.svg"), "")
150
- self.window.ui.nodes['indexes.new'].clicked.connect(
151
- lambda: self.window.controller.settings.open_section('llama-index'))
119
+ nodes['indexes.new'] = QPushButton(self._settings_icon, "")
120
+ nodes['indexes.new'].clicked.connect(self._open_llama_index_settings)
152
121
 
153
- # labels
154
- self.window.ui.nodes['indexes.label'] = TitleLabel(trans("toolbox.indexes.label"))
155
- self.window.ui.nodes['llama_index.mode.label'] = TitleLabel(trans("toolbox.llama_index.mode.label"))
122
+ nodes['indexes.label'] = TitleLabel(trans("toolbox.indexes.label"))
123
+ nodes['llama_index.mode.label'] = TitleLabel(trans("toolbox.llama_index.mode.label"))
156
124
 
157
- # idx select combo
158
125
  idx_layout = QHBoxLayout()
159
- idx_layout.addWidget(self.window.ui.nodes['indexes.label'])
160
- idx_layout.addWidget(self.window.ui.nodes['indexes.select'])
161
- idx_layout.addWidget(self.window.ui.nodes['indexes.new'], alignment=Qt.AlignRight)
126
+ idx_layout.addWidget(nodes['indexes.label'])
127
+ idx_layout.addWidget(nodes['indexes.select'])
128
+ idx_layout.addWidget(nodes['indexes.new'], alignment=Qt.AlignRight)
162
129
  idx_layout.setContentsMargins(0, 0, 0, 10)
163
130
  idx_widget = QWidget()
164
131
  idx_widget.setLayout(idx_layout)
165
132
  idx_widget.setMinimumHeight(55)
166
133
  idx_widget.setMinimumWidth(275)
167
134
 
168
- # mode select combo
169
135
  mode_layout = QHBoxLayout()
170
- mode_layout.addWidget(self.window.ui.nodes['llama_index.mode.label'])
171
- mode_layout.addWidget(self.window.ui.nodes['llama_index.mode.select'])
136
+ mode_layout.addWidget(nodes['llama_index.mode.label'])
137
+ mode_layout.addWidget(nodes['llama_index.mode.select'])
172
138
  mode_layout.setContentsMargins(0, 0, 0, 10)
173
139
  mode_widget = QWidget()
174
140
  mode_widget.setLayout(mode_layout)
175
141
  mode_widget.setMinimumHeight(55)
176
142
  mode_widget.setMinimumWidth(275)
177
143
 
178
- # rows
179
144
  rows = QVBoxLayout()
180
- # rows.addWidget(label)
181
145
  rows.addWidget(idx_widget)
182
146
  rows.addWidget(mode_widget)
183
- # rows.addLayout(cols) # raw option
184
- # rows.addWidget(self.window.ui.nodes['tip.toolbox.indexes'])
185
147
 
186
- self.window.ui.nodes['idx.options'] = QWidget()
187
- self.window.ui.nodes['idx.options'].setLayout(rows)
188
- self.window.ui.nodes['idx.options'].setContentsMargins(0, 0, 0, 0)
148
+ nodes['idx.options'] = QWidget()
149
+ nodes['idx.options'].setLayout(rows)
150
+ nodes['idx.options'].setContentsMargins(0, 0, 0, 0)
189
151
 
190
- return self.window.ui.nodes['idx.options']
152
+ return nodes['idx.options']
191
153
 
192
154
  def create_model(self, parent) -> QStandardItemModel:
193
155
  """
@@ -204,19 +166,11 @@ class Indexes:
204
166
 
205
167
  :param data: Data to update
206
168
  """
207
- # combo box
208
- combo_keys = []
209
- combo_keys.append({ # add empty
210
- "-": "---"
211
- })
212
- for item in data:
213
- name = item['name']
214
- if name == "":
215
- name = item['id']
216
- combo_keys.append({
217
- item['id']: name
218
- })
219
- self.window.ui.nodes['indexes.select'].set_keys(combo_keys)
169
+ combo_keys = [{"-": "---"}] + [{item['id']: (item['name'] or item['id'])} for item in data]
170
+ signature = tuple((item['id'], (item['name'] or item['id'])) for item in data)
171
+ if self._last_combo_signature != signature:
172
+ self.window.ui.nodes['indexes.select'].set_keys(combo_keys)
173
+ self._last_combo_signature = signature
220
174
  """
221
175
  # store previous selection
222
176
  self.window.ui.nodes[self.id].backup_selection()
@@ -234,3 +188,6 @@ class Indexes:
234
188
  # restore previous selection
235
189
  self.window.ui.nodes[self.id].restore_selection()
236
190
  """
191
+
192
+ def _open_llama_index_settings(self):
193
+ self.window.controller.settings.open_section('llama-index')
@@ -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.17 03:00:00 #
9
+ # Updated Date: 2025.08.24 23:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtWidgets import QVBoxLayout, QWidget
@@ -25,6 +25,8 @@ class Mode:
25
25
  """
26
26
  self.window = window
27
27
  self.id = 'prompt.mode'
28
+ self._label_key = f'{self.id}.label'
29
+ self._label_trans_key = 'toolbox.mode.label'
28
30
 
29
31
  def setup(self) -> QWidget:
30
32
  """
@@ -42,18 +44,29 @@ class Mode:
42
44
 
43
45
  :return: QVBoxLayout
44
46
  """
45
- label_key = self.id + '.label'
46
- self.window.ui.nodes[self.id] = ModeCombo(self.window, self.id)
47
- self.window.ui.nodes[label_key] = TitleLabel(trans("toolbox.mode.label"))
47
+ ui_nodes = self.window.ui.nodes
48
+
49
+ label = ui_nodes.get(self._label_key)
50
+ label_text = trans(self._label_trans_key)
51
+ if label is None:
52
+ label = TitleLabel(label_text)
53
+ ui_nodes[self._label_key] = label
54
+ else:
55
+ label.setText(label_text)
56
+
57
+ combo = ui_nodes.get(self.id)
58
+ if combo is None:
59
+ combo = ModeCombo(self.window, self.id)
60
+ ui_nodes[self.id] = combo
48
61
 
49
62
  header_layout = QVBoxLayout()
50
- header_layout.addWidget(self.window.ui.nodes[label_key])
63
+ header_layout.addWidget(label)
51
64
  header_layout.setContentsMargins(5, 5, 0, 0)
52
65
 
53
66
  layout = QVBoxLayout()
54
67
  layout.addLayout(header_layout)
55
- layout.addWidget(self.window.ui.nodes[self.id])
68
+ layout.addWidget(combo)
56
69
  layout.addStretch()
57
70
  layout.setContentsMargins(2, 5, 5, 5)
58
71
 
59
- return layout
72
+ return layout
@@ -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.17 03:00:00 #
9
+ # Updated Date: 2025.08.24 23:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtWidgets import QVBoxLayout, QWidget
@@ -17,6 +17,7 @@ from pygpt_net.utils import trans
17
17
 
18
18
 
19
19
  class Model:
20
+
20
21
  def __init__(self, window=None):
21
22
  """
22
23
  Toolbox UI
@@ -25,6 +26,7 @@ class Model:
25
26
  """
26
27
  self.window = window
27
28
  self.id = 'prompt.model'
29
+ self.label_key = f'{self.id}.label'
28
30
 
29
31
  def setup(self) -> QWidget:
30
32
  """
@@ -42,19 +44,19 @@ class Model:
42
44
 
43
45
  :return: QVBoxLayout
44
46
  """
45
- label_key = self.id + '.label'
47
+ nodes = self.window.ui.nodes
46
48
 
47
- self.window.ui.nodes[label_key] = TitleLabel(trans("toolbox.model.label"))
48
- self.window.ui.nodes[self.id] = ModelCombo(self.window, self.id)
49
+ label = TitleLabel(trans("toolbox.model.label"))
50
+ label.setContentsMargins(5, 0, 0, 0)
51
+ nodes[self.label_key] = label
49
52
 
50
- header_layout = QVBoxLayout()
51
- header_layout.addWidget(self.window.ui.nodes[label_key])
52
- header_layout.setContentsMargins(5, 0, 0, 0)
53
+ combo = ModelCombo(self.window, self.id)
54
+ nodes[self.id] = combo
53
55
 
54
56
  layout = QVBoxLayout()
55
- layout.addLayout(header_layout)
56
- layout.addWidget(self.window.ui.nodes[self.id])
57
+ layout.addWidget(label)
58
+ layout.addWidget(combo)
57
59
  layout.addStretch()
58
60
  layout.setContentsMargins(2, 5, 5, 5)
59
61
 
60
- return layout
62
+ return layout