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
@@ -6,28 +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: 2025.08.07 19:00:00 #
9
+ # Updated Date: 2025.08.24 23:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtCore import Qt
13
- from PySide6.QtWidgets import QVBoxLayout, QLabel, QHBoxLayout, QCheckBox, QWidget, QSizePolicy, QPushButton, \
14
- QGridLayout, QWidgetItem, QLayout
13
+ from PySide6.QtWidgets import QVBoxLayout, QHBoxLayout, QCheckBox, QWidget, QSizePolicy, \
14
+ QGridLayout
15
15
 
16
16
  from pygpt_net.ui.widget.audio.output import AudioOutput
17
17
  from pygpt_net.ui.widget.element.labels import ChatStatusLabel, IconLabel, HelpLabel
18
- from pygpt_net.ui.widget.anims.loader import Loading
19
18
  from pygpt_net.ui.widget.tabs.layout import OutputLayout
19
+ from pygpt_net.utils import trans
20
20
 
21
21
  from .explorer import Explorer
22
22
  from .input import Input
23
23
  from .calendar import Calendar
24
24
  from .painter import Painter
25
25
 
26
- from pygpt_net.utils import trans
27
- import pygpt_net.icons_rc
28
-
29
-
30
-
31
26
  class Output:
32
27
  def __init__(self, window=None):
33
28
  """
@@ -47,10 +42,7 @@ class Output:
47
42
 
48
43
  :return: QWidget
49
44
  """
50
- # prepare columns
51
45
  self.window.ui.layout = OutputLayout(self.window)
52
-
53
- # create empty containers for chat output
54
46
  self.window.ui.nodes['output'] = {}
55
47
  self.window.ui.nodes['output_plain'] = {}
56
48
 
@@ -69,176 +61,122 @@ class Output:
69
61
 
70
62
  :return: QHBoxLayout
