pygpt-net 2.7.3__py3-none-any.whl → 2.7.5__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 +15 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +382 -350
- pygpt_net/app_core.py +4 -2
- pygpt_net/controller/__init__.py +5 -1
- pygpt_net/controller/assistant/assistant.py +1 -4
- pygpt_net/controller/assistant/batch.py +5 -504
- pygpt_net/controller/assistant/editor.py +5 -5
- pygpt_net/controller/assistant/files.py +16 -16
- pygpt_net/controller/chat/attachment.py +5 -1
- pygpt_net/controller/chat/handler/google_stream.py +307 -1
- pygpt_net/controller/chat/handler/worker.py +8 -1
- pygpt_net/controller/chat/image.py +15 -3
- pygpt_net/controller/dialogs/confirm.py +73 -101
- pygpt_net/controller/files/files.py +3 -1
- pygpt_net/controller/lang/mapping.py +9 -9
- pygpt_net/controller/layout/layout.py +2 -2
- pygpt_net/controller/painter/capture.py +50 -1
- pygpt_net/controller/presets/presets.py +2 -1
- pygpt_net/controller/remote_store/__init__.py +12 -0
- pygpt_net/{provider/core/assistant_file/db_sqlite → controller/remote_store/google}/__init__.py +2 -2
- pygpt_net/controller/remote_store/google/batch.py +402 -0
- pygpt_net/controller/remote_store/google/store.py +615 -0
- pygpt_net/controller/remote_store/openai/__init__.py +12 -0
- pygpt_net/controller/remote_store/openai/batch.py +524 -0
- pygpt_net/controller/{assistant → remote_store/openai}/store.py +63 -60
- pygpt_net/controller/remote_store/remote_store.py +35 -0
- pygpt_net/controller/theme/nodes.py +2 -1
- pygpt_net/controller/ui/mode.py +5 -1
- pygpt_net/controller/ui/ui.py +36 -2
- pygpt_net/core/assistants/assistants.py +3 -15
- pygpt_net/core/db/database.py +5 -3
- pygpt_net/core/filesystem/url.py +4 -1
- pygpt_net/core/locale/placeholder.py +35 -0
- pygpt_net/core/remote_store/__init__.py +12 -0
- pygpt_net/core/remote_store/google/__init__.py +11 -0
- pygpt_net/core/remote_store/google/files.py +224 -0
- pygpt_net/core/remote_store/google/store.py +248 -0
- pygpt_net/core/remote_store/openai/__init__.py +11 -0
- pygpt_net/core/{assistants → remote_store/openai}/files.py +26 -19
- pygpt_net/core/{assistants → remote_store/openai}/store.py +32 -15
- pygpt_net/core/remote_store/remote_store.py +24 -0
- pygpt_net/core/render/web/helpers.py +5 -0
- pygpt_net/data/config/config.json +8 -5
- pygpt_net/data/config/models.json +77 -3
- pygpt_net/data/config/settings.json +45 -14
- pygpt_net/data/css/web-blocks.css +3 -0
- pygpt_net/data/css/web-chatgpt.css +3 -0
- pygpt_net/data/locale/locale.de.ini +43 -41
- pygpt_net/data/locale/locale.en.ini +56 -44
- pygpt_net/data/locale/locale.es.ini +43 -41
- pygpt_net/data/locale/locale.fr.ini +43 -41
- pygpt_net/data/locale/locale.it.ini +43 -41
- pygpt_net/data/locale/locale.pl.ini +43 -41
- pygpt_net/data/locale/locale.uk.ini +43 -41
- pygpt_net/data/locale/locale.zh.ini +43 -41
- pygpt_net/data/locale/plugin.cmd_history.de.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_history.en.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_history.es.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_history.fr.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_history.it.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_history.pl.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_history.uk.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_history.zh.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_mouse_control.en.ini +14 -0
- pygpt_net/data/locale/plugin.cmd_web.de.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_web.en.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_web.es.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_web.fr.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_web.it.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_web.pl.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_web.uk.ini +1 -1
- pygpt_net/data/locale/plugin.cmd_web.zh.ini +1 -1
- pygpt_net/data/locale/plugin.idx_llama_index.de.ini +2 -2
- pygpt_net/data/locale/plugin.idx_llama_index.en.ini +2 -2
- pygpt_net/data/locale/plugin.idx_llama_index.es.ini +2 -2
- pygpt_net/data/locale/plugin.idx_llama_index.fr.ini +2 -2
- pygpt_net/data/locale/plugin.idx_llama_index.it.ini +2 -2
- pygpt_net/data/locale/plugin.idx_llama_index.pl.ini +2 -2
- pygpt_net/data/locale/plugin.idx_llama_index.uk.ini +2 -2
- pygpt_net/data/locale/plugin.idx_llama_index.zh.ini +2 -2
- pygpt_net/item/assistant.py +1 -211
- pygpt_net/item/ctx.py +3 -1
- pygpt_net/item/store.py +238 -0
- pygpt_net/launcher.py +115 -55
- pygpt_net/migrations/Version20260102190000.py +35 -0
- pygpt_net/migrations/__init__.py +3 -1
- pygpt_net/plugin/cmd_mouse_control/config.py +470 -1
- pygpt_net/plugin/cmd_mouse_control/plugin.py +488 -22
- pygpt_net/plugin/cmd_mouse_control/worker.py +464 -87
- pygpt_net/plugin/cmd_mouse_control/worker_sandbox.py +729 -0
- pygpt_net/plugin/idx_llama_index/config.py +2 -2
- pygpt_net/preload.py +243 -0
- pygpt_net/provider/api/google/__init__.py +16 -54
- pygpt_net/provider/api/google/chat.py +546 -129
- pygpt_net/provider/api/google/computer.py +190 -0
- pygpt_net/provider/api/google/image.py +74 -6
- pygpt_net/provider/api/google/realtime/realtime.py +2 -2
- pygpt_net/provider/api/google/remote_tools.py +93 -0
- pygpt_net/provider/api/google/store.py +546 -0
- pygpt_net/provider/api/google/video.py +9 -4
- pygpt_net/provider/api/google/worker/__init__.py +0 -0
- pygpt_net/provider/api/google/worker/importer.py +392 -0
- pygpt_net/provider/api/openai/computer.py +10 -1
- pygpt_net/provider/api/openai/image.py +42 -19
- pygpt_net/provider/api/openai/store.py +6 -6
- pygpt_net/provider/api/openai/video.py +27 -2
- pygpt_net/provider/api/openai/worker/importer.py +24 -24
- pygpt_net/provider/api/x_ai/image.py +25 -2
- pygpt_net/provider/core/config/patch.py +23 -1
- pygpt_net/provider/core/config/patches/patch_before_2_6_42.py +3 -3
- pygpt_net/provider/core/model/patch.py +17 -3
- pygpt_net/provider/core/preset/json_file.py +13 -7
- pygpt_net/provider/core/{assistant_file → remote_file}/__init__.py +1 -1
- pygpt_net/provider/core/{assistant_file → remote_file}/base.py +9 -9
- pygpt_net/provider/core/remote_file/db_sqlite/__init__.py +12 -0
- pygpt_net/provider/core/{assistant_file → remote_file}/db_sqlite/patch.py +1 -1
- pygpt_net/provider/core/{assistant_file → remote_file}/db_sqlite/provider.py +23 -20
- pygpt_net/provider/core/{assistant_file → remote_file}/db_sqlite/storage.py +35 -27
- pygpt_net/provider/core/{assistant_file → remote_file}/db_sqlite/utils.py +5 -4
- pygpt_net/provider/core/{assistant_store → remote_store}/__init__.py +1 -1
- pygpt_net/provider/core/{assistant_store → remote_store}/base.py +10 -10
- pygpt_net/provider/core/{assistant_store → remote_store}/db_sqlite/__init__.py +1 -1
- pygpt_net/provider/core/{assistant_store → remote_store}/db_sqlite/patch.py +1 -1
- pygpt_net/provider/core/{assistant_store → remote_store}/db_sqlite/provider.py +16 -15
- pygpt_net/provider/core/{assistant_store → remote_store}/db_sqlite/storage.py +30 -23
- pygpt_net/provider/core/{assistant_store → remote_store}/db_sqlite/utils.py +5 -4
- pygpt_net/provider/core/{assistant_store → remote_store}/json_file.py +9 -9
- pygpt_net/provider/llms/google.py +2 -2
- pygpt_net/ui/base/config_dialog.py +3 -2
- pygpt_net/ui/dialog/assistant.py +3 -3
- pygpt_net/ui/dialog/plugins.py +3 -1
- pygpt_net/ui/dialog/remote_store_google.py +539 -0
- pygpt_net/ui/dialog/{assistant_store.py → remote_store_openai.py} +95 -95
- pygpt_net/ui/dialogs.py +5 -3
- pygpt_net/ui/layout/chat/attachments_uploaded.py +3 -3
- pygpt_net/ui/layout/chat/input.py +20 -2
- pygpt_net/ui/layout/chat/painter.py +6 -4
- pygpt_net/ui/layout/toolbox/computer_env.py +26 -8
- pygpt_net/ui/layout/toolbox/image.py +5 -5
- pygpt_net/ui/layout/toolbox/video.py +5 -4
- pygpt_net/ui/main.py +84 -3
- pygpt_net/ui/menu/tools.py +13 -5
- pygpt_net/ui/widget/dialog/base.py +3 -10
- pygpt_net/ui/widget/dialog/remote_store_google.py +56 -0
- pygpt_net/ui/widget/dialog/{assistant_store.py → remote_store_openai.py} +9 -9
- pygpt_net/ui/widget/element/button.py +4 -4
- pygpt_net/ui/widget/lists/remote_store_google.py +248 -0
- pygpt_net/ui/widget/lists/{assistant_store.py → remote_store_openai.py} +21 -21
- pygpt_net/ui/widget/option/checkbox_list.py +47 -9
- pygpt_net/ui/widget/option/combo.py +158 -4
- pygpt_net/ui/widget/textarea/input_extra.py +664 -0
- {pygpt_net-2.7.3.dist-info → pygpt_net-2.7.5.dist-info}/METADATA +48 -9
- {pygpt_net-2.7.3.dist-info → pygpt_net-2.7.5.dist-info}/RECORD +157 -130
- {pygpt_net-2.7.3.dist-info → pygpt_net-2.7.5.dist-info}/LICENSE +0 -0
- {pygpt_net-2.7.3.dist-info → pygpt_net-2.7.5.dist-info}/WHEEL +0 -0
- {pygpt_net-2.7.3.dist-info → pygpt_net-2.7.5.dist-info}/entry_points.txt +0 -0
|
@@ -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:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
import time
|
|
@@ -14,7 +14,7 @@ from typing import Dict
|
|
|
14
14
|
|
|
15
15
|
from sqlalchemy import text
|
|
16
16
|
|
|
17
|
-
from pygpt_net.item.
|
|
17
|
+
from pygpt_net.item.store import RemoteFileItem
|
|
18
18
|
from .utils import pack_item_value, unpack_file
|
|
19
19
|
|
|
20
20
|
|
|
@@ -35,36 +35,37 @@ class Storage:
|
|
|
35
35
|
"""
|
|
36
36
|
self.window = window
|
|
37
37
|
|
|
38
|
-
def get_all(self) -> Dict[str,
|
|
38
|
+
def get_all(self, provider: str) -> Dict[str, RemoteFileItem]:
|
|
39
39
|
"""
|
|
40
|
-
Return dict with
|
|
40
|
+
Return dict with RemoteFileItem objects, indexed by ID
|
|
41
41
|
|
|
42
|
-
:
|
|
42
|
+
:param provider: provider ID
|
|
43
|
+
:return: dict of RemoteFileItem objects
|
|
43
44
|
"""
|
|
44
45
|
stmt = text("""
|
|
45
|
-
SELECT * FROM remote_file
|
|
46
|
-
""")
|
|
46
|
+
SELECT * FROM remote_file WHERE provider = :provider
|
|
47
|
+
""").bindparams(provider=provider)
|
|
47
48
|
items = {}
|
|
48
49
|
db = self.window.core.db.get_db()
|
|
49
50
|
with db.connect() as conn:
|
|
50
51
|
result = conn.execute(stmt)
|
|
51
52
|
for row in result:
|
|
52
|
-
file =
|
|
53
|
+
file = RemoteFileItem()
|
|
53
54
|
unpack_file(file, row._asdict())
|
|
54
55
|
items[file.id] = file # index by ID
|
|
55
56
|
return items
|
|
56
57
|
|
|
57
|
-
def get_by_id(self, id: int) ->
|
|
58
|
+
def get_by_id(self, id: int) -> RemoteFileItem:
|
|
58
59
|
"""
|
|
59
|
-
Return
|
|
60
|
+
Return RemoteFileItem by ID
|
|
60
61
|
|
|
61
62
|
:param id: file item ID
|
|
62
|
-
:return:
|
|
63
|
+
:return: RemoteFileItem
|
|
63
64
|
"""
|
|
64
65
|
stmt = text("""
|
|
65
66
|
SELECT * FROM remote_file WHERE id = :id LIMIT 1
|
|
66
67
|
""").bindparams(idx=id)
|
|
67
|
-
file =
|
|
68
|
+
file = RemoteFileItem()
|
|
68
69
|
db = self.window.core.db.get_db()
|
|
69
70
|
with db.connect() as conn:
|
|
70
71
|
result = conn.execute(stmt)
|
|
@@ -74,9 +75,9 @@ class Storage:
|
|
|
74
75
|
|
|
75
76
|
def get_by_store_or_thread(self, store_id: str, thread_id: str) -> dict:
|
|
76
77
|
"""
|
|
77
|
-
Return dict with
|
|
78
|
+
Return dict with RemoteFileItem objects, indexed by ID
|
|
78
79
|
|
|
79
|
-
:return: dict of
|
|
80
|
+
:return: dict of RemoteFileItem objects
|
|
80
81
|
"""
|
|
81
82
|
if (store_id is None or store_id == "") and (thread_id is None or thread_id == ""):
|
|
82
83
|
return {}
|
|
@@ -105,14 +106,14 @@ class Storage:
|
|
|
105
106
|
with db.connect() as conn:
|
|
106
107
|
result = conn.execute(stmt)
|
|
107
108
|
for row in result:
|
|
108
|
-
file =
|
|
109
|
+
file = RemoteFileItem()
|
|
109
110
|
unpack_file(file, row._asdict())
|
|
110
111
|
items[file.id] = file # index by record ID
|
|
111
112
|
return items
|
|
112
113
|
|
|
113
114
|
def count_by_store_or_thread(self, store_id: str, thread_id: str) -> int:
|
|
114
115
|
"""
|
|
115
|
-
Count
|
|
116
|
+
Count RemoteFileItem objects
|
|
116
117
|
|
|
117
118
|
:return: num of files
|
|
118
119
|
"""
|
|
@@ -161,21 +162,22 @@ class Storage:
|
|
|
161
162
|
with db.connect() as conn:
|
|
162
163
|
result = conn.execute(stmt)
|
|
163
164
|
for row in result:
|
|
164
|
-
file =
|
|
165
|
+
file = RemoteFileItem()
|
|
165
166
|
unpack_file(file, row._asdict())
|
|
166
167
|
items[file.id] = file
|
|
167
168
|
return items
|
|
168
169
|
|
|
169
|
-
def truncate_all(self) -> bool:
|
|
170
|
+
def truncate_all(self, provider: str) -> bool:
|
|
170
171
|
"""
|
|
171
172
|
Truncate all files items
|
|
172
173
|
|
|
174
|
+
:param provider: provider ID
|
|
173
175
|
:return: True if truncated
|
|
174
176
|
"""
|
|
175
177
|
db = self.window.core.db.get_db()
|
|
176
178
|
with db.begin() as conn:
|
|
177
|
-
conn.execute(text("DELETE FROM remote_file"))
|
|
178
|
-
conn.execute(text("DELETE FROM sqlite_sequence WHERE name='remote_file'"))
|
|
179
|
+
conn.execute(text("DELETE FROM remote_file WHERE provider = :provider").bindparams(provider=provider))
|
|
180
|
+
# conn.execute(text("DELETE FROM sqlite_sequence WHERE name='remote_file'"))
|
|
179
181
|
return True
|
|
180
182
|
|
|
181
183
|
def truncate_by_store(self, store_id: str) -> bool:
|
|
@@ -238,15 +240,16 @@ class Storage:
|
|
|
238
240
|
conn.execute(stmt)
|
|
239
241
|
return True
|
|
240
242
|
|
|
241
|
-
def clear_all_stores_from_files(self) -> bool:
|
|
243
|
+
def clear_all_stores_from_files(self, provider: str) -> bool:
|
|
242
244
|
"""
|
|
243
245
|
Clear all stores from files
|
|
244
246
|
|
|
247
|
+
:param provider: provider ID
|
|
245
248
|
:return: True if cleared
|
|
246
249
|
"""
|
|
247
250
|
stmt = text("""
|
|
248
|
-
DELETE FROM remote_file WHERE store_id IS NOT NULL
|
|
249
|
-
""")
|
|
251
|
+
DELETE FROM remote_file WHERE store_id IS NOT NULL AND provider = :provider
|
|
252
|
+
""").bindparams(provider=provider)
|
|
250
253
|
db = self.window.core.db.get_db()
|
|
251
254
|
with db.begin() as conn:
|
|
252
255
|
conn.execute(stmt)
|
|
@@ -271,11 +274,11 @@ class Storage:
|
|
|
271
274
|
conn.execute(stmt)
|
|
272
275
|
return True
|
|
273
276
|
|
|
274
|
-
def save(self, file:
|
|
277
|
+
def save(self, file: RemoteFileItem):
|
|
275
278
|
"""
|
|
276
279
|
Insert or update file item
|
|
277
280
|
|
|
278
|
-
:param file:
|
|
281
|
+
:param file: RemoteFileItem object
|
|
279
282
|
"""
|
|
280
283
|
db = self.window.core.db.get_db()
|
|
281
284
|
with db.begin() as conn:
|
|
@@ -284,6 +287,7 @@ class Storage:
|
|
|
284
287
|
UPDATE remote_file
|
|
285
288
|
SET
|
|
286
289
|
name = :name,
|
|
290
|
+
provider = :provider,
|
|
287
291
|
path = :path,
|
|
288
292
|
file_id = :file_id,
|
|
289
293
|
store_id = :store_id,
|
|
@@ -293,6 +297,7 @@ class Storage:
|
|
|
293
297
|
""").bindparams(
|
|
294
298
|
id=file.record_id,
|
|
295
299
|
name=file.name,
|
|
300
|
+
provider=file.provider,
|
|
296
301
|
path=file.path,
|
|
297
302
|
file_id=file.file_id,
|
|
298
303
|
store_id=file.store_id,
|
|
@@ -301,11 +306,11 @@ class Storage:
|
|
|
301
306
|
)
|
|
302
307
|
conn.execute(stmt)
|
|
303
308
|
|
|
304
|
-
def insert(self, file:
|
|
309
|
+
def insert(self, file: RemoteFileItem) -> int:
|
|
305
310
|
"""
|
|
306
311
|
Insert file item
|
|
307
312
|
|
|
308
|
-
:param file:
|
|
313
|
+
:param file: RemoteFileItem object
|
|
309
314
|
:return: file item ID
|
|
310
315
|
"""
|
|
311
316
|
db = self.window.core.db.get_db()
|
|
@@ -315,6 +320,7 @@ class Storage:
|
|
|
315
320
|
(
|
|
316
321
|
uuid,
|
|
317
322
|
name,
|
|
323
|
+
provider,
|
|
318
324
|
path,
|
|
319
325
|
size,
|
|
320
326
|
file_id,
|
|
@@ -327,6 +333,7 @@ class Storage:
|
|
|
327
333
|
(
|
|
328
334
|
:uuid,
|
|
329
335
|
:name,
|
|
336
|
+
:provider,
|
|
330
337
|
:path,
|
|
331
338
|
:size,
|
|
332
339
|
:file_id,
|
|
@@ -338,6 +345,7 @@ class Storage:
|
|
|
338
345
|
""").bindparams(
|
|
339
346
|
uuid=file.uuid,
|
|
340
347
|
name=file.name,
|
|
348
|
+
provider=file.provider,
|
|
341
349
|
path=file.path,
|
|
342
350
|
size=int(file.size or 0),
|
|
343
351
|
file_id=file.file_id,
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
7
|
# MIT License #
|
|
8
8
|
# Created By : Marcin Szczygliński #
|
|
9
|
-
# Updated Date:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
import json
|
|
13
13
|
|
|
14
14
|
from pygpt_net.utils import unpack_var
|
|
15
|
-
from pygpt_net.item.
|
|
15
|
+
from pygpt_net.item.store import RemoteFileItem
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def unpack_file(file:
|
|
18
|
+
def unpack_file(file: RemoteFileItem, row: dict) -> RemoteFileItem:
|
|
19
19
|
"""
|
|
20
20
|
Unpack file item from DB row
|
|
21
21
|
|
|
22
|
-
:param file: file item (
|
|
22
|
+
:param file: file item (RemoteStoreItem)
|
|
23
23
|
:param row: DB row
|
|
24
24
|
:return: store item
|
|
25
25
|
"""
|
|
@@ -30,6 +30,7 @@ def unpack_file(file: AssistantFileItem, row: dict) -> AssistantFileItem:
|
|
|
30
30
|
file.updated = unpack_var(row['updated_ts'], "int")
|
|
31
31
|
file.size = unpack_var(row['size'], "int")
|
|
32
32
|
file.name = row['name']
|
|
33
|
+
file.provider = row['provider']
|
|
33
34
|
file.path = row['path']
|
|
34
35
|
file.file_id = row['file_id']
|
|
35
36
|
file.store_id = row['store_id']
|
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
7
|
# MIT License #
|
|
8
8
|
# Created By : Marcin Szczygliński #
|
|
9
|
-
# Updated Date:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
from typing import Dict
|
|
13
13
|
|
|
14
14
|
from packaging.version import Version
|
|
15
15
|
|
|
16
|
-
from pygpt_net.item.
|
|
16
|
+
from pygpt_net.item.store import RemoteStoreItem
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class BaseProvider:
|
|
20
20
|
def __init__(self, window=None):
|
|
21
21
|
self.window = window
|
|
22
22
|
self.id = ""
|
|
23
|
-
self.type = "
|
|
23
|
+
self.type = "remote_store"
|
|
24
24
|
|
|
25
25
|
def attach(self, window):
|
|
26
26
|
self.window = window
|
|
@@ -31,26 +31,26 @@ class BaseProvider:
|
|
|
31
31
|
def patch(self, version: Version) -> bool:
|
|
32
32
|
pass
|
|
33
33
|
|
|
34
|
-
def create(self, store:
|
|
34
|
+
def create(self, store: RemoteStoreItem) -> str:
|
|
35
35
|
pass
|
|
36
36
|
|
|
37
|
-
def load(self, id) ->
|
|
37
|
+
def load(self, id) -> RemoteStoreItem:
|
|
38
38
|
pass
|
|
39
39
|
|
|
40
|
-
def load_all(self) -> Dict[str,
|
|
40
|
+
def load_all(self, provider: str) -> Dict[str, RemoteStoreItem]:
|
|
41
41
|
pass
|
|
42
42
|
|
|
43
|
-
def save(self, file:
|
|
43
|
+
def save(self, file: RemoteStoreItem):
|
|
44
44
|
pass
|
|
45
45
|
|
|
46
|
-
def save_all(self, items: Dict[str,
|
|
46
|
+
def save_all(self, items: Dict[str, RemoteStoreItem]):
|
|
47
47
|
pass
|
|
48
48
|
|
|
49
49
|
def remove(self, id: str):
|
|
50
50
|
pass
|
|
51
51
|
|
|
52
|
-
def truncate(self):
|
|
52
|
+
def truncate(self, provider: str):
|
|
53
53
|
pass
|
|
54
54
|
|
|
55
|
-
def dump(self, store:
|
|
55
|
+
def dump(self, store: RemoteStoreItem) -> str:
|
|
56
56
|
pass
|
|
@@ -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:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
from .provider import *
|
|
@@ -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:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
from packaging.version import parse as parse_version, Version
|
|
@@ -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:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
import uuid
|
|
@@ -14,8 +14,8 @@ from typing import Dict
|
|
|
14
14
|
|
|
15
15
|
from packaging.version import Version
|
|
16
16
|
|
|
17
|
-
from pygpt_net.item.
|
|
18
|
-
from pygpt_net.provider.core.
|
|
17
|
+
from pygpt_net.item.store import RemoteStoreItem
|
|
18
|
+
from pygpt_net.provider.core.remote_store.base import BaseProvider
|
|
19
19
|
|
|
20
20
|
from .patch import Patch
|
|
21
21
|
from .storage import Storage
|
|
@@ -28,7 +28,7 @@ class DbSqliteProvider(BaseProvider):
|
|
|
28
28
|
self.patcher = Patch(window, self)
|
|
29
29
|
self.storage = Storage(window)
|
|
30
30
|
self.id = "db_sqlite"
|
|
31
|
-
self.type = "
|
|
31
|
+
self.type = "remote_store"
|
|
32
32
|
|
|
33
33
|
def attach(self, window):
|
|
34
34
|
self.window = window
|
|
@@ -51,11 +51,11 @@ class DbSqliteProvider(BaseProvider):
|
|
|
51
51
|
"""
|
|
52
52
|
return str(uuid.uuid4())
|
|
53
53
|
|
|
54
|
-
def create(self, store:
|
|
54
|
+
def create(self, store: RemoteStoreItem) -> int:
|
|
55
55
|
"""
|
|
56
56
|
Create new and return its ID
|
|
57
57
|
|
|
58
|
-
:param store:
|
|
58
|
+
:param store: RemoteStoreItem
|
|
59
59
|
:return: store ID
|
|
60
60
|
"""
|
|
61
61
|
if store.record_id is None or store.record_id == "":
|
|
@@ -63,15 +63,16 @@ class DbSqliteProvider(BaseProvider):
|
|
|
63
63
|
store.record_id = self.storage.insert(store)
|
|
64
64
|
return store.record_id
|
|
65
65
|
|
|
66
|
-
def load_all(self) -> Dict[str,
|
|
66
|
+
def load_all(self, provider: str) -> Dict[str, RemoteStoreItem]:
|
|
67
67
|
"""
|
|
68
68
|
Load stores from DB
|
|
69
69
|
|
|
70
|
+
:param provider: provider ID
|
|
70
71
|
:return: stores dict
|
|
71
72
|
"""
|
|
72
|
-
return self.storage.get_all()
|
|
73
|
+
return self.storage.get_all(provider)
|
|
73
74
|
|
|
74
|
-
def load(self, id: int) ->
|
|
75
|
+
def load(self, id: int) -> RemoteStoreItem:
|
|
75
76
|
"""
|
|
76
77
|
Load store from DB
|
|
77
78
|
|
|
@@ -80,11 +81,11 @@ class DbSqliteProvider(BaseProvider):
|
|
|
80
81
|
"""
|
|
81
82
|
return self.storage.get_by_id(id)
|
|
82
83
|
|
|
83
|
-
def save(self, store:
|
|
84
|
+
def save(self, store: RemoteStoreItem):
|
|
84
85
|
"""
|
|
85
86
|
Save store to DB
|
|
86
87
|
|
|
87
|
-
:param store:
|
|
88
|
+
:param store: RemoteStoreItem
|
|
88
89
|
"""
|
|
89
90
|
try:
|
|
90
91
|
self.storage.save(store)
|
|
@@ -92,11 +93,11 @@ class DbSqliteProvider(BaseProvider):
|
|
|
92
93
|
self.window.core.debug.log(e)
|
|
93
94
|
print("Error while saving stored: {}".format(str(e)))
|
|
94
95
|
|
|
95
|
-
def save_all(self, items: Dict[str,
|
|
96
|
+
def save_all(self, items: Dict[str, RemoteStoreItem]):
|
|
96
97
|
"""
|
|
97
98
|
Save all stores to DB
|
|
98
99
|
|
|
99
|
-
:param items: dict of
|
|
100
|
+
:param items: dict of RemoteStoreItem objects
|
|
100
101
|
"""
|
|
101
102
|
try:
|
|
102
103
|
for id in items:
|
|
@@ -124,12 +125,12 @@ class DbSqliteProvider(BaseProvider):
|
|
|
124
125
|
"""
|
|
125
126
|
return self.storage.delete_by_store_id(id)
|
|
126
127
|
|
|
127
|
-
def truncate(self) -> bool:
|
|
128
|
+
def truncate(self, provider: str) -> bool:
|
|
128
129
|
"""
|
|
129
130
|
Truncate all stores
|
|
130
131
|
|
|
131
132
|
:return: True if truncated
|
|
132
133
|
"""
|
|
133
|
-
return self.storage.truncate_all()
|
|
134
|
+
return self.storage.truncate_all(provider)
|
|
134
135
|
|
|
135
136
|
|
|
@@ -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:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
import time
|
|
@@ -14,7 +14,7 @@ from typing import Dict
|
|
|
14
14
|
|
|
15
15
|
from sqlalchemy import text
|
|
16
16
|
|
|
17
|
-
from pygpt_net.item.
|
|
17
|
+
from pygpt_net.item.store import RemoteStoreItem
|
|
18
18
|
|
|
19
19
|
from .utils import pack_item_value, unpack_store
|
|
20
20
|
|
|
@@ -35,36 +35,37 @@ class Storage:
|
|
|
35
35
|
"""
|
|
36
36
|
self.window = window
|
|
37
37
|
|
|
38
|
-
def get_all(self) -> Dict[str,
|
|
38
|
+
def get_all(self, provider: str) -> Dict[str, RemoteStoreItem]:
|
|
39
39
|
"""
|
|
40
|
-
Return dict with
|
|
40
|
+
Return dict with RemoteStoreItem objects, indexed by ID
|
|
41
41
|
|
|
42
|
-
:
|
|
42
|
+
:param provider: provider ID
|
|
43
|
+
:return: dict of RemoteStoreItem objects
|
|
43
44
|
"""
|
|
44
45
|
stmt = text("""
|
|
45
|
-
SELECT * FROM remote_store
|
|
46
|
-
""")
|
|
46
|
+
SELECT * FROM remote_store WHERE provider = :provider
|
|
47
|
+
""").bindparams(provider=provider)
|
|
47
48
|
items = {}
|
|
48
49
|
db = self.window.core.db.get_db()
|
|
49
50
|
with db.connect() as conn:
|
|
50
51
|
result = conn.execute(stmt)
|
|
51
52
|
for row in result:
|
|
52
|
-
store =
|
|
53
|
+
store = RemoteStoreItem()
|
|
53
54
|
unpack_store(store, row._asdict())
|
|
54
55
|
items[store.id] = store # index by store ID
|
|
55
56
|
return items
|
|
56
57
|
|
|
57
|
-
def get_by_id(self, id: int) ->
|
|
58
|
+
def get_by_id(self, id: int) -> RemoteStoreItem:
|
|
58
59
|
"""
|
|
59
|
-
Return
|
|
60
|
+
Return RemoteStoreItem by ID
|
|
60
61
|
|
|
61
62
|
:param id: store item ID
|
|
62
|
-
:return:
|
|
63
|
+
:return: RemoteStoreItem
|
|
63
64
|
"""
|
|
64
65
|
stmt = text("""
|
|
65
66
|
SELECT * FROM remote_store WHERE id = :id LIMIT 1
|
|
66
67
|
""").bindparams(id=id)
|
|
67
|
-
store =
|
|
68
|
+
store = RemoteStoreItem()
|
|
68
69
|
db = self.window.core.db.get_db()
|
|
69
70
|
with db.connect() as conn:
|
|
70
71
|
result = conn.execute(stmt)
|
|
@@ -72,17 +73,17 @@ class Storage:
|
|
|
72
73
|
unpack_store(store, row._asdict())
|
|
73
74
|
return store
|
|
74
75
|
|
|
75
|
-
def get_by_store_id(self, id: str) ->
|
|
76
|
+
def get_by_store_id(self, id: str) -> RemoteStoreItem:
|
|
76
77
|
"""
|
|
77
|
-
Return
|
|
78
|
+
Return RemoteStoreItem by ID
|
|
78
79
|
|
|
79
80
|
:param id: store_id
|
|
80
|
-
:return:
|
|
81
|
+
:return: RemoteStoreItem
|
|
81
82
|
"""
|
|
82
83
|
stmt = text("""
|
|
83
84
|
SELECT * FROM remote_store WHERE store_id = :id LIMIT 1
|
|
84
85
|
""").bindparams(id=id)
|
|
85
|
-
store =
|
|
86
|
+
store = RemoteStoreItem()
|
|
86
87
|
db = self.window.core.db.get_db()
|
|
87
88
|
with db.connect() as conn:
|
|
88
89
|
result = conn.execute(stmt)
|
|
@@ -90,16 +91,17 @@ class Storage:
|
|
|
90
91
|
unpack_store(store, row._asdict())
|
|
91
92
|
return store
|
|
92
93
|
|
|
93
|
-
def truncate_all(self) -> bool:
|
|
94
|
+
def truncate_all(self, provider: str) -> bool:
|
|
94
95
|
"""
|
|
95
96
|
Truncate all stores items
|
|
96
97
|
|
|
98
|
+
:param provider: provider ID
|
|
97
99
|
:return: True if truncated
|
|
98
100
|
"""
|
|
99
101
|
db = self.window.core.db.get_db()
|
|
100
102
|
with db.begin() as conn:
|
|
101
|
-
conn.execute(text("DELETE FROM remote_store"))
|
|
102
|
-
conn.execute(text("DELETE FROM sqlite_sequence WHERE name='remote_store'"))
|
|
103
|
+
conn.execute(text("DELETE FROM remote_store WHERE provider = :provider").bindparams(provider=provider))
|
|
104
|
+
# conn.execute(text("DELETE FROM sqlite_sequence WHERE name='remote_store'"))
|
|
103
105
|
return True
|
|
104
106
|
|
|
105
107
|
def delete_by_id(self, id: int) -> bool:
|
|
@@ -132,11 +134,11 @@ class Storage:
|
|
|
132
134
|
conn.execute(stmt)
|
|
133
135
|
return True
|
|
134
136
|
|
|
135
|
-
def save(self, store:
|
|
137
|
+
def save(self, store: RemoteStoreItem):
|
|
136
138
|
"""
|
|
137
139
|
Insert or update store item
|
|
138
140
|
|
|
139
|
-
:param store:
|
|
141
|
+
:param store: RemoteStoreItem object
|
|
140
142
|
"""
|
|
141
143
|
db = self.window.core.db.get_db()
|
|
142
144
|
with db.begin() as conn:
|
|
@@ -145,6 +147,7 @@ class Storage:
|
|
|
145
147
|
UPDATE remote_store
|
|
146
148
|
SET
|
|
147
149
|
name = :name,
|
|
150
|
+
provider = :provider,
|
|
148
151
|
description = :description,
|
|
149
152
|
expire_days = :expire_days,
|
|
150
153
|
usage_bytes = :usage_bytes,
|
|
@@ -160,6 +163,7 @@ class Storage:
|
|
|
160
163
|
""").bindparams(
|
|
161
164
|
id=store.record_id,
|
|
162
165
|
name=store.name,
|
|
166
|
+
provider=store.provider,
|
|
163
167
|
description=store.description,
|
|
164
168
|
expire_days=store.expire_days,
|
|
165
169
|
usage_bytes=store.usage_bytes,
|
|
@@ -174,11 +178,11 @@ class Storage:
|
|
|
174
178
|
)
|
|
175
179
|
conn.execute(stmt)
|
|
176
180
|
|
|
177
|
-
def insert(self, store:
|
|
181
|
+
def insert(self, store: RemoteStoreItem) -> int:
|
|
178
182
|
"""
|
|
179
183
|
Insert store item
|
|
180
184
|
|
|
181
|
-
:param store:
|
|
185
|
+
:param store: RemoteStoreItem object
|
|
182
186
|
:return: store item ID
|
|
183
187
|
"""
|
|
184
188
|
db = self.window.core.db.get_db()
|
|
@@ -189,6 +193,7 @@ class Storage:
|
|
|
189
193
|
store_id,
|
|
190
194
|
uuid,
|
|
191
195
|
name,
|
|
196
|
+
provider,
|
|
192
197
|
description,
|
|
193
198
|
expire_days,
|
|
194
199
|
usage_bytes,
|
|
@@ -206,6 +211,7 @@ class Storage:
|
|
|
206
211
|
:store_id,
|
|
207
212
|
:uuid,
|
|
208
213
|
:name,
|
|
214
|
+
:provider,
|
|
209
215
|
:description,
|
|
210
216
|
:expire_days,
|
|
211
217
|
:usage_bytes,
|
|
@@ -222,6 +228,7 @@ class Storage:
|
|
|
222
228
|
store_id=store.id,
|
|
223
229
|
uuid=store.uuid,
|
|
224
230
|
name=store.name,
|
|
231
|
+
provider=store.provider,
|
|
225
232
|
description=store.description,
|
|
226
233
|
expire_days=int(store.expire_days or 0),
|
|
227
234
|
usage_bytes=int(store.usage_bytes or 0),
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
|
7
7
|
# MIT License #
|
|
8
8
|
# Created By : Marcin Szczygliński #
|
|
9
|
-
# Updated Date:
|
|
9
|
+
# Updated Date: 2026.01.02 20:00:00 #
|
|
10
10
|
# ================================================== #
|
|
11
11
|
|
|
12
12
|
import json
|
|
13
13
|
|
|
14
14
|
from pygpt_net.utils import unpack_var
|
|
15
|
-
from pygpt_net.item.
|
|
15
|
+
from pygpt_net.item.store import RemoteStoreItem
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def unpack_store(store:
|
|
18
|
+
def unpack_store(store: RemoteStoreItem, row: dict) -> RemoteStoreItem:
|
|
19
19
|
"""
|
|
20
20
|
Unpack store item from DB row
|
|
21
21
|
|
|
22
|
-
:param store: store item (
|
|
22
|
+
:param store: store item (RemoteStoreItem)
|
|
23
23
|
:param row: DB row
|
|
24
24
|
:return: store item
|
|
25
25
|
"""
|
|
@@ -31,6 +31,7 @@ def unpack_store(store: AssistantStoreItem, row: dict) -> AssistantStoreItem:
|
|
|
31
31
|
store.last_active = unpack_var(row['last_active_ts'], "int")
|
|
32
32
|
store.last_sync = unpack_var(row['last_sync_ts'], "int")
|
|
33
33
|
store.name = row['name']
|
|
34
|
+
store.provider = row['provider']
|
|
34
35
|
store.description = row['description']
|
|
35
36
|
store.expire_days = unpack_var(row['expire_days'], "int")
|
|
36
37
|
store.usage_bytes = unpack_var(row['usage_bytes'], "int")
|