pygpt-net 2.4.41__py3-none-any.whl → 2.4.42__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.
- CHANGELOG.md +8 -0
- README.md +135 -70
- pygpt_net/CHANGELOG.txt +8 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +3 -1
- pygpt_net/controller/audio/__init__.py +2 -2
- pygpt_net/controller/camera.py +1 -10
- pygpt_net/controller/chat/audio.py +2 -2
- pygpt_net/controller/config/placeholder.py +15 -1
- pygpt_net/controller/ui/mode.py +16 -21
- pygpt_net/core/audio/__init__.py +4 -1
- pygpt_net/core/audio/whisper.py +37 -0
- pygpt_net/core/bridge/worker.py +2 -2
- pygpt_net/core/debug/events.py +22 -10
- pygpt_net/core/debug/tabs.py +6 -3
- pygpt_net/core/history.py +3 -2
- pygpt_net/core/idx/__init__.py +16 -4
- pygpt_net/core/idx/chat.py +15 -5
- pygpt_net/core/idx/indexing.py +24 -8
- pygpt_net/core/installer.py +2 -4
- pygpt_net/core/models.py +62 -17
- pygpt_net/core/modes.py +11 -13
- pygpt_net/core/notepad.py +4 -4
- pygpt_net/core/plugins.py +27 -16
- pygpt_net/core/presets.py +20 -9
- pygpt_net/core/profile.py +11 -3
- pygpt_net/core/render/web/parser.py +3 -1
- pygpt_net/core/settings.py +5 -5
- pygpt_net/core/tabs/tab.py +10 -2
- pygpt_net/core/tokens.py +8 -6
- pygpt_net/core/web/__init__.py +105 -0
- pygpt_net/core/{web.py → web/helpers.py} +93 -67
- pygpt_net/data/config/config.json +3 -3
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/locale/locale.en.ini +1 -0
- pygpt_net/data/locale/plugin.cmd_web.en.ini +2 -0
- pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
- pygpt_net/item/ctx.py +13 -2
- pygpt_net/plugin/agent/__init__.py +7 -2
- pygpt_net/plugin/audio_output/__init__.py +6 -1
- pygpt_net/plugin/base/plugin.py +58 -26
- pygpt_net/plugin/base/worker.py +20 -17
- pygpt_net/plugin/cmd_history/config.py +2 -2
- pygpt_net/plugin/cmd_web/__init__.py +3 -4
- pygpt_net/plugin/cmd_web/config.py +71 -3
- pygpt_net/plugin/cmd_web/websearch.py +20 -12
- pygpt_net/plugin/cmd_web/worker.py +67 -4
- pygpt_net/plugin/idx_llama_index/config.py +3 -3
- pygpt_net/plugin/mailer/__init__.py +123 -0
- pygpt_net/plugin/mailer/config.py +149 -0
- pygpt_net/plugin/mailer/runner.py +285 -0
- pygpt_net/plugin/mailer/worker.py +123 -0
- pygpt_net/provider/agents/base.py +5 -2
- pygpt_net/provider/agents/openai.py +4 -2
- pygpt_net/provider/agents/openai_assistant.py +4 -2
- pygpt_net/provider/agents/planner.py +4 -2
- pygpt_net/provider/agents/react.py +4 -2
- pygpt_net/provider/audio_output/openai_tts.py +5 -11
- pygpt_net/provider/core/assistant/base.py +5 -3
- pygpt_net/provider/core/assistant/json_file.py +8 -5
- pygpt_net/provider/core/assistant_file/base.py +4 -3
- pygpt_net/provider/core/assistant_file/db_sqlite/__init__.py +4 -3
- pygpt_net/provider/core/assistant_file/db_sqlite/storage.py +3 -2
- pygpt_net/provider/core/assistant_store/base.py +6 -4
- pygpt_net/provider/core/assistant_store/db_sqlite/__init__.py +5 -4
- pygpt_net/provider/core/assistant_store/db_sqlite/storage.py +5 -3
- pygpt_net/provider/core/attachment/base.py +5 -3
- pygpt_net/provider/core/attachment/json_file.py +4 -3
- pygpt_net/provider/core/calendar/base.py +5 -3
- pygpt_net/provider/core/calendar/db_sqlite/__init__.py +6 -5
- pygpt_net/provider/core/calendar/db_sqlite/storage.py +5 -4
- pygpt_net/provider/core/config/base.py +8 -6
- pygpt_net/provider/core/config/json_file.py +9 -7
- pygpt_net/provider/core/ctx/base.py +27 -25
- pygpt_net/provider/core/ctx/db_sqlite/__init__.py +51 -35
- pygpt_net/provider/core/ctx/db_sqlite/storage.py +42 -31
- pygpt_net/provider/core/ctx/db_sqlite/utils.py +11 -9
- pygpt_net/provider/core/index/base.py +129 -23
- pygpt_net/provider/core/index/db_sqlite/__init__.py +130 -23
- pygpt_net/provider/core/index/db_sqlite/storage.py +130 -23
- pygpt_net/provider/core/index/db_sqlite/utils.py +4 -2
- pygpt_net/provider/core/mode/base.py +5 -3
- pygpt_net/provider/core/mode/json_file.py +7 -6
- pygpt_net/provider/core/model/base.py +6 -4
- pygpt_net/provider/core/model/json_file.py +9 -7
- pygpt_net/provider/core/notepad/base.py +5 -3
- pygpt_net/provider/core/notepad/db_sqlite/__init__.py +5 -4
- pygpt_net/provider/core/notepad/db_sqlite/storage.py +4 -3
- pygpt_net/provider/core/plugin_preset/base.py +4 -2
- pygpt_net/provider/core/plugin_preset/json_file.py +5 -3
- pygpt_net/provider/core/preset/base.py +6 -4
- pygpt_net/provider/core/preset/json_file.py +9 -9
- pygpt_net/provider/core/prompt/base.py +6 -3
- pygpt_net/provider/core/prompt/json_file.py +11 -6
- pygpt_net/provider/gpt/assistants.py +15 -6
- pygpt_net/provider/gpt/audio.py +5 -5
- pygpt_net/provider/gpt/chat.py +7 -5
- pygpt_net/provider/gpt/completion.py +8 -4
- pygpt_net/provider/gpt/image.py +3 -3
- pygpt_net/provider/gpt/store.py +46 -12
- pygpt_net/provider/gpt/vision.py +16 -11
- pygpt_net/provider/llms/anthropic.py +7 -2
- pygpt_net/provider/llms/azure_openai.py +26 -5
- pygpt_net/provider/llms/base.py +47 -9
- pygpt_net/provider/llms/google.py +7 -2
- pygpt_net/provider/llms/hugging_face.py +13 -3
- pygpt_net/provider/llms/hugging_face_api.py +18 -4
- pygpt_net/provider/llms/local.py +7 -2
- pygpt_net/provider/llms/ollama.py +30 -6
- pygpt_net/provider/llms/openai.py +32 -6
- pygpt_net/provider/vector_stores/__init__.py +45 -14
- pygpt_net/provider/vector_stores/base.py +35 -8
- pygpt_net/provider/vector_stores/chroma.py +13 -3
- pygpt_net/provider/vector_stores/ctx_attachment.py +31 -12
- pygpt_net/provider/vector_stores/elasticsearch.py +12 -3
- pygpt_net/provider/vector_stores/pinecode.py +12 -3
- pygpt_net/provider/vector_stores/redis.py +12 -3
- pygpt_net/provider/vector_stores/simple.py +12 -3
- pygpt_net/provider/vector_stores/temp.py +16 -4
- pygpt_net/provider/web/base.py +10 -3
- pygpt_net/provider/web/google_custom_search.py +9 -3
- pygpt_net/provider/web/microsoft_bing.py +9 -3
- pygpt_net/tools/__init__.py +13 -5
- pygpt_net/tools/audio_transcriber/__init__.py +4 -3
- pygpt_net/tools/base.py +15 -8
- pygpt_net/tools/code_interpreter/__init__.py +4 -3
- pygpt_net/tools/html_canvas/__init__.py +4 -3
- pygpt_net/tools/image_viewer/__init__.py +10 -4
- pygpt_net/tools/indexer/__init__.py +8 -7
- pygpt_net/tools/media_player/__init__.py +4 -3
- pygpt_net/tools/text_editor/__init__.py +36 -10
- pygpt_net/ui/layout/chat/output.py +2 -2
- pygpt_net/ui/menu/audio.py +12 -1
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/METADATA +136 -71
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/RECORD +139 -132
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/entry_points.txt +0 -0
@@ -6,13 +6,15 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import uuid
|
13
13
|
import time
|
14
|
+
from typing import Dict, Optional
|
14
15
|
|
15
16
|
from sqlalchemy import text
|
17
|
+
from traitlets import Any
|
16
18
|
|
17
19
|
from pygpt_net.item.index import IndexItem
|
18
20
|
from .utils import unpack_file_item
|
@@ -35,7 +37,10 @@ class Storage:
|
|
35
37
|
"""
|
36
38
|
self.window = window
|
37
39
|
|
38
|
-
def get_items(
|
40
|
+
def get_items(
|
41
|
+
self,
|
42
|
+
store_id: str
|
43
|
+
) -> Dict[str, IndexItem]:
|
39
44
|
"""
|
40
45
|
Return idx items by store ID
|
41
46
|
|
@@ -65,7 +70,12 @@ class Storage:
|
|
65
70
|
|
66
71
|
return indexes
|
67
72
|
|
68
|
-
def insert_file(
|
73
|
+
def insert_file(
|
74
|
+
self,
|
75
|
+
store_id: str,
|
76
|
+
idx: str,
|
77
|
+
data: Dict[str, Any]
|
78
|
+
) -> int:
|
69
79
|
"""
|
70
80
|
Insert file to index
|
71
81
|
|
@@ -114,7 +124,13 @@ class Storage:
|
|
114
124
|
|
115
125
|
return id
|
116
126
|
|
117
|
-
def insert_ctx_meta(
|
127
|
+
def insert_ctx_meta(
|
128
|
+
self,
|
129
|
+
store_id: str,
|
130
|
+
idx: str,
|
131
|
+
meta_id: int,
|
132
|
+
doc_id: str
|
133
|
+
) -> int:
|
118
134
|
"""
|
119
135
|
Insert ctx meta to index
|
120
136
|
|
@@ -162,7 +178,12 @@ class Storage:
|
|
162
178
|
|
163
179
|
return id
|
164
180
|
|
165
|
-
def insert_external(
|
181
|
+
def insert_external(
|
182
|
+
self,
|
183
|
+
store_id: str,
|
184
|
+
idx: str,
|
185
|
+
data: Dict[str, Any]
|
186
|
+
) -> int:
|
166
187
|
"""
|
167
188
|
Insert external data to index
|
168
189
|
|
@@ -211,7 +232,12 @@ class Storage:
|
|
211
232
|
|
212
233
|
return id
|
213
234
|
|
214
|
-
def is_meta_indexed(
|
235
|
+
def is_meta_indexed(
|
236
|
+
self,
|
237
|
+
store_id: str,
|
238
|
+
idx: str,
|
239
|
+
meta_id: int
|
240
|
+
) -> bool:
|
215
241
|
"""
|
216
242
|
Check if context meta is indexed
|
217
243
|
|
@@ -238,7 +264,12 @@ class Storage:
|
|
238
264
|
data = row._asdict()
|
239
265
|
return int(data['count']) > 0
|
240
266
|
|
241
|
-
def is_file_indexed(
|
267
|
+
def is_file_indexed(
|
268
|
+
self,
|
269
|
+
store_id: str,
|
270
|
+
idx: str,
|
271
|
+
file_id: str
|
272
|
+
) -> bool:
|
242
273
|
"""
|
243
274
|
Check if file is indexed
|
244
275
|
|
@@ -265,7 +296,13 @@ class Storage:
|
|
265
296
|
data = row._asdict()
|
266
297
|
return int(data['count']) > 0
|
267
298
|
|
268
|
-
def is_external_indexed(
|
299
|
+
def is_external_indexed(
|
300
|
+
self,
|
301
|
+
store_id: str,
|
302
|
+
idx: str,
|
303
|
+
content: str,
|
304
|
+
type: str
|
305
|
+
) -> bool:
|
269
306
|
"""
|
270
307
|
Check if external is indexed
|
271
308
|
|
@@ -295,7 +332,12 @@ class Storage:
|
|
295
332
|
data = row._asdict()
|
296
333
|
return int(data['count']) > 0
|
297
334
|
|
298
|
-
def get_meta_doc_id(
|
335
|
+
def get_meta_doc_id(
|
336
|
+
self,
|
337
|
+
store_id: str,
|
338
|
+
idx: str,
|
339
|
+
meta_id: int
|
340
|
+
) -> str:
|
299
341
|
"""
|
300
342
|
Get indexed document id by meta id
|
301
343
|
|
@@ -322,7 +364,12 @@ class Storage:
|
|
322
364
|
data = row._asdict()
|
323
365
|
return data['doc_id']
|
324
366
|
|
325
|
-
def get_file_doc_id(
|
367
|
+
def get_file_doc_id(
|
368
|
+
self,
|
369
|
+
store_id: str,
|
370
|
+
idx: str,
|
371
|
+
file_id: str
|
372
|
+
) -> str:
|
326
373
|
"""
|
327
374
|
Get indexed document id by file id
|
328
375
|
|
@@ -349,7 +396,13 @@ class Storage:
|
|
349
396
|
data = row._asdict()
|
350
397
|
return data['doc_id']
|
351
398
|
|
352
|
-
def get_external_doc_id(
|
399
|
+
def get_external_doc_id(
|
400
|
+
self,
|
401
|
+
store_id: str,
|
402
|
+
idx: str,
|
403
|
+
content: str,
|
404
|
+
type: str
|
405
|
+
) -> str:
|
353
406
|
"""
|
354
407
|
Get indexed document id by external
|
355
408
|
|
@@ -379,7 +432,12 @@ class Storage:
|
|
379
432
|
data = row._asdict()
|
380
433
|
return data['doc_id']
|
381
434
|
|
382
|
-
def update_file(
|
435
|
+
def update_file(
|
436
|
+
self,
|
437
|
+
id: int,
|
438
|
+
doc_id: str,
|
439
|
+
ts: int
|
440
|
+
) -> bool:
|
383
441
|
"""
|
384
442
|
Update timestamp of file in index
|
385
443
|
|
@@ -403,7 +461,11 @@ class Storage:
|
|
403
461
|
conn.execute(stmt)
|
404
462
|
return True
|
405
463
|
|
406
|
-
def update_ctx_meta(
|
464
|
+
def update_ctx_meta(
|
465
|
+
self,
|
466
|
+
meta_id: int,
|
467
|
+
doc_id: str
|
468
|
+
) -> bool:
|
407
469
|
"""
|
408
470
|
Update timestamp of ctx meta in index
|
409
471
|
|
@@ -427,7 +489,13 @@ class Storage:
|
|
427
489
|
conn.execute(stmt)
|
428
490
|
return True
|
429
491
|
|
430
|
-
def update_external(
|
492
|
+
def update_external(
|
493
|
+
self,
|
494
|
+
content: str,
|
495
|
+
type: str,
|
496
|
+
doc_id: str,
|
497
|
+
ts: int
|
498
|
+
) -> bool:
|
431
499
|
"""
|
432
500
|
Update timestamp of external data in index
|
433
501
|
|
@@ -454,7 +522,12 @@ class Storage:
|
|
454
522
|
conn.execute(stmt)
|
455
523
|
return True
|
456
524
|
|
457
|
-
def remove_file(
|
525
|
+
def remove_file(
|
526
|
+
self,
|
527
|
+
store_id: str,
|
528
|
+
idx: str,
|
529
|
+
doc_id: str
|
530
|
+
):
|
458
531
|
"""
|
459
532
|
Remove file from index
|
460
533
|
|
@@ -471,7 +544,12 @@ class Storage:
|
|
471
544
|
doc_id=doc_id,
|
472
545
|
))
|
473
546
|
|
474
|
-
def remove_ctx_meta(
|
547
|
+
def remove_ctx_meta(
|
548
|
+
self,
|
549
|
+
store_id: str,
|
550
|
+
idx: str,
|
551
|
+
meta_id: str
|
552
|
+
):
|
475
553
|
"""
|
476
554
|
Remove file from index
|
477
555
|
|
@@ -488,7 +566,12 @@ class Storage:
|
|
488
566
|
meta_id=meta_id,
|
489
567
|
))
|
490
568
|
|
491
|
-
def remove_external(
|
569
|
+
def remove_external(
|
570
|
+
self,
|
571
|
+
store_id: str,
|
572
|
+
idx: str,
|
573
|
+
doc_id: str
|
574
|
+
):
|
492
575
|
"""
|
493
576
|
Remove file from index
|
494
577
|
|
@@ -505,7 +588,11 @@ class Storage:
|
|
505
588
|
doc_id=doc_id,
|
506
589
|
))
|
507
590
|
|
508
|
-
def truncate_all(
|
591
|
+
def truncate_all(
|
592
|
+
self,
|
593
|
+
store_id: Optional[str] = None,
|
594
|
+
idx: Optional[str] = None
|
595
|
+
) -> bool:
|
509
596
|
"""
|
510
597
|
Truncate all idx tables in database (all stores)
|
511
598
|
|
@@ -518,7 +605,11 @@ class Storage:
|
|
518
605
|
self.truncate_external(store_id, idx)
|
519
606
|
return True
|
520
607
|
|
521
|
-
def truncate_files(
|
608
|
+
def truncate_files(
|
609
|
+
self,
|
610
|
+
store_id: Optional[str] = None,
|
611
|
+
idx: Optional[str] = None
|
612
|
+
) -> bool:
|
522
613
|
"""
|
523
614
|
Truncate files table in database
|
524
615
|
|
@@ -528,7 +619,11 @@ class Storage:
|
|
528
619
|
"""
|
529
620
|
return self.truncate_by_db_table("idx_file", store_id, idx)
|
530
621
|
|
531
|
-
def truncate_ctx(
|
622
|
+
def truncate_ctx(
|
623
|
+
self,
|
624
|
+
store_id: Optional[str] = None,
|
625
|
+
idx: Optional[str] = None
|
626
|
+
) -> bool:
|
532
627
|
"""
|
533
628
|
Truncate context table in database
|
534
629
|
|
@@ -538,7 +633,11 @@ class Storage:
|
|
538
633
|
"""
|
539
634
|
return self.truncate_by_db_table("idx_ctx", store_id, idx)
|
540
635
|
|
541
|
-
def truncate_external(
|
636
|
+
def truncate_external(
|
637
|
+
self,
|
638
|
+
store_id: Optional[str] = None,
|
639
|
+
idx: Optional[str] = None
|
640
|
+
) -> bool:
|
542
641
|
"""
|
543
642
|
Truncate external table in database
|
544
643
|
|
@@ -548,7 +647,12 @@ class Storage:
|
|
548
647
|
"""
|
549
648
|
return self.truncate_by_db_table("idx_external", store_id, idx)
|
550
649
|
|
551
|
-
def truncate_by_db_table(
|
650
|
+
def truncate_by_db_table(
|
651
|
+
self,
|
652
|
+
tbl: str,
|
653
|
+
store_id: Optional[str] = None,
|
654
|
+
idx: Optional[str] = None
|
655
|
+
) -> bool:
|
552
656
|
"""
|
553
657
|
Truncate external table in database
|
554
658
|
|
@@ -574,7 +678,10 @@ class Storage:
|
|
574
678
|
text(query).bindparams(**params))
|
575
679
|
return True
|
576
680
|
|
577
|
-
def get_counters(
|
681
|
+
def get_counters(
|
682
|
+
self,
|
683
|
+
type: str
|
684
|
+
) -> Dict[str, Dict[str, int]]:
|
578
685
|
"""
|
579
686
|
Get counters (stats, count items by type [file, ctx, external])
|
580
687
|
|
@@ -6,13 +6,15 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Tuple, Dict, Any
|
13
|
+
|
12
14
|
from pygpt_net.utils import unpack_var
|
13
15
|
|
14
16
|
|
15
|
-
def unpack_file_item(row:
|
17
|
+
def unpack_file_item(row: Dict[str, Any]) -> Tuple[str, dict]:
|
16
18
|
"""
|
17
19
|
Unpack item from DB row
|
18
20
|
|
@@ -6,9 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date:
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Dict
|
13
|
+
|
12
14
|
from pygpt_net.item.mode import ModeItem
|
13
15
|
|
14
16
|
|
@@ -24,10 +26,10 @@ class BaseProvider:
|
|
24
26
|
def create(self, mode: ModeItem) -> str:
|
25
27
|
pass
|
26
28
|
|
27
|
-
def load(self) ->
|
29
|
+
def load(self) -> Dict[str, str]:
|
28
30
|
pass
|
29
31
|
|
30
|
-
def save(self, items:
|
32
|
+
def save(self, items: Dict[str, str]):
|
31
33
|
pass
|
32
34
|
|
33
35
|
def remove(self, id: str):
|
@@ -6,11 +6,12 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
13
|
import os
|
14
|
+
from typing import Optional, Dict
|
14
15
|
|
15
16
|
from pygpt_net.provider.core.mode.base import BaseProvider
|
16
17
|
from pygpt_net.item.mode import ModeItem
|
@@ -26,7 +27,7 @@ class JsonFileProvider(BaseProvider):
|
|
26
27
|
self.type = "mode"
|
27
28
|
self.config_file = 'modes.json'
|
28
29
|
|
29
|
-
def get_version(self) -> str
|
30
|
+
def get_version(self) -> Optional[str]:
|
30
31
|
"""
|
31
32
|
Get data version
|
32
33
|
|
@@ -40,7 +41,7 @@ class JsonFileProvider(BaseProvider):
|
|
40
41
|
if '__meta__' in data and 'version' in data['__meta__']:
|
41
42
|
return data['__meta__']['version']
|
42
43
|
|
43
|
-
def load(self) ->
|
44
|
+
def load(self) -> Optional[Dict[str, ModeItem]]:
|
44
45
|
"""
|
45
46
|
Load modes config from JSON file
|
46
47
|
|
@@ -69,7 +70,7 @@ class JsonFileProvider(BaseProvider):
|
|
69
70
|
|
70
71
|
return items
|
71
72
|
|
72
|
-
def save(self, items:
|
73
|
+
def save(self, items: Dict[str, ModeItem]):
|
73
74
|
"""
|
74
75
|
Save modes config to JSON file
|
75
76
|
|
@@ -101,7 +102,7 @@ class JsonFileProvider(BaseProvider):
|
|
101
102
|
pass
|
102
103
|
|
103
104
|
@staticmethod
|
104
|
-
def serialize(item: ModeItem) ->
|
105
|
+
def serialize(item: ModeItem) -> Dict[str, str]:
|
105
106
|
"""
|
106
107
|
Serialize item to dict
|
107
108
|
|
@@ -116,7 +117,7 @@ class JsonFileProvider(BaseProvider):
|
|
116
117
|
}
|
117
118
|
|
118
119
|
@staticmethod
|
119
|
-
def deserialize(data:
|
120
|
+
def deserialize(data: Dict[str, str], item: ModeItem):
|
120
121
|
"""
|
121
122
|
Deserialize item from dict
|
122
123
|
|
@@ -6,9 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date:
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Dict
|
13
|
+
|
12
14
|
from packaging.version import Version
|
13
15
|
|
14
16
|
from pygpt_net.item.model import ModelItem
|
@@ -32,13 +34,13 @@ class BaseProvider:
|
|
32
34
|
def create(self, model: ModelItem) -> str:
|
33
35
|
pass
|
34
36
|
|
35
|
-
def load(self) ->
|
37
|
+
def load(self) -> Dict[str, ModelItem]:
|
36
38
|
pass
|
37
39
|
|
38
|
-
def load_base(self) ->
|
40
|
+
def load_base(self) -> Dict[str, ModelItem]:
|
39
41
|
pass
|
40
42
|
|
41
|
-
def save(self, items:
|
43
|
+
def save(self, items: Dict[str, ModelItem]):
|
42
44
|
pass
|
43
45
|
|
44
46
|
def remove(self, id: str):
|
@@ -6,12 +6,14 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
13
|
import os
|
14
14
|
import shutil
|
15
|
+
from typing import Optional, Dict, Any
|
16
|
+
|
15
17
|
from packaging.version import Version
|
16
18
|
|
17
19
|
from pygpt_net.provider.core.model.base import BaseProvider
|
@@ -38,7 +40,7 @@ class JsonFileProvider(BaseProvider):
|
|
38
40
|
src = os.path.join(self.window.core.config.get_app_path(), 'data', 'config', self.config_file)
|
39
41
|
shutil.copyfile(src, dst)
|
40
42
|
|
41
|
-
def get_version(self) -> str
|
43
|
+
def get_version(self) -> Optional[str]:
|
42
44
|
"""
|
43
45
|
Get data version
|
44
46
|
|
@@ -52,7 +54,7 @@ class JsonFileProvider(BaseProvider):
|
|
52
54
|
if '__meta__' in data and 'version' in data['__meta__']:
|
53
55
|
return data['__meta__']['version']
|
54
56
|
|
55
|
-
def load_base(self) ->
|
57
|
+
def load_base(self) -> Optional[Dict[str, ModelItem]]:
|
56
58
|
"""
|
57
59
|
Load base models config from base JSON file
|
58
60
|
|
@@ -61,7 +63,7 @@ class JsonFileProvider(BaseProvider):
|
|
61
63
|
path = os.path.join(self.window.core.config.get_app_path(), 'data', 'config', self.config_file)
|
62
64
|
return self.load(path)
|
63
65
|
|
64
|
-
def load(self, path: str = None) ->
|
66
|
+
def load(self, path: Optional[str] = None) -> Optional[Dict[str, ModelItem]]:
|
65
67
|
"""
|
66
68
|
Load models config from JSON file
|
67
69
|
"""
|
@@ -106,7 +108,7 @@ class JsonFileProvider(BaseProvider):
|
|
106
108
|
|
107
109
|
return items
|
108
110
|
|
109
|
-
def save(self, items:
|
111
|
+
def save(self, items: Dict[str, ModelItem]):
|
110
112
|
"""
|
111
113
|
Save models config to JSON file
|
112
114
|
|
@@ -147,7 +149,7 @@ class JsonFileProvider(BaseProvider):
|
|
147
149
|
return self.patcher.execute(version)
|
148
150
|
|
149
151
|
@staticmethod
|
150
|
-
def serialize(item: ModelItem) ->
|
152
|
+
def serialize(item: ModelItem) -> Dict[str, Any]:
|
151
153
|
"""
|
152
154
|
Serialize item to dict
|
153
155
|
|
@@ -167,7 +169,7 @@ class JsonFileProvider(BaseProvider):
|
|
167
169
|
}
|
168
170
|
|
169
171
|
@staticmethod
|
170
|
-
def deserialize(data:
|
172
|
+
def deserialize(data: Dict[str, Any], item: ModelItem):
|
171
173
|
"""
|
172
174
|
Deserialize item from dict
|
173
175
|
|
@@ -6,9 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date:
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Dict
|
13
|
+
|
12
14
|
from packaging.version import Version
|
13
15
|
|
14
16
|
from pygpt_net.item.notepad import NotepadItem
|
@@ -35,13 +37,13 @@ class BaseProvider:
|
|
35
37
|
def load(self, id) -> NotepadItem:
|
36
38
|
pass
|
37
39
|
|
38
|
-
def load_all(self) ->
|
40
|
+
def load_all(self) -> Dict[int, NotepadItem]:
|
39
41
|
pass
|
40
42
|
|
41
43
|
def save(self, notepad: NotepadItem):
|
42
44
|
pass
|
43
45
|
|
44
|
-
def save_all(self, items:
|
46
|
+
def save_all(self, items: Dict[int, NotepadItem]):
|
45
47
|
pass
|
46
48
|
|
47
49
|
def remove(self, id):
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import uuid
|
13
|
+
from typing import Dict
|
13
14
|
|
14
15
|
from packaging.version import Version
|
15
16
|
|
@@ -49,7 +50,7 @@ class DbSqliteProvider(BaseProvider):
|
|
49
50
|
"""
|
50
51
|
return str(uuid.uuid4())
|
51
52
|
|
52
|
-
def create(self, notepad: NotepadItem) ->
|
53
|
+
def create(self, notepad: NotepadItem) -> int:
|
53
54
|
"""
|
54
55
|
Create new and return its ID
|
55
56
|
|
@@ -60,7 +61,7 @@ class DbSqliteProvider(BaseProvider):
|
|
60
61
|
notepad.id = self.storage.insert(notepad)
|
61
62
|
return notepad.id
|
62
63
|
|
63
|
-
def load_all(self) ->
|
64
|
+
def load_all(self) -> Dict[int, NotepadItem]:
|
64
65
|
"""
|
65
66
|
Load notepads from DB
|
66
67
|
|
@@ -89,7 +90,7 @@ class DbSqliteProvider(BaseProvider):
|
|
89
90
|
self.window.core.debug.log(e)
|
90
91
|
print("Error while saving notepad: {}".format(str(e)))
|
91
92
|
|
92
|
-
def save_all(self, items:
|
93
|
+
def save_all(self, items: Dict[int, NotepadItem]):
|
93
94
|
"""
|
94
95
|
Save all notepads to DB
|
95
96
|
|
@@ -6,10 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date:
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import time
|
13
|
+
from typing import Dict, Any
|
13
14
|
|
14
15
|
from sqlalchemy import text
|
15
16
|
|
@@ -33,7 +34,7 @@ class Storage:
|
|
33
34
|
"""
|
34
35
|
self.window = window
|
35
36
|
|
36
|
-
def get_all(self) ->
|
37
|
+
def get_all(self) -> Dict[int, NotepadItem]:
|
37
38
|
"""
|
38
39
|
Return dict with NotepadItem objects, indexed by ID
|
39
40
|
|
@@ -207,7 +208,7 @@ class Storage:
|
|
207
208
|
notepad.id = result.lastrowid
|
208
209
|
return notepad.id
|
209
210
|
|
210
|
-
def unpack(self, notepad: NotepadItem, row:
|
211
|
+
def unpack(self, notepad: NotepadItem, row: Dict[str, Any]) -> NotepadItem:
|
211
212
|
"""
|
212
213
|
Unpack notepad item from DB row
|
213
214
|
|
@@ -6,9 +6,11 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Optional
|
13
|
+
|
12
14
|
from packaging.version import Version
|
13
15
|
|
14
16
|
|
@@ -27,7 +29,7 @@ class BaseProvider:
|
|
27
29
|
def patch(self, version: Version) -> bool:
|
28
30
|
pass
|
29
31
|
|
30
|
-
def load(self, all: bool = False) -> dict:
|
32
|
+
def load(self, all: bool = False) -> Optional[dict]:
|
31
33
|
pass
|
32
34
|
|
33
35
|
def save(self, items: dict):
|
@@ -6,11 +6,13 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
13
|
import os
|
14
|
+
from typing import Optional
|
15
|
+
|
14
16
|
from packaging.version import Version
|
15
17
|
|
16
18
|
from pygpt_net.provider.core.plugin_preset.base import BaseProvider
|
@@ -35,7 +37,7 @@ class JsonFileProvider(BaseProvider):
|
|
35
37
|
self.save({})
|
36
38
|
print("Installed: {}".format(dst))
|
37
39
|
|
38
|
-
def get_version(self) -> str
|
40
|
+
def get_version(self) -> Optional[str]:
|
39
41
|
"""
|
40
42
|
Get config file version
|
41
43
|
|
@@ -50,7 +52,7 @@ class JsonFileProvider(BaseProvider):
|
|
50
52
|
if '__meta__' in data and 'version' in data['__meta__']:
|
51
53
|
return data['__meta__']['version']
|
52
54
|
|
53
|
-
def load(self, all: bool = False) -> dict
|
55
|
+
def load(self, all: bool = False) -> Optional[dict]:
|
54
56
|
"""
|
55
57
|
Load config from JSON file
|
56
58
|
|