71
63
  """
72
- # video capture icon
73
- self.window.ui.nodes['icon.video.capture'] = IconLabel(":/icons/webcam.svg", window=self.window)
74
- self.window.ui.nodes['icon.video.capture'].setToolTip(trans("icon.video.capture"))
75
- self.window.ui.nodes['icon.video.capture'].clicked.connect(
76
- lambda:self.window.controller.camera.toggle_capture()
77
- )
78
-
79
- # audio output icon
80
- self.window.ui.nodes['icon.audio.output'] = IconLabel(":/icons/volume.svg", window=self.window)
81
- self.window.ui.nodes['icon.audio.output'].setToolTip(trans("icon.audio.output"))
82
- self.window.ui.nodes['icon.audio.output'].clicked.connect(
83
- lambda: self.window.controller.plugins.toggle('audio_output')
84
- )
85
-
86
- # audio input icon
87
- self.window.ui.nodes['icon.audio.input'] = IconLabel(":/icons/mic.svg", window=self.window)
88
- self.window.ui.nodes['icon.audio.input'].setToolTip(trans("icon.audio.input"))
89
- self.window.ui.nodes['icon.audio.input'].clicked.connect(
90
- lambda: self.window.controller.plugins.toggle('audio_input')
91
- )
92
-
93
- # interpreter icon
94
- self.window.ui.nodes['icon.interpreter'] = IconLabel(":/icons/code.svg", window=self.window)
95
- self.window.ui.nodes['icon.interpreter'].setToolTip("Python Code Interpreter")
96
- self.window.ui.nodes['icon.interpreter'].clicked.connect(
97
- lambda: self.window.tools.get("interpreter").toggle()
98
- )
99
-
100
- # indexer icon
101
- self.window.ui.nodes['icon.indexer'] = IconLabel(":/icons/db.svg", window=self.window)
102
- self.window.ui.nodes['icon.indexer'].setToolTip("Indexer")
103
- self.window.ui.nodes['icon.indexer'].clicked.connect(
104
- lambda: self.window.tools.get("indexer").toggle()
105
- )
106
-
107
- # mode
108
- self.window.ui.nodes['chat.label'] = ChatStatusLabel("")
109
- self.window.ui.nodes['chat.label'].setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
110
- self.window.ui.nodes['chat.label'].setWordWrap(False)
111
-
112
- # model
113
- self.window.ui.nodes['chat.model'] = ChatStatusLabel("")
114
- self.window.ui.nodes['chat.model'].setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
115
- self.window.ui.nodes['chat.model'].setWordWrap(False)
116
-
117
- # plugins
118
- self.window.ui.nodes['chat.plugins'] = ChatStatusLabel("")
119
- self.window.ui.nodes['chat.plugins'].setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
120
-
121
- # timestamp
122
- self.window.ui.nodes['output.timestamp'] = QCheckBox(trans('output.timestamp'))
123
- self.window.ui.nodes['output.timestamp'].stateChanged.connect(
124
- lambda: self.window.controller.chat.common.toggle_timestamp(
125
- self.window.ui.nodes['output.timestamp'].isChecked())
126
- )
127
-
128
- # plain text
129
- self.window.ui.nodes['output.raw'] = QCheckBox(trans('output.raw'))
130
- self.window.ui.nodes['output.raw'].clicked.connect(
131
- lambda: self.window.controller.chat.common.toggle_raw(
132
- self.window.ui.nodes['output.raw'].isChecked())
133
- )
64
+ nodes = self.window.ui.nodes
65
+ plugin_addon = self.window.ui.plugin_addon
66
+ ctrl = self.window.controller
67
+ tools = self.window.tools
134
68
 
135
- """
136
- # edit icons
137
- self.window.ui.nodes['output.edit'] = QCheckBox(trans('output.edit'))
138
- self.window.ui.nodes['output.edit'].clicked.connect(
139
- lambda: self.window.controller.chat.common.toggle_edit_icons(
140
- self.window.ui.nodes['output.edit'].isChecked())
141
- )
142
- """
69
+ nodes['icon.video.capture'] = IconLabel(":/icons/webcam.svg", window=self.window)
70
+ nodes['icon.video.capture'].setToolTip(trans("icon.video.capture"))
71
+ nodes['icon.video.capture'].clicked.connect(lambda: ctrl.camera.toggle_capture())
72
+
73
+ nodes['icon.audio.output'] = IconLabel(":/icons/volume.svg", window=self.window)
74
+ nodes['icon.audio.output'].setToolTip(trans("icon.audio.output"))
75
+ nodes['icon.audio.output'].clicked.connect(lambda: ctrl.plugins.toggle('audio_output'))
143
76
 
144
- # tokens
145
- self.window.ui.nodes['prompt.context'] = ChatStatusLabel("")
146
- self.window.ui.nodes['prompt.context'].setToolTip(trans('tip.tokens.ctx'))
147
- self.window.ui.nodes['prompt.context'].setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
77
+ nodes['icon.audio.input'] = IconLabel(":/icons/mic.svg", window=self.window)
78
+ nodes['icon.audio.input'].setToolTip(trans("icon.audio.input"))
79
+ nodes['icon.audio.input'].clicked.connect(lambda: ctrl.plugins.toggle('audio_input'))
148
80
 
149
- self.window.ui.nodes['input.counter'] = ChatStatusLabel("")
150
- self.window.ui.nodes['input.counter'].setToolTip(trans('tip.tokens.input'))
151
- self.window.ui.nodes['input.counter'].setWordWrap(False)
81
+ nodes['icon.interpreter'] = IconLabel(":/icons/code.svg", window=self.window)
82
+ nodes['icon.interpreter'].setToolTip("Python Code Interpreter")
83
+ nodes['icon.interpreter'].clicked.connect(lambda: tools.get("interpreter").toggle())
152
84
 
153
- # plugin audio output addon
154
- self.window.ui.plugin_addon['audio.output'] = AudioOutput(self.window)
85
+ nodes['icon.indexer'] = IconLabel(":/icons/db.svg", window=self.window)
86
+ nodes['icon.indexer'].setToolTip("Indexer")
87
+ nodes['icon.indexer'].clicked.connect(lambda: tools.get("indexer").toggle())
155
88
 
156
- # schedule
157
- self.window.ui.plugin_addon['schedule'] = ChatStatusLabel("")
89
+ min_policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
158
90
 
159
- # inline vision
160
- self.window.ui.nodes['inline.vision'] = HelpLabel(trans('inline.vision'))
161
- self.window.ui.nodes['inline.vision'].setVisible(False)
162
- self.window.ui.nodes['inline.vision'].setContentsMargins(0, 0, 0, 0)
91
+ nodes['chat.label'] = ChatStatusLabel("")
92
+ nodes['chat.label'].setSizePolicy(min_policy)
93
+ nodes['chat.label'].setWordWrap(False)
94
+
95
+ nodes['chat.model'] = ChatStatusLabel("")
96
+ nodes['chat.model'].setSizePolicy(min_policy)
97
+ nodes['chat.model'].setWordWrap(False)
98
+
99
+ nodes['chat.plugins'] = ChatStatusLabel("")
100
+ nodes['chat.plugins'].setSizePolicy(min_policy)
101
+
102
+ nodes['output.timestamp'] = QCheckBox(trans('output.timestamp'))
103
+ nodes['output.timestamp'].toggled.connect(ctrl.chat.common.toggle_timestamp)
104
+
105
+ nodes['output.raw'] = QCheckBox(trans('output.raw'))
106
+ nodes['output.raw'].toggled.connect(ctrl.chat.common.toggle_raw)
107
+
108
+ nodes['prompt.context'] = ChatStatusLabel("")
109
+ nodes['prompt.context'].setToolTip(trans('tip.tokens.ctx'))
110
+ nodes['prompt.context'].setSizePolicy(min_policy)
111
+
112
+ nodes['input.counter'] = ChatStatusLabel("")
113
+ nodes['input.counter'].setToolTip(trans('tip.tokens.input'))
114
+ nodes['input.counter'].setWordWrap(False)
115
+
116
+ plugin_addon['audio.output'] = AudioOutput(self.window)
117
+ plugin_addon['schedule'] = ChatStatusLabel("")
118
+
119
+ nodes['inline.vision'] = HelpLabel(trans('inline.vision'))
120
+ nodes['inline.vision'].setVisible(False)
121
+ nodes['inline.vision'].setContentsMargins(0, 0, 0, 0)
163
122
 
164
123
  opts_layout = QHBoxLayout()
165
- # opts_layout.setSpacing(2) #
166
124
  opts_layout.setContentsMargins(0, 0, 0, 0)
167
- opts_layout.addWidget(self.window.ui.nodes['output.raw'])
168
- opts_layout.addWidget(self.window.ui.nodes['output.timestamp'])
169
- # opts_layout.addWidget(self.window.ui.nodes['output.edit'])
170
-
171
- opts_layout.addWidget(self.window.ui.nodes['inline.vision'])
125
+ opts_layout.addWidget(nodes['output.raw'])
126
+ opts_layout.addWidget(nodes['output.timestamp'])
127
+ opts_layout.addWidget(nodes['inline.vision'])
172
128
  opts_layout.setAlignment(Qt.AlignLeft)
173
129
 
174
- left_layout = QHBoxLayout()
175
- left_layout.addLayout(opts_layout)
176
- left_layout.setContentsMargins(0, 0, 0, 0)
177
-
178
- right_layout = QHBoxLayout()
179
- right_layout.addWidget(self.window.ui.nodes['icon.video.capture'])
180
- right_layout.addWidget(self.window.ui.nodes['icon.audio.input'])
181
- right_layout.addWidget(self.window.ui.nodes['icon.audio.output'])
182
- right_layout.addWidget(self.window.ui.nodes['icon.interpreter'])
183
- right_layout.addWidget(self.window.ui.nodes['icon.indexer'])
184
- right_layout.addWidget(self.window.ui.plugin_addon['schedule'])
185
- right_layout.addWidget(QLabel(" "))
186
- right_layout.addWidget(self.window.ui.nodes['chat.plugins'])
187
- right_layout.addWidget(QLabel(" "))
188
- right_layout.addWidget(self.window.ui.nodes['chat.label'])
189
- right_layout.addWidget(QLabel(" "))
190
- right_layout.addWidget(self.window.ui.nodes['chat.model'])
191
- right_layout.addWidget(QLabel(" "))
192
- right_layout.addWidget(self.window.ui.nodes['prompt.context'])
193
- right_layout.addWidget(QLabel(" "))
194
- right_layout.addWidget(self.window.ui.nodes['input.counter'])
195
- right_layout.setContentsMargins(0, 8, 20, 0)
196
-
197
- left_widget = QWidget()
198
- left_widget.setLayout(left_layout)
199
- right_widget = QWidget()
200
- right_widget.setLayout(right_layout)
201
-
202
- self.window.ui.nodes['anim.loading'] = QWidget()
203
- self.window.ui.nodes['anim.loading'].hide()
130
+ left_bar_layout = QHBoxLayout()
131
+ left_bar_layout.addLayout(opts_layout)
132
+ left_bar_layout.setContentsMargins(0, 0, 0, 0)
133
+
134
+ nodes['anim.loading'] = QWidget()
135
+ nodes['anim.loading'].hide()
136
+
137
+ right_bar_layout = QHBoxLayout()
138
+ right_bar_layout.addWidget(nodes['icon.video.capture'])
139
+ right_bar_layout.addWidget(nodes['icon.audio.input'])
140
+ right_bar_layout.addWidget(nodes['icon.audio.output'])
141
+ right_bar_layout.addWidget(nodes['icon.interpreter'])
142
+ right_bar_layout.addWidget(nodes['icon.indexer'])
143
+ right_bar_layout.addWidget(plugin_addon['schedule'])
144
+ right_bar_layout.addSpacing(6)
145
+ right_bar_layout.addWidget(nodes['chat.plugins'])
146
+ right_bar_layout.addSpacing(6)
147
+ right_bar_layout.addWidget(nodes['chat.label'])
148
+ right_bar_layout.addSpacing(12)
149
+ right_bar_layout.addWidget(nodes['chat.model'])
150
+ right_bar_layout.addSpacing(12)
151
+ right_bar_layout.addWidget(nodes['prompt.context'])
152
+ right_bar_layout.addSpacing(12)
153
+ right_bar_layout.addWidget(nodes['input.counter'])
154
+ right_bar_layout.setContentsMargins(0, 8, 20, 0)
204
155
 
205
156
  grid = QGridLayout()
206
-
207
- left_layout = QHBoxLayout()
208
- left_layout.addWidget(left_widget)
209
- #left_layout.addStretch(1)
210
- left_layout.setContentsMargins(0, 0, 0, 0)
211
-
212
- center_layout = QHBoxLayout()
213
- #center_layout.addStretch()
214
- center_layout.addWidget(self.window.ui.nodes['anim.loading'])
215
- center_layout.addStretch()
216
- center_layout.setContentsMargins(20, 0, 0, 0)
217
-
218
- right_layout = QHBoxLayout()
219
- right_layout.addStretch(1)
220
- right_layout.addWidget(right_widget)
221
- right_layout.setContentsMargins(0, 0, 0, 0)
222
-
223
- grid.addLayout(left_layout, 0, 0)
224
- grid.addLayout(center_layout, 0, 1, alignment=Qt.AlignCenter)
225
- grid.addLayout(right_layout, 0, 2, alignment=Qt.AlignRight)
157
+ grid.addLayout(left_bar_layout, 0, 0)
158
+ grid.addWidget(nodes['anim.loading'], 0, 1, alignment=Qt.AlignCenter)
159
+ grid.addLayout(right_bar_layout, 0, 2, alignment=Qt.AlignRight)
160
+ grid.setColumnStretch(0, 0)
161
+ grid.setColumnStretch(1, 1)
162
+ grid.setColumnStretch(2, 0)
226
163
  grid.setContentsMargins(0, 0, 0, 0)
227
164
 
228
- self.window.ui.nodes['chat.footer'] = QWidget()
229
- self.window.ui.nodes['chat.footer'].setLayout(grid)
165
+ nodes['chat.footer'] = QWidget()
166
+ nodes['chat.footer'].setLayout(grid)
230
167
 
231
168
  bottom_layout = QVBoxLayout()
232
- bottom_layout.addWidget(self.window.ui.nodes['chat.footer'])
169
+ bottom_layout.addWidget(nodes['chat.footer'])
233
170
  bottom_layout.setContentsMargins(2, 0, 2, 0)
234
171
  return bottom_layout
235
172
 
236
173
  def set_fixed_size_policy(self, layout):
237
174
  for i in range(layout.count()):
238
175
  item = layout.itemAt(i)
239
- if isinstance(item, QWidgetItem):
240
- widget = item.widget()
241
- if widget:
242
- widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
243
- elif isinstance(item, QLayout):
244
- self.set_fixed_size_policy(item)
176
+ w = item.widget()
177
+ if w is not None:
178
+ w.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
179
+ else:
180
+ l = item.layout()
181
+ if l is not None:
182
+ self.set_fixed_size_policy(l)
@@ -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: 2025.01.19 02:00:00 #
9
+ # Updated Date: 2025.08.24 23:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from PySide6.QtGui import QPixmap, QIcon
13
13
  from PySide6.QtWidgets import QVBoxLayout, QHBoxLayout, QWidget, QRadioButton, QPushButton, QComboBox, QScrollArea
14
+ from PySide6.QtCore import QSize
14
15
 
15
16
  from pygpt_net.ui.widget.draw.painter import PainterWidget
16
17
  from pygpt_net.ui.widget.element.labels import HelpLabel
@@ -26,6 +27,7 @@ class Painter:
26
27
  :param window: Window instance
27
28
  """
