pygpt-net 2.7.7__py3-none-any.whl → 2.7.9__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.
- pygpt_net/CHANGELOG.txt +12 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +5 -1
- pygpt_net/controller/assistant/batch.py +2 -2
- pygpt_net/controller/assistant/files.py +7 -6
- pygpt_net/controller/assistant/threads.py +0 -0
- pygpt_net/controller/chat/command.py +0 -0
- pygpt_net/controller/dialogs/confirm.py +35 -58
- pygpt_net/controller/lang/mapping.py +9 -9
- pygpt_net/controller/realtime/realtime.py +13 -1
- pygpt_net/controller/remote_store/{google/batch.py → batch.py} +209 -252
- pygpt_net/controller/remote_store/remote_store.py +982 -13
- pygpt_net/core/command/command.py +0 -0
- pygpt_net/core/db/viewer.py +1 -1
- pygpt_net/core/realtime/worker.py +3 -1
- pygpt_net/{controller/remote_store/google → core/remote_store/anthropic}/__init__.py +0 -1
- pygpt_net/core/remote_store/anthropic/files.py +211 -0
- pygpt_net/core/remote_store/anthropic/store.py +208 -0
- pygpt_net/core/remote_store/openai/store.py +5 -4
- pygpt_net/core/remote_store/remote_store.py +5 -1
- pygpt_net/{controller/remote_store/openai → core/remote_store/xai}/__init__.py +0 -1
- pygpt_net/core/remote_store/xai/files.py +225 -0
- pygpt_net/core/remote_store/xai/store.py +219 -0
- pygpt_net/data/config/config.json +10 -6
- pygpt_net/data/config/models.json +38 -22
- pygpt_net/data/config/settings.json +54 -1
- pygpt_net/data/icons/folder_eye.svg +1 -0
- pygpt_net/data/icons/folder_eye_filled.svg +1 -0
- pygpt_net/data/icons/folder_open.svg +1 -0
- pygpt_net/data/icons/folder_open_filled.svg +1 -0
- pygpt_net/data/locale/locale.de.ini +4 -3
- pygpt_net/data/locale/locale.en.ini +14 -4
- pygpt_net/data/locale/locale.es.ini +4 -3
- pygpt_net/data/locale/locale.fr.ini +4 -3
- pygpt_net/data/locale/locale.it.ini +4 -3
- pygpt_net/data/locale/locale.pl.ini +5 -4
- pygpt_net/data/locale/locale.uk.ini +4 -3
- pygpt_net/data/locale/locale.zh.ini +4 -3
- pygpt_net/icons.qrc +4 -0
- pygpt_net/icons_rc.py +282 -138
- pygpt_net/provider/api/anthropic/__init__.py +2 -0
- pygpt_net/provider/api/anthropic/chat.py +84 -1
- pygpt_net/provider/api/anthropic/store.py +307 -0
- pygpt_net/provider/api/anthropic/stream.py +75 -0
- pygpt_net/provider/api/anthropic/worker/__init__.py +0 -0
- pygpt_net/provider/api/anthropic/worker/importer.py +278 -0
- pygpt_net/provider/api/google/chat.py +59 -2
- pygpt_net/provider/api/google/realtime/client.py +70 -24
- pygpt_net/provider/api/google/realtime/realtime.py +48 -12
- pygpt_net/provider/api/google/store.py +124 -3
- pygpt_net/provider/api/google/stream.py +91 -24
- pygpt_net/provider/api/google/worker/importer.py +16 -28
- pygpt_net/provider/api/openai/assistants.py +2 -2
- pygpt_net/provider/api/openai/realtime/realtime.py +26 -6
- pygpt_net/provider/api/openai/store.py +4 -1
- pygpt_net/provider/api/openai/worker/importer.py +19 -61
- pygpt_net/provider/api/openai/worker/importer_assistants.py +230 -0
- pygpt_net/provider/api/x_ai/__init__.py +27 -6
- pygpt_net/provider/api/x_ai/audio.py +43 -11
- pygpt_net/provider/api/x_ai/chat.py +92 -4
- pygpt_net/provider/api/x_ai/realtime/__init__.py +12 -0
- pygpt_net/provider/api/x_ai/realtime/client.py +1864 -0
- pygpt_net/provider/api/x_ai/realtime/realtime.py +213 -0
- pygpt_net/provider/api/x_ai/remote_tools.py +102 -1
- pygpt_net/provider/api/x_ai/store.py +610 -0
- pygpt_net/provider/api/x_ai/stream.py +30 -9
- pygpt_net/provider/api/x_ai/tools.py +51 -0
- pygpt_net/provider/api/x_ai/worker/importer.py +308 -0
- pygpt_net/provider/audio_input/xai_grok_voice.py +390 -0
- pygpt_net/provider/audio_output/xai_tts.py +325 -0
- pygpt_net/provider/core/config/patch.py +29 -3
- pygpt_net/provider/core/config/patches/patch_before_2_6_42.py +2 -2
- pygpt_net/provider/core/model/patch.py +49 -1
- pygpt_net/tools/image_viewer/tool.py +334 -34
- pygpt_net/tools/image_viewer/ui/dialogs.py +317 -21
- pygpt_net/ui/dialog/assistant.py +1 -1
- pygpt_net/ui/dialog/plugins.py +13 -5
- pygpt_net/ui/dialog/remote_store.py +552 -0
- pygpt_net/ui/dialogs.py +3 -5
- pygpt_net/ui/layout/ctx/ctx_list.py +58 -7
- pygpt_net/ui/menu/tools.py +6 -13
- pygpt_net/ui/widget/dialog/{remote_store_google.py → remote_store.py} +10 -10
- pygpt_net/ui/widget/element/button.py +4 -4
- pygpt_net/ui/widget/image/display.py +2 -2
- pygpt_net/ui/widget/lists/context.py +2 -2
- {pygpt_net-2.7.7.dist-info → pygpt_net-2.7.9.dist-info}/METADATA +14 -2
- {pygpt_net-2.7.7.dist-info → pygpt_net-2.7.9.dist-info}/RECORD +87 -75
- pygpt_net/controller/remote_store/google/store.py +0 -615
- pygpt_net/controller/remote_store/openai/batch.py +0 -524
- pygpt_net/controller/remote_store/openai/store.py +0 -699
- pygpt_net/ui/dialog/remote_store_google.py +0 -539
- pygpt_net/ui/dialog/remote_store_openai.py +0 -539
- pygpt_net/ui/widget/dialog/remote_store_openai.py +0 -56
- pygpt_net/ui/widget/lists/remote_store_google.py +0 -248
- pygpt_net/ui/widget/lists/remote_store_openai.py +0 -317
- {pygpt_net-2.7.7.dist-info → pygpt_net-2.7.9.dist-info}/LICENSE +0 -0
- {pygpt_net-2.7.7.dist-info → pygpt_net-2.7.9.dist-info}/WHEEL +0 -0
- {pygpt_net-2.7.7.dist-info → pygpt_net-2.7.9.dist-info}/entry_points.txt +0 -0
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# ================================================== #
|
|
4
|
-
# This file is a part of PYGPT package #
|
|
5
|
-
# Website: https://pygpt.net #
|
|
6
|
-
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
|
-
# MIT License #
|
|
8
|
-
# Created By : Marcin Szczygliński #
|
|
9
|
-
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
|
-
# ================================================== #
|
|
11
|
-
|
|
12
|
-
from typing import Optional, Any, Union
|
|
13
|
-
|
|
14
|
-
from PySide6.QtCore import QTimer
|
|
15
|
-
from PySide6.QtWidgets import QFileDialog, QApplication
|
|
16
|
-
|
|
17
|
-
from pygpt_net.utils import trans
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class Batch:
|
|
21
|
-
def __init__(self, window=None):
|
|
22
|
-
"""
|
|
23
|
-
Assistants batch controller
|
|
24
|
-
|
|
25
|
-
:param window: Window instance
|
|
26
|
-
"""
|
|
27
|
-
self.window = window
|
|
28
|
-
self.files_to_upload = []
|
|
29
|
-
|
|
30
|
-
def import_stores(self, force: bool = False):
|
|
31
|
-
"""
|
|
32
|
-
Import vector stores from API
|
|
33
|
-
|
|
34
|
-
:param force: if true, imports without confirmation
|
|
35
|
-
"""
|
|
36
|
-
if not force:
|
|
37
|
-
self.window.ui.dialogs.confirm(
|
|
38
|
-
type='remote_store.openai.import',
|
|
39
|
-
id='',
|
|
40
|
-
msg=trans('confirm.remote_store.import'),
|
|
41
|
-
)
|
|
42
|
-
return
|
|
43
|
-
# run asynchronous
|
|
44
|
-
self.window.update_status("Importing vector stores...please wait...")
|
|
45
|
-
self.window.core.remote_store.openai.truncate() # clear all stores
|
|
46
|
-
self.window.core.api.openai.assistants.importer.import_vector_stores()
|
|
47
|
-
self.window.controller.assistant.files.update()
|
|
48
|
-
self.window.controller.remote_store.openai.update()
|
|
49
|
-
|
|
50
|
-
def import_files_current(self):
|
|
51
|
-
"""Import files from API"""
|
|
52
|
-
id = self.window.core.config.get('assistant')
|
|
53
|
-
if id is None or id == "":
|
|
54
|
-
return
|
|
55
|
-
if self.window.core.assistants.has(id):
|
|
56
|
-
assistant = self.window.core.assistants.get_by_id(id)
|
|
57
|
-
store_id = assistant.vector_store
|
|
58
|
-
if store_id is None or store_id == "":
|
|
59
|
-
self.window.ui.dialogs.alert(trans("dialog.remote_store.alert.assign"))
|
|
60
|
-
return
|
|
61
|
-
self.import_store_files(store_id)
|
|
62
|
-
|
|
63
|
-
def import_files(self, force: bool = False):
|
|
64
|
-
"""
|
|
65
|
-
Sync files with API (all)
|
|
66
|
-
|
|
67
|
-
:param force: force sync files
|
|
68
|
-
"""
|
|
69
|
-
if not force:
|
|
70
|
-
self.window.ui.dialogs.confirm(
|
|
71
|
-
type='remote_store.openai.files.import.all',
|
|
72
|
-
id='',
|
|
73
|
-
msg=trans('confirm.remote_store.import_files'),
|
|
74
|
-
)
|
|
75
|
-
return
|
|
76
|
-
try:
|
|
77
|
-
self.window.controller.assistant.files.import_files() # all
|
|
78
|
-
except Exception as e:
|
|
79
|
-
self.window.core.debug.log(e)
|
|
80
|
-
self.window.ui.dialogs.alert(e)
|
|
81
|
-
|
|
82
|
-
def import_store_files(
|
|
83
|
-
self,
|
|
84
|
-
store_id: str,
|
|
85
|
-
force: bool = False
|
|
86
|
-
):
|
|
87
|
-
"""
|
|
88
|
-
Sync files with API (store)
|
|
89
|
-
|
|
90
|
-
:param store_id: vector store ID
|
|
91
|
-
:param force: force sync files
|
|
92
|
-
"""
|
|
93
|
-
if store_id is None:
|
|
94
|
-
self.window.ui.dialogs.alert(trans("dialog.remote_store.alert.select"))
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
if not force:
|
|
98
|
-
self.window.ui.dialogs.confirm(
|
|
99
|
-
type='remote_store.openai.files.import.store',
|
|
100
|
-
id=store_id,
|
|
101
|
-
msg=trans('confirm.remote_store.import_files.store'),
|
|
102
|
-
)
|
|
103
|
-
return
|
|
104
|
-
try:
|
|
105
|
-
self.window.controller.assistant.files.import_files(store_id) # by store
|
|
106
|
-
except Exception as e:
|
|
107
|
-
self.window.core.debug.log(e)
|
|
108
|
-
self.window.ui.dialogs.alert(e)
|
|
109
|
-
|
|
110
|
-
def truncate_files(self, force: bool = False):
|
|
111
|
-
"""
|
|
112
|
-
Truncate all files in API
|
|
113
|
-
|
|
114
|
-
:param force: if True, imports without confirmation
|
|
115
|
-
"""
|
|
116
|
-
if not force:
|
|
117
|
-
self.window.ui.dialogs.confirm(
|
|
118
|
-
type='remote_store.openai.files.truncate',
|
|
119
|
-
id='',
|
|
120
|
-
msg=trans('confirm.remote_store.openai.files.truncate'),
|
|
121
|
-
)
|
|
122
|
-
return
|
|
123
|
-
# run asynchronous
|
|
124
|
-
self.window.update_status("Removing files...please wait...")
|
|
125
|
-
QApplication.processEvents()
|
|
126
|
-
self.window.core.api.openai.assistants.importer.truncate_files() # remove all files from API
|
|
127
|
-
|
|
128
|
-
def truncate_store_files_by_idx(self, idx: Union[int, list], force: bool = False):
|
|
129
|
-
"""
|
|
130
|
-
Truncate all files in API (store)
|
|
131
|
-
|
|
132
|
-
:param idx: store index or list of indexes
|
|
133
|
-
:param force: if True, imports without confirmation
|
|
134
|
-
"""
|
|
135
|
-
store_ids = []
|
|
136
|
-
ids = idx if isinstance(idx, list) else [idx]
|
|
137
|
-
for i in ids:
|
|
138
|
-
store_id = self.window.controller.remote_store.openai.get_by_tab_idx(i)
|
|
139
|
-
store_ids.append(store_id)
|
|
140
|
-
self.truncate_store_files(store_ids, force)
|
|
141
|
-
|
|
142
|
-
def truncate_store_files(self, store_id: Union[str, list], force: bool = False):
|
|
143
|
-
"""
|
|
144
|
-
Truncate all files in API (store)
|
|
145
|
-
|
|
146
|
-
:param store_id: store ID
|
|
147
|
-
:param force: if True, imports without confirmation
|
|
148
|
-
"""
|
|
149
|
-
if store_id is None:
|
|
150
|
-
self.window.ui.dialogs.alert(trans("dialog.remote_store.alert.select"))
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
if not force:
|
|
154
|
-
self.window.ui.dialogs.confirm(
|
|
155
|
-
type='remote_store.openai.files.truncate.store',
|
|
156
|
-
id=store_id,
|
|
157
|
-
msg=trans('confirm.remote_store.openai.files.truncate.store'),
|
|
158
|
-
)
|
|
159
|
-
return
|
|
160
|
-
# run asynchronous
|
|
161
|
-
self.window.update_status("Removing files...please wait...")
|
|
162
|
-
QApplication.processEvents()
|
|
163
|
-
ids = store_id if isinstance(store_id, list) else [store_id]
|
|
164
|
-
for store_id in ids:
|
|
165
|
-
self.window.core.api.openai.assistants.importer.truncate_files(store_id) # remove all files from API
|
|
166
|
-
|
|
167
|
-
def clear_store_files_by_idx(
|
|
168
|
-
self,
|
|
169
|
-
idx: Union[int, list],
|
|
170
|
-
force: bool = False
|
|
171
|
-
):
|
|
172
|
-
"""
|
|
173
|
-
Clear files (store, local only)
|
|
174
|
-
|
|
175
|
-
:param idx: store index or list of indexes
|
|
176
|
-
:param force: if True, clears without confirmation
|
|
177
|
-
"""
|
|
178
|
-
store_ids = []
|
|
179
|
-
ids = idx if isinstance(idx, list) else [idx]
|
|
180
|
-
for i in ids:
|
|
181
|
-
store_id = self.window.controller.remote_store.openai.get_by_tab_idx(i)
|
|
182
|
-
store_ids.append(store_id)
|
|
183
|
-
self.clear_store_files(store_ids, force)
|
|
184
|
-
|
|
185
|
-
def clear_store_files(
|
|
186
|
-
self,
|
|
187
|
-
store_id: Optional[Union[str, list]] = None,
|
|
188
|
-
force: bool = False
|
|
189
|
-
):
|
|
190
|
-
"""
|
|
191
|
-
Clear files (store, local only)
|
|
192
|
-
|
|
193
|
-
:param store_id: store ID or list of store IDs
|
|
194
|
-
:param force: if True, clears without confirmation
|
|
195
|
-
"""
|
|
196
|
-
if store_id is None:
|
|
197
|
-
self.window.ui.dialogs.alert(trans("dialog.remote_store.alert.select"))
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
if not force:
|
|
201
|
-
self.window.ui.dialogs.confirm(
|
|
202
|
-
type='remote_store.openai.files.clear.store',
|
|
203
|
-
id=store_id,
|
|
204
|
-
msg=trans('confirm.assistant.files.clear'),
|
|
205
|
-
)
|
|
206
|
-
return
|
|
207
|
-
self.window.update_status("Clearing store files...please wait...")
|
|
208
|
-
QApplication.processEvents()
|
|
209
|
-
|
|
210
|
-
ids = store_id if isinstance(store_id, list) else [store_id]
|
|
211
|
-
for store_id in ids:
|
|
212
|
-
self.window.core.remote_store.openai.files.truncate_local(store_id) # clear files local
|
|
213
|
-
|
|
214
|
-
self.window.controller.assistant.files.update()
|
|
215
|
-
self.window.update_status("OK. All store files cleared.")
|
|
216
|
-
self.window.ui.dialogs.alert(trans("status.finished"))
|
|
217
|
-
|
|
218
|
-
def clear_files(self, force: bool = False):
|
|
219
|
-
"""
|
|
220
|
-
Clear files (all, local only)
|
|
221
|
-
|
|
222
|
-
:param force: if True, clears without confirmation
|
|
223
|
-
"""
|
|
224
|
-
if not force:
|
|
225
|
-
self.window.ui.dialogs.confirm(
|
|
226
|
-
type='remote_store.openai.files.clear.all',
|
|
227
|
-
id='',
|
|
228
|
-
msg=trans('confirm.assistant.files.clear'),
|
|
229
|
-
)
|
|
230
|
-
return
|
|
231
|
-
self.window.update_status("Clearing files...please wait...")
|
|
232
|
-
QApplication.processEvents()
|
|
233
|
-
self.window.core.remote_store.openai.files.truncate_local() # clear files local
|
|
234
|
-
self.window.controller.assistant.files.update()
|
|
235
|
-
self.window.update_status("OK. All files cleared.")
|
|
236
|
-
self.window.ui.dialogs.alert(trans("status.finished"))
|
|
237
|
-
|
|
238
|
-
def clear_stores(self, force: bool = False):
|
|
239
|
-
"""
|
|
240
|
-
Clear vector stores (local only)
|
|
241
|
-
|
|
242
|
-
:param force: if True, clears without confirmation
|
|
243
|
-
"""
|
|
244
|
-
if not force:
|
|
245
|
-
self.window.ui.dialogs.confirm(
|
|
246
|
-
type='remote_store.openai.clear',
|
|
247
|
-
id='',
|
|
248
|
-
msg=trans('confirm.remote_store.clear'),
|
|
249
|
-
)
|
|
250
|
-
return
|
|
251
|
-
self.window.update_status("Clearing vector stores...please wait...")
|
|
252
|
-
QApplication.processEvents()
|
|
253
|
-
self.window.core.remote_store.openai.truncate() # clear all stores
|
|
254
|
-
self.window.controller.assistant.files.update()
|
|
255
|
-
self.window.controller.remote_store.openai.update()
|
|
256
|
-
self.window.update_status("OK. All stores cleared.")
|
|
257
|
-
self.window.controller.remote_store.openai.current = None
|
|
258
|
-
self.window.controller.remote_store.openai.init()
|
|
259
|
-
|
|
260
|
-
def truncate_stores(self, force: bool = False):
|
|
261
|
-
"""
|
|
262
|
-
Truncate vector stores in API
|
|
263
|
-
|
|
264
|
-
:param force: if True, truncates without confirmation
|
|
265
|
-
"""
|
|
266
|
-
if not force:
|
|
267
|
-
self.window.ui.dialogs.confirm(
|
|
268
|
-
type='remote_store.openai.truncate',
|
|
269
|
-
id='',
|
|
270
|
-
msg=trans('confirm.remote_store.truncate'),
|
|
271
|
-
)
|
|
272
|
-
return
|
|
273
|
-
# run asynchronous
|
|
274
|
-
self.window.update_status("Removing vector stores...please wait...")
|
|
275
|
-
QApplication.processEvents()
|
|
276
|
-
self.window.core.remote_store.openai.truncate() # clear all stores
|
|
277
|
-
self.window.core.api.openai.assistants.importer.truncate_vector_stores()
|
|
278
|
-
self.window.controller.assistant.files.update()
|
|
279
|
-
self.window.controller.remote_store.openai.update()
|
|
280
|
-
self.window.controller.remote_store.openai.current = None
|
|
281
|
-
self.window.controller.remote_store.openai.init()
|
|
282
|
-
|
|
283
|
-
def refresh_stores(self, force: bool = False):
|
|
284
|
-
"""
|
|
285
|
-
Refresh all vector stores
|
|
286
|
-
|
|
287
|
-
:param force: if True, refresh without confirmation
|
|
288
|
-
"""
|
|
289
|
-
if not force:
|
|
290
|
-
self.window.ui.dialogs.confirm(
|
|
291
|
-
type='remote_store.openai.refresh',
|
|
292
|
-
id='',
|
|
293
|
-
msg=trans('confirm.remote_store.refresh'),
|
|
294
|
-
)
|
|
295
|
-
return
|
|
296
|
-
self.window.update_status("Refreshing vector stores...please wait...")
|
|
297
|
-
QApplication.processEvents()
|
|
298
|
-
self.window.core.api.openai.assistants.importer.refresh_vector_stores()
|
|
299
|
-
|
|
300
|
-
def handle_refreshed_stores(self, num: int):
|
|
301
|
-
"""
|
|
302
|
-
Handle refreshed stores
|
|
303
|
-
|
|
304
|
-
:param num: number of refreshed files
|
|
305
|
-
"""
|
|
306
|
-
self.window.controller.remote_store.openai.update_current()
|
|
307
|
-
self.window.controller.remote_store.openai.update()
|
|
308
|
-
self.window.ui.dialogs.alert(trans("status.finished"))
|
|
309
|
-
self.window.update_status("OK. All stores refreshed.")
|
|
310
|
-
|
|
311
|
-
def handle_refreshed_stores_failed(self, error: Any):
|
|
312
|
-
"""
|
|
313
|
-
Handle error on refreshing stores
|
|
314
|
-
|
|
315
|
-
:param error: error message
|
|
316
|
-
"""
|
|
317
|
-
self.window.core.debug.log(error)
|
|
318
|
-
print("Error refreshing stores", error)
|
|
319
|
-
self.window.controller.assistant.files.update()
|
|
320
|
-
self.window.controller.remote_store.openai.update()
|
|
321
|
-
self.window.update_status("Error refreshing stores.")
|
|
322
|
-
self.window.ui.dialogs.alert(error)
|
|
323
|
-
|
|
324
|
-
def handle_imported_stores(self, num: int):
|
|
325
|
-
"""
|
|
326
|
-
Handle imported stores
|
|
327
|
-
|
|
328
|
-
:param num: number of imported files
|
|
329
|
-
"""
|
|
330
|
-
self.window.controller.assistant.files.update()
|
|
331
|
-
self.window.controller.remote_store.openai.update()
|
|
332
|
-
self.window.update_status("OK. Imported stores: " + str(num) + ".")
|
|
333
|
-
# alert on files import after stores
|
|
334
|
-
# self.window.ui.dialogs.alert(trans("status.finished"))
|
|
335
|
-
|
|
336
|
-
def handle_imported_stores_failed(self, error: Any):
|
|
337
|
-
"""
|
|
338
|
-
Handle error on importing stores
|
|
339
|
-
|
|
340
|
-
:param error: error message
|
|
341
|
-
"""
|
|
342
|
-
self.window.core.debug.log(error)
|
|
343
|
-
self.window.controller.assistant.files.update()
|
|
344
|
-
self.window.controller.remote_store.openai.update()
|
|
345
|
-
print("Error importing stores", error)
|
|
346
|
-
self.window.update_status("Error importing stores.")
|
|
347
|
-
self.window.ui.dialogs.alert(error)
|
|
348
|
-
|
|
349
|
-
def handle_truncated_stores(self, num: int):
|
|
350
|
-
"""
|
|
351
|
-
Handle truncated stores
|
|
352
|
-
|
|
353
|
-
:param num: number of removed files
|
|
354
|
-
"""
|
|
355
|
-
self.window.core.remote_store.openai.truncate()
|
|
356
|
-
self.window.controller.assistant.batch.remove_all_stores_from_assistants()
|
|
357
|
-
self.window.controller.assistant.files.update()
|
|
358
|
-
self.window.controller.remote_store.openai.update()
|
|
359
|
-
self.window.controller.remote_store.openai.current = None
|
|
360
|
-
self.window.controller.remote_store.openai.init()
|
|
361
|
-
self.window.update_status("OK. Removed stores: " + str(num) + ".")
|
|
362
|
-
self.window.ui.dialogs.alert(trans("status.finished"))
|
|
363
|
-
|
|
364
|
-
def handle_truncated_stores_failed(self, error: Any):
|
|
365
|
-
"""
|
|
366
|
-
Handle error on truncating stores
|
|
367
|
-
|
|
368
|
-
:param error: error message
|
|
369
|
-
"""
|
|
370
|
-
self.window.core.debug.log(error)
|
|
371
|
-
print("Error removing stores", error)
|
|
372
|
-
self.window.controller.assistant.files.update()
|
|
373
|
-
self.window.controller.remote_store.openai.update()
|
|
374
|
-
self.window.update_status("Error removing stores.")
|
|
375
|
-
self.window.ui.dialogs.alert(error)
|
|
376
|
-
|
|
377
|
-
def handle_imported_files(self, num: int):
|
|
378
|
-
"""
|
|
379
|
-
Handle imported files
|
|
380
|
-
|
|
381
|
-
:param num: number of imported files
|
|
382
|
-
"""
|
|
383
|
-
self.window.controller.assistant.files.update()
|
|
384
|
-
self.window.update_status("OK. Imported files: " + str(num) + ".")
|
|
385
|
-
self.window.ui.dialogs.alert(trans("status.finished"))
|
|
386
|
-
|
|
387
|
-
def handle_imported_files_failed(self, error: Any):
|
|
388
|
-
"""
|
|
389
|
-
Handle error on importing files
|
|
390
|
-
|
|
391
|
-
:param error: error message
|
|
392
|
-
"""
|
|
393
|
-
self.window.core.debug.log(error)
|
|
394
|
-
self.window.controller.assistant.files.update()
|
|
395
|
-
print("Error importing files")
|
|
396
|
-
self.window.update_status("Error importing files.")
|
|
397
|
-
self.window.ui.dialogs.alert(error)
|
|
398
|
-
|
|
399
|
-
def handle_truncated_files(
|
|
400
|
-
self,
|
|
401
|
-
store_id: Optional[str] = None,
|
|
402
|
-
num: int = 0
|
|
403
|
-
):
|
|
404
|
-
"""
|
|
405
|
-
Handle truncated (in API) files
|
|
406
|
-
|
|
407
|
-
:param store_id: vector store ID
|
|
408
|
-
:param num: number of truncated files
|
|
409
|
-
"""
|
|
410
|
-
self.window.update_status("OK. Truncated files: " + str(num) + ".")
|
|
411
|
-
if store_id is not None:
|
|
412
|
-
self.window.controller.remote_store.openai.refresh_by_store_id(store_id)
|
|
413
|
-
self.window.controller.assistant.files.update()
|
|
414
|
-
self.window.ui.dialogs.alert(trans("status.finished"))
|
|
415
|
-
|
|
416
|
-
def handle_truncated_files_failed(self, error: Any):
|
|
417
|
-
"""
|
|
418
|
-
Handle error on truncated files
|
|
419
|
-
|
|
420
|
-
:param error: error message
|
|
421
|
-
"""
|
|
422
|
-
self.window.core.debug.log(error)
|
|
423
|
-
print("Error truncating files")
|
|
424
|
-
self.window.controller.assistant.files.update()
|
|
425
|
-
self.window.update_status("Error truncating files.")
|
|
426
|
-
self.window.ui.dialogs.alert(error)
|
|
427
|
-
|
|
428
|
-
def open_upload_files(self):
|
|
429
|
-
"""Open upload files dialog"""
|
|
430
|
-
if self.window.controller.remote_store.openai.current is None:
|
|
431
|
-
self.window.ui.dialogs.alert("Please select vector store first.")
|
|
432
|
-
return
|
|
433
|
-
|
|
434
|
-
options = QFileDialog.Options()
|
|
435
|
-
files, _ = QFileDialog.getOpenFileNames(
|
|
436
|
-
self.window,
|
|
437
|
-
"Select file(s)...",
|
|
438
|
-
"",
|
|
439
|
-
"All Files (*)",
|
|
440
|
-
options=options
|
|
441
|
-
)
|
|
442
|
-
if files:
|
|
443
|
-
self.files_to_upload = files
|
|
444
|
-
|
|
445
|
-
if self.files_to_upload:
|
|
446
|
-
msg = "Are you sure you want to upload {} file(s)?".format(len(self.files_to_upload))
|
|
447
|
-
self.window.ui.dialogs.confirm(
|
|
448
|
-
type="remote_store.openai.files.upload",
|
|
449
|
-
id=0,
|
|
450
|
-
msg=msg,
|
|
451
|
-
)
|
|
452
|
-
|
|
453
|
-
def open_upload_dir(self):
|
|
454
|
-
"""Open upload files dialog"""
|
|
455
|
-
if self.window.controller.remote_store.openai.current is None:
|
|
456
|
-
self.window.ui.dialogs.alert("Please select vector store first.")
|
|
457
|
-
return
|
|
458
|
-
|
|
459
|
-
options = QFileDialog.Options()
|
|
460
|
-
directory = QFileDialog.getExistingDirectory(
|
|
461
|
-
self.window,
|
|
462
|
-
"Select directory...",
|
|
463
|
-
options=options
|
|
464
|
-
)
|
|
465
|
-
if directory:
|
|
466
|
-
self.files_to_upload = self.window.core.filesystem.get_files_from_dir(directory)
|
|
467
|
-
|
|
468
|
-
if self.files_to_upload:
|
|
469
|
-
msg = ("Are you sure you want to upload {} file(s) from directory {}?".
|
|
470
|
-
format(len(self.files_to_upload), directory))
|
|
471
|
-
self.window.ui.dialogs.confirm(
|
|
472
|
-
type="remote_store.openai.files.upload",
|
|
473
|
-
id=0,
|
|
474
|
-
msg=msg,
|
|
475
|
-
)
|
|
476
|
-
|
|
477
|
-
def refresh_delayed(self, ms: int = 1000):
|
|
478
|
-
"""
|
|
479
|
-
Refresh UI after delay
|
|
480
|
-
|
|
481
|
-
:param ms: milliseconds to wait
|
|
482
|
-
"""
|
|
483
|
-
self.window.update_status("Refreshing status...")
|
|
484
|
-
QTimer.singleShot(ms, lambda: self.window.controller.remote_store.openai.refresh_status())
|
|
485
|
-
|
|
486
|
-
def upload(self, force: bool = False):
|
|
487
|
-
"""
|
|
488
|
-
Upload files to vector store
|
|
489
|
-
|
|
490
|
-
:param force: if true, uploads without confirmation
|
|
491
|
-
"""
|
|
492
|
-
if self.window.controller.remote_store.openai.current is None:
|
|
493
|
-
self.window.ui.dialogs.alert(trans("dialog.remote_store.alert.select"))
|
|
494
|
-
return
|
|
495
|
-
|
|
496
|
-
store_id = self.window.controller.remote_store.openai.current
|
|
497
|
-
self.window.update_status("Uploading files...please wait...")
|
|
498
|
-
QApplication.processEvents()
|
|
499
|
-
self.window.core.api.openai.assistants.importer.upload_files(store_id, self.files_to_upload)
|
|
500
|
-
self.files_to_upload = [] # clear files
|
|
501
|
-
|
|
502
|
-
def handle_uploaded_files(self, num: int):
|
|
503
|
-
"""
|
|
504
|
-
Handle uploaded files
|
|
505
|
-
|
|
506
|
-
:param num: number of uploaded files
|
|
507
|
-
"""
|
|
508
|
-
self.window.controller.assistant.files.update()
|
|
509
|
-
self.window.update_status("OK. Uploaded files: " + str(num) + ".")
|
|
510
|
-
self.window.ui.dialogs.alert("OK. Uploaded files: " + str(num) + ".")
|
|
511
|
-
self.refresh_delayed(1500)
|
|
512
|
-
|
|
513
|
-
def handle_uploaded_files_failed(self, error: Any):
|
|
514
|
-
"""
|
|
515
|
-
Handle error on uploading files
|
|
516
|
-
|
|
517
|
-
:param error: error message
|
|
518
|
-
"""
|
|
519
|
-
self.window.core.debug.log(error)
|
|
520
|
-
print("Error uploading files")
|
|
521
|
-
self.window.controller.assistant.files.update()
|
|
522
|
-
self.refresh_delayed(1500)
|
|
523
|
-
self.window.update_status("Error uploading files.")
|
|
524
|
-
self.window.ui.dialogs.alert(error)
|