28
29
  self.window = window
30
+ self._initialized = False
29
31
 
30
32
  def init(self):
31
33
  """
@@ -33,47 +35,62 @@ class Painter:
33
35
 
34
36
  :return: QWidget
35
37
  """
36
- self.window.ui.painter = PainterWidget(self.window)
38
+ ui = self.window.ui
39
+ nodes = ui.nodes
40
+ common = self.window.controller.painter.common
41
+
42
+ if getattr(ui, 'painter', None) is None:
43
+ ui.painter = PainterWidget(self.window)
37
44
 
38
45
  key = 'painter.btn.brush'
39
- self.window.ui.nodes[key] = QRadioButton(trans('painter.mode.paint'))
40
- self.window.ui.nodes[key].setChecked(True)
41
- self.window.ui.nodes[key].toggled.connect(self.window.controller.painter.common.set_brush_mode)
46
+ if nodes.get(key) is None:
47
+ rb = QRadioButton(trans('painter.mode.paint'))
48
+ rb.setChecked(True)
49
+ rb.toggled.connect(self.window.controller.painter.common.set_brush_mode)
50
+ nodes[key] = rb
42
51
 
43
52
  key = 'painter.btn.erase'
44
- self.window.ui.nodes[key] = QRadioButton(trans('painter.mode.erase'))
45
- self.window.ui.nodes[key].toggled.connect(self.window.controller.painter.common.set_erase_mode)
53
+ if nodes.get(key) is None:
54
+ rb = QRadioButton(trans('painter.mode.erase'))
55
+ rb.toggled.connect(self.window.controller.painter.common.set_erase_mode)
56
+ nodes[key] = rb
46
57
 
47
58
  key = 'painter.select.brush.size'
48
- sizes = self.window.controller.painter.common.get_sizes()
49
- self.window.ui.nodes[key] = QComboBox()
50
- self.window.ui.nodes[key].addItems(sizes)
51
- self.window.ui.nodes[key].currentTextChanged.connect(
52
- self.window.controller.painter.common.change_brush_size)
53
- self.window.ui.nodes[key].setMinimumContentsLength(10)
54
- self.window.ui.nodes[key].setSizeAdjustPolicy(QComboBox.AdjustToContents)
59
+ if nodes.get(key) is None:
60
+ sizes = common.get_sizes()
61
+ cb = QComboBox()
62
+ cb.addItems(sizes)
63
+ cb.currentTextChanged.connect(common.change_brush_size)
64
+ cb.setMinimumContentsLength(10)
65
+ cb.setSizeAdjustPolicy(QComboBox.AdjustToContents)
66
+ nodes[key] = cb
55
67
 
56
68
  key = 'painter.select.canvas.size'
57
- canvas_sizes = self.window.controller.painter.common.get_canvas_sizes()
58
- self.window.ui.nodes[key] = QComboBox()
59
- self.window.ui.nodes[key].addItems(canvas_sizes)
60
- self.window.ui.nodes[key].setMinimumContentsLength(20)
61
- self.window.ui.nodes[key].setSizeAdjustPolicy(QComboBox.AdjustToContents)
62
- self.window.ui.nodes[key].currentTextChanged.connect(
63
- self.window.controller.painter.common.change_canvas_size)
69
+ if nodes.get(key) is None:
70
+ canvas_sizes = common.get_canvas_sizes()
71
+ cb = QComboBox()
72
+ cb.addItems(canvas_sizes)
73
+ cb.setMinimumContentsLength(20)
74
+ cb.setSizeAdjustPolicy(QComboBox.AdjustToContents)
75
+ cb.currentTextChanged.connect(common.change_canvas_size)
76
+ nodes[key] = cb
64
77
 
65
78
  key = 'painter.select.brush.color'
66
- self.window.ui.nodes[key] = QComboBox()
67
- colors = self.window.controller.painter.common.get_colors()
68
- for color_name, color_value in colors.items():
69
- pixmap = QPixmap(100, 100)
70
- pixmap.fill(color_value)
71
- icon = QIcon(pixmap)
72
- self.window.ui.nodes[key].addItem(icon, color_name, color_value)
73
- self.window.ui.nodes[key].currentTextChanged.connect(
74
- self.window.controller.painter.common.change_brush_color)
75
- self.window.ui.nodes[key].setMinimumContentsLength(10)
76
- self.window.ui.nodes[key].setSizeAdjustPolicy(QComboBox.AdjustToContents)
79
+ if nodes.get(key) is None:
80
+ cb = QComboBox()
81
+ cb.setIconSize(QSize(16, 16))
82
+ colors = common.get_colors()
83
+ for color_name, color_value in colors.items():
84
+ pixmap = QPixmap(16, 16)
85
+ pixmap.fill(color_value)
86
+ icon = QIcon(pixmap)
87
+ cb.addItem(icon, color_name, color_value)
88
+ cb.currentTextChanged.connect(common.change_brush_color)
89
+ cb.setMinimumContentsLength(10)
90
+ cb.setSizeAdjustPolicy(QComboBox.AdjustToContents)
91
+ nodes[key] = cb
92
+
93
+ self._initialized = True
77
94
 
78
95
  def setup(self) -> QWidget:
79
96
  """
@@ -81,7 +98,6 @@ class Painter:
81
98
 
82
99
  :return: QWidget
83
100
  """
84
- # build tab body
85
101
  self.init()
86
102
  body = self.window.core.tabs.from_layout(self.setup_painter())
87
103
  body.append(self.window.ui.painter)
@@ -93,39 +109,51 @@ class Painter:
93
109
 
94
110
  :return: QVBoxLayout
95
111
  """
112
+ ui = self.window.ui
113
+ nodes = ui.nodes
114
+
96
115
  top = QHBoxLayout()
97
- top.addWidget(self.window.ui.nodes['painter.btn.brush'])
98
- top.addWidget(self.window.ui.nodes['painter.btn.erase'])
99
- top.addWidget(self.window.ui.nodes['painter.select.brush.size'])
100
- top.addWidget(self.window.ui.nodes['painter.select.brush.color'])
101
- top.addWidget(self.window.ui.nodes['painter.select.canvas.size'])
116
+ top.addWidget(nodes['painter.btn.brush'])
117
+ top.addWidget(nodes['painter.btn.erase'])
118
+ top.addWidget(nodes['painter.select.brush.size'])
119
+ top.addWidget(nodes['painter.select.brush.color'])
120
+ top.addWidget(nodes['painter.select.canvas.size'])
102
121
  top.addStretch(1)
103
122
 
104
- self.window.ui.nodes['painter.btn.capture'] = QPushButton(trans('painter.btn.capture'))
105
- self.window.ui.nodes['painter.btn.capture'].clicked.connect(self.window.controller.painter.capture.use)
106
- top.addWidget(self.window.ui.nodes['painter.btn.capture'])
107
-
108
- self.window.ui.nodes['painter.btn.camera.capture'] = QPushButton(trans('painter.btn.camera.capture'))
109
- self.window.ui.nodes['painter.btn.camera.capture'].clicked.connect(self.window.controller.painter.capture.camera)
110
- top.addWidget(self.window.ui.nodes['painter.btn.camera.capture'])
111
-
112
- self.window.ui.nodes['painter.btn.clear'] = QPushButton(trans('painter.btn.clear'))
113
- self.window.ui.nodes['painter.btn.clear'].clicked.connect(self.window.ui.painter.clear_image)
114
- top.addWidget(self.window.ui.nodes['painter.btn.clear'])
115
-
116
- self.window.ui.painter_scroll = QScrollArea()
117
- self.window.ui.painter_scroll.setWidget(self.window.ui.painter)
118
- self.window.ui.painter_scroll.setWidgetResizable(True)
119
-
120
- self.window.ui.nodes['tip.output.tab.draw'] = HelpLabel(trans('tip.output.tab.draw'), self.window)
123
+ if nodes.get('painter.btn.capture') is None:
124
+ btn = QPushButton(trans('painter.btn.capture'))
125
+ btn.clicked.connect(self.window.controller.painter.capture.use)
126
+ nodes['painter.btn.capture'] = btn
127
+ top.addWidget(nodes['painter.btn.capture'])
128
+
129
+ if nodes.get('painter.btn.camera.capture') is None:
130
+ btn = QPushButton(trans('painter.btn.camera.capture'))
131
+ btn.clicked.connect(self.window.controller.painter.capture.camera)
132
+ nodes['painter.btn.camera.capture'] = btn
133
+ top.addWidget(nodes['painter.btn.camera.capture'])
134
+
135
+ if nodes.get('painter.btn.clear') is None:
136
+ btn = QPushButton(trans('painter.btn.clear'))
137
+ btn.clicked.connect(ui.painter.clear_image)
138
+ nodes['painter.btn.clear'] = btn
139
+ top.addWidget(nodes['painter.btn.clear'])
140
+
141
+ if getattr(ui, 'painter_scroll', None) is None:
142
+ ui.painter_scroll = QScrollArea()
143
+ ui.painter_scroll.setWidget(ui.painter)
144
+ ui.painter_scroll.setWidgetResizable(True)
145
+ else:
146
+ if ui.painter_scroll.widget() is not ui.painter:
147
+ ui.painter_scroll.setWidget(ui.painter)
148
+ ui.painter_scroll.setWidgetResizable(True)
149
+
150
+ if nodes.get('tip.output.tab.draw') is None:
151
+ nodes['tip.output.tab.draw'] = HelpLabel(trans('tip.output.tab.draw'), self.window)
121
152
 
122
153
  layout = QVBoxLayout()
123
154
  layout.addLayout(top)
124
- layout.addWidget( self.window.ui.painter_scroll)
125
- layout.addWidget(self.window.ui.nodes['tip.output.tab.draw'])
155
+ layout.addWidget(ui.painter_scroll)
156
+ layout.addWidget(nodes['tip.output.tab.draw'])
126
157
  layout.setContentsMargins(0, 0, 0, 0)
127
158
 
128
- return layout
129
-
130
-
131
-
159
+ return layout