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.
Files changed (139) hide show
  1. CHANGELOG.md +8 -0
  2. README.md +135 -70
  3. pygpt_net/CHANGELOG.txt +8 -0
  4. pygpt_net/__init__.py +3 -3
  5. pygpt_net/app.py +3 -1
  6. pygpt_net/controller/audio/__init__.py +2 -2
  7. pygpt_net/controller/camera.py +1 -10
  8. pygpt_net/controller/chat/audio.py +2 -2
  9. pygpt_net/controller/config/placeholder.py +15 -1
  10. pygpt_net/controller/ui/mode.py +16 -21
  11. pygpt_net/core/audio/__init__.py +4 -1
  12. pygpt_net/core/audio/whisper.py +37 -0
  13. pygpt_net/core/bridge/worker.py +2 -2
  14. pygpt_net/core/debug/events.py +22 -10
  15. pygpt_net/core/debug/tabs.py +6 -3
  16. pygpt_net/core/history.py +3 -2
  17. pygpt_net/core/idx/__init__.py +16 -4
  18. pygpt_net/core/idx/chat.py +15 -5
  19. pygpt_net/core/idx/indexing.py +24 -8
  20. pygpt_net/core/installer.py +2 -4
  21. pygpt_net/core/models.py +62 -17
  22. pygpt_net/core/modes.py +11 -13
  23. pygpt_net/core/notepad.py +4 -4
  24. pygpt_net/core/plugins.py +27 -16
  25. pygpt_net/core/presets.py +20 -9
  26. pygpt_net/core/profile.py +11 -3
  27. pygpt_net/core/render/web/parser.py +3 -1
  28. pygpt_net/core/settings.py +5 -5
  29. pygpt_net/core/tabs/tab.py +10 -2
  30. pygpt_net/core/tokens.py +8 -6
  31. pygpt_net/core/web/__init__.py +105 -0
  32. pygpt_net/core/{web.py → web/helpers.py} +93 -67
  33. pygpt_net/data/config/config.json +3 -3
  34. pygpt_net/data/config/models.json +3 -3
  35. pygpt_net/data/config/modes.json +3 -3
  36. pygpt_net/data/locale/locale.en.ini +1 -0
  37. pygpt_net/data/locale/plugin.cmd_web.en.ini +2 -0
  38. pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
  39. pygpt_net/item/ctx.py +13 -2
  40. pygpt_net/plugin/agent/__init__.py +7 -2
  41. pygpt_net/plugin/audio_output/__init__.py +6 -1
  42. pygpt_net/plugin/base/plugin.py +58 -26
  43. pygpt_net/plugin/base/worker.py +20 -17
  44. pygpt_net/plugin/cmd_history/config.py +2 -2
  45. pygpt_net/plugin/cmd_web/__init__.py +3 -4
  46. pygpt_net/plugin/cmd_web/config.py +71 -3
  47. pygpt_net/plugin/cmd_web/websearch.py +20 -12
  48. pygpt_net/plugin/cmd_web/worker.py +67 -4
  49. pygpt_net/plugin/idx_llama_index/config.py +3 -3
  50. pygpt_net/plugin/mailer/__init__.py +123 -0
  51. pygpt_net/plugin/mailer/config.py +149 -0
  52. pygpt_net/plugin/mailer/runner.py +285 -0
  53. pygpt_net/plugin/mailer/worker.py +123 -0
  54. pygpt_net/provider/agents/base.py +5 -2
  55. pygpt_net/provider/agents/openai.py +4 -2
  56. pygpt_net/provider/agents/openai_assistant.py +4 -2
  57. pygpt_net/provider/agents/planner.py +4 -2
  58. pygpt_net/provider/agents/react.py +4 -2
  59. pygpt_net/provider/audio_output/openai_tts.py +5 -11
  60. pygpt_net/provider/core/assistant/base.py +5 -3
  61. pygpt_net/provider/core/assistant/json_file.py +8 -5
  62. pygpt_net/provider/core/assistant_file/base.py +4 -3
  63. pygpt_net/provider/core/assistant_file/db_sqlite/__init__.py +4 -3
  64. pygpt_net/provider/core/assistant_file/db_sqlite/storage.py +3 -2
  65. pygpt_net/provider/core/assistant_store/base.py +6 -4
  66. pygpt_net/provider/core/assistant_store/db_sqlite/__init__.py +5 -4
  67. pygpt_net/provider/core/assistant_store/db_sqlite/storage.py +5 -3
  68. pygpt_net/provider/core/attachment/base.py +5 -3
  69. pygpt_net/provider/core/attachment/json_file.py +4 -3
  70. pygpt_net/provider/core/calendar/base.py +5 -3
  71. pygpt_net/provider/core/calendar/db_sqlite/__init__.py +6 -5
  72. pygpt_net/provider/core/calendar/db_sqlite/storage.py +5 -4
  73. pygpt_net/provider/core/config/base.py +8 -6
  74. pygpt_net/provider/core/config/json_file.py +9 -7
  75. pygpt_net/provider/core/ctx/base.py +27 -25
  76. pygpt_net/provider/core/ctx/db_sqlite/__init__.py +51 -35
  77. pygpt_net/provider/core/ctx/db_sqlite/storage.py +42 -31
  78. pygpt_net/provider/core/ctx/db_sqlite/utils.py +11 -9
  79. pygpt_net/provider/core/index/base.py +129 -23
  80. pygpt_net/provider/core/index/db_sqlite/__init__.py +130 -23
  81. pygpt_net/provider/core/index/db_sqlite/storage.py +130 -23
  82. pygpt_net/provider/core/index/db_sqlite/utils.py +4 -2
  83. pygpt_net/provider/core/mode/base.py +5 -3
  84. pygpt_net/provider/core/mode/json_file.py +7 -6
  85. pygpt_net/provider/core/model/base.py +6 -4
  86. pygpt_net/provider/core/model/json_file.py +9 -7
  87. pygpt_net/provider/core/notepad/base.py +5 -3
  88. pygpt_net/provider/core/notepad/db_sqlite/__init__.py +5 -4
  89. pygpt_net/provider/core/notepad/db_sqlite/storage.py +4 -3
  90. pygpt_net/provider/core/plugin_preset/base.py +4 -2
  91. pygpt_net/provider/core/plugin_preset/json_file.py +5 -3
  92. pygpt_net/provider/core/preset/base.py +6 -4
  93. pygpt_net/provider/core/preset/json_file.py +9 -9
  94. pygpt_net/provider/core/prompt/base.py +6 -3
  95. pygpt_net/provider/core/prompt/json_file.py +11 -6
  96. pygpt_net/provider/gpt/assistants.py +15 -6
  97. pygpt_net/provider/gpt/audio.py +5 -5
  98. pygpt_net/provider/gpt/chat.py +7 -5
  99. pygpt_net/provider/gpt/completion.py +8 -4
  100. pygpt_net/provider/gpt/image.py +3 -3
  101. pygpt_net/provider/gpt/store.py +46 -12
  102. pygpt_net/provider/gpt/vision.py +16 -11
  103. pygpt_net/provider/llms/anthropic.py +7 -2
  104. pygpt_net/provider/llms/azure_openai.py +26 -5
  105. pygpt_net/provider/llms/base.py +47 -9
  106. pygpt_net/provider/llms/google.py +7 -2
  107. pygpt_net/provider/llms/hugging_face.py +13 -3
  108. pygpt_net/provider/llms/hugging_face_api.py +18 -4
  109. pygpt_net/provider/llms/local.py +7 -2
  110. pygpt_net/provider/llms/ollama.py +30 -6
  111. pygpt_net/provider/llms/openai.py +32 -6
  112. pygpt_net/provider/vector_stores/__init__.py +45 -14
  113. pygpt_net/provider/vector_stores/base.py +35 -8
  114. pygpt_net/provider/vector_stores/chroma.py +13 -3
  115. pygpt_net/provider/vector_stores/ctx_attachment.py +31 -12
  116. pygpt_net/provider/vector_stores/elasticsearch.py +12 -3
  117. pygpt_net/provider/vector_stores/pinecode.py +12 -3
  118. pygpt_net/provider/vector_stores/redis.py +12 -3
  119. pygpt_net/provider/vector_stores/simple.py +12 -3
  120. pygpt_net/provider/vector_stores/temp.py +16 -4
  121. pygpt_net/provider/web/base.py +10 -3
  122. pygpt_net/provider/web/google_custom_search.py +9 -3
  123. pygpt_net/provider/web/microsoft_bing.py +9 -3
  124. pygpt_net/tools/__init__.py +13 -5
  125. pygpt_net/tools/audio_transcriber/__init__.py +4 -3
  126. pygpt_net/tools/base.py +15 -8
  127. pygpt_net/tools/code_interpreter/__init__.py +4 -3
  128. pygpt_net/tools/html_canvas/__init__.py +4 -3
  129. pygpt_net/tools/image_viewer/__init__.py +10 -4
  130. pygpt_net/tools/indexer/__init__.py +8 -7
  131. pygpt_net/tools/media_player/__init__.py +4 -3
  132. pygpt_net/tools/text_editor/__init__.py +36 -10
  133. pygpt_net/ui/layout/chat/output.py +2 -2
  134. pygpt_net/ui/menu/audio.py +12 -1
  135. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/METADATA +136 -71
  136. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/RECORD +139 -132
  137. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/LICENSE +0 -0
  138. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/WHEEL +0 -0
  139. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.42.dist-info}/entry_points.txt +0 -0
@@ -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.04.29 16:00:00 #
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
 
@@ -67,7 +68,7 @@ class DbSqliteProvider(BaseProvider):
67
68
  file.record_id = self.storage.insert(file)
68
69
  return file.record_id
69
70
 
70
- def load_all(self) -> dict:
71
+ def load_all(self) -> Dict[str, AssistantFileItem]:
71
72
  """
72
73
  Load files from DB
73
74
 
@@ -96,7 +97,7 @@ class DbSqliteProvider(BaseProvider):
96
97
  self.window.core.debug.log(e)
97
98
  print("Error while saving filed: {}".format(str(e)))
98
99
 
99
- def save_all(self, items: dict):
100
+ def save_all(self, items: Dict[str, AssistantFileItem]):
100
101
  """
101
102
  Save all files to DB
102
103
 
@@ -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.04.29 16:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import time
13
+ from typing import Dict
13
14
 
14
15
  from sqlalchemy import text
15
16
 
@@ -34,7 +35,7 @@ class Storage:
34
35
  """
35
36
  self.window = window
36
37
 
37
- def get_all(self) -> dict:
38
+ def get_all(self) -> Dict[str, AssistantFileItem]:
38
39
  """
39
40
  Return dict with AssistantFileItem objects, indexed by ID
40
41
 
@@ -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.04.26 23:00:00 #
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.assistant import AssistantStoreItem
@@ -32,16 +34,16 @@ class BaseProvider:
32
34
  def create(self, store: AssistantStoreItem) -> str:
33
35
  pass
34
36
 
35
- def load(self, id) -> dict:
37
+ def load(self, id) -> AssistantStoreItem:
36
38
  pass
37
39
 
38
- def load_all(self) -> dict:
40
+ def load_all(self) -> Dict[str, AssistantStoreItem]:
39
41
  pass
40
42
 
41
43
  def save(self, file: AssistantStoreItem):
42
44
  pass
43
45
 
44
- def save_all(self, items: dict):
46
+ def save_all(self, items: Dict[str, AssistantStoreItem]):
45
47
  pass
46
48
 
47
49
  def remove(self, id: str):
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env python3
2
2
  # -*- coding: utf-8 -*-
3
3
  # ================================================== #
4
- # This store is a part of PYGPT package #
4
+ # This store is a part of PYGPT package #
5
5
  # Website: https://pygpt.net #
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.04.26 23:00:00 #
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
 
@@ -62,7 +63,7 @@ class DbSqliteProvider(BaseProvider):
62
63
  store.record_id = self.storage.insert(store)
63
64
  return store.record_id
64
65
 
65
- def load_all(self) -> dict:
66
+ def load_all(self) -> Dict[str, AssistantStoreItem]:
66
67
  """
67
68
  Load stores from DB
68
69
 
@@ -91,7 +92,7 @@ class DbSqliteProvider(BaseProvider):
91
92
  self.window.core.debug.log(e)
92
93
  print("Error while saving stored: {}".format(str(e)))
93
94
 
94
- def save_all(self, items: dict):
95
+ def save_all(self, items: Dict[str, AssistantStoreItem]):
95
96
  """
96
97
  Save all stores to DB
97
98
 
@@ -1,19 +1,21 @@
1
1
  #!/usr/bin/env python3
2
2
  # -*- coding: utf-8 -*-
3
3
  # ================================================== #
4
- # This store is a part of PYGPT package #
4
+ # This store is a part of PYGPT package #
5
5
  # Website: https://pygpt.net #
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.04.26 23:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import time
13
+ from typing import Dict
13
14
 
14
15
  from sqlalchemy import text
15
16
 
16
17
  from pygpt_net.item.assistant import AssistantStoreItem
18
+
17
19
  from .utils import pack_item_value, unpack_store
18
20
 
19
21
  class Storage:
@@ -33,7 +35,7 @@ class Storage:
33
35
  """
34
36
  self.window = window
35
37
 
36
- def get_all(self) -> dict:
38
+ def get_all(self) -> Dict[str, AssistantStoreItem]:
37
39
  """
38
40
  Return dict with AssistantStoreItem objects, indexed by ID
39
41
 
@@ -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: 2023.12.31 04:00:00 #
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.attachment import AttachmentItem
@@ -32,10 +34,10 @@ class BaseProvider:
32
34
  def create(self, attachment: AttachmentItem) -> str:
33
35
  pass
34
36
 
35
- def load(self) -> dict:
37
+ def load(self) -> Dict[str, Dict[str, AttachmentItem]]:
36
38
  pass
37
39
 
38
- def save(self, items: dict):
40
+ def save(self, items: Dict[str, Dict[str, AttachmentItem]]):
39
41
  pass
40
42
 
41
43
  def remove(self, id: str):
@@ -6,12 +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.11.26 02:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
13
13
  import os
14
14
  import uuid
15
+ from typing import Dict
15
16
 
16
17
  from packaging.version import Version
17
18
 
@@ -46,7 +47,7 @@ class JsonFileProvider(BaseProvider):
46
47
  attachment.id = self.create_id()
47
48
  return attachment.id
48
49
 
49
- def load(self) -> dict:
50
+ def load(self) -> Dict[str, Dict[str, AttachmentItem]]:
50
51
  """
51
52
  Load attachments from file
52
53
 
@@ -74,7 +75,7 @@ class JsonFileProvider(BaseProvider):
74
75
 
75
76
  return items
76
77
 
77
- def save(self, items: dict):
78
+ def save(self, items: Dict[str, Dict[str, AttachmentItem]]):
78
79
  """
79
80
  Save attachments to file
80
81
  """
@@ -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.01.06 04:00:00 #
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.calendar_note import CalendarNoteItem
@@ -35,13 +37,13 @@ class BaseProvider:
35
37
  def load(self, year, month, day) -> CalendarNoteItem:
36
38
  pass
37
39
 
38
- def load_all(self) -> dict:
40
+ def load_all(self) -> Dict[str, CalendarNoteItem]:
39
41
  pass
40
42
 
41
43
  def save(self, notepad: CalendarNoteItem):
42
44
  pass
43
45
 
44
- def save_all(self, items: dict):
46
+ def save_all(self, items: Dict[str, CalendarNoteItem]):
45
47
  pass
46
48
 
47
49
  def remove(self, year, month, day):
@@ -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.03.07 23:00:00 #
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
 
@@ -65,7 +66,7 @@ class DbSqliteProvider(BaseProvider):
65
66
  note.id = self.storage.insert(note)
66
67
  return note.id
67
68
 
68
- def load_all(self) -> dict:
69
+ def load_all(self) -> Dict[str, CalendarNoteItem]:
69
70
  """
70
71
  Load notes from DB
71
72
 
@@ -73,7 +74,7 @@ class DbSqliteProvider(BaseProvider):
73
74
  """
74
75
  return self.storage.get_all()
75
76
 
76
- def load_by_month(self, year: int, month: int) -> dict:
77
+ def load_by_month(self, year: int, month: int) -> Dict[str, CalendarNoteItem]:
77
78
  """
78
79
  Load notes from DB
79
80
 
@@ -92,7 +93,7 @@ class DbSqliteProvider(BaseProvider):
92
93
  """
93
94
  return self.storage.get_by_date(year, month, day)
94
95
 
95
- def get_notes_existence_by_day(self, year, month) -> dict:
96
+ def get_notes_existence_by_day(self, year, month) -> Dict[str, Dict[int, int]]:
96
97
  """
97
98
  Get notes existence by day
98
99
 
@@ -114,7 +115,7 @@ class DbSqliteProvider(BaseProvider):
114
115
  self.window.core.debug.log(e)
115
116
  print("Error while saving note: {}".format(str(e)))
116
117
 
117
- def save_all(self, items: dict):
118
+ def save_all(self, items: Dict[str, CalendarNoteItem]):
118
119
  """
119
120
  Save all notes to DB
120
121
 
@@ -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.03.06 04:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import time
13
+ from typing import Dict
13
14
 
14
15
  from sqlalchemy import text
15
16
 
@@ -34,7 +35,7 @@ class Storage:
34
35
  """
35
36
  self.window = window
36
37
 
37
- def get_all(self) -> dict:
38
+ def get_all(self) -> Dict[str, CalendarNoteItem]:
38
39
  """
39
40
  Return dict with CalendarNoteItem objects, indexed by YYYY-MM-DD
40
41
 
@@ -54,7 +55,7 @@ class Storage:
54
55
  items[dt] = note
55
56
  return items
56
57
 
57
- def get_by_month(self, year: int, month: int) -> dict:
58
+ def get_by_month(self, year: int, month: int) -> Dict[str, CalendarNoteItem]:
58
59
  """
59
60
  Return dict with CalendarNoteItem objects, indexed by YYYY-MM-DD
60
61
 
@@ -96,7 +97,7 @@ class Storage:
96
97
  self.unpack(notepad, row._asdict())
97
98
  return notepad
98
99
 
99
- def get_notes_existence_by_day(self, year: int, month: int) -> dict:
100
+ def get_notes_existence_by_day(self, year: int, month: int) -> Dict[str, Dict[int, int]]:
100
101
  """
101
102
  Return a dict of days with the count of notes for the given year and month.
102
103
 
@@ -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: 2023.12.31 04:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict, Any, Optional
13
+
12
14
  from packaging.version import Version
13
15
 
14
16
 
@@ -30,19 +32,19 @@ class BaseProvider:
30
32
  def patch(self, version: Version) -> bool:
31
33
  pass
32
34
 
33
- def load(self, all: bool = False) -> dict:
35
+ def load(self, all: bool = False) -> Optional[Dict[str, Any]]:
34
36
  pass
35
37
 
36
- def load_base(self) -> dict:
38
+ def load_base(self) -> Optional[Dict[str, Any]]:
37
39
  pass
38
40
 
39
- def save(self, items: dict, filename: str = 'config.json'):
41
+ def save(self, items: Dict[str, Any], filename: str = 'config.json'):
40
42
  pass
41
43
 
42
- def get_options(self) -> dict:
44
+ def get_options(self) -> Optional[Dict[str, Any]]:
43
45
  pass
44
46
 
45
- def get_sections(self) -> dict:
47
+ def get_sections(self) -> Optional[Dict[str, Any]]:
46
48
  pass
47
49
 
48
50
  def get_version(self) -> 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.01.12 04:00:00 #
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.config.base import BaseProvider
@@ -38,7 +40,7 @@ class JsonFileProvider(BaseProvider):
38
40
  src = os.path.join(self.path_app, 'data', 'config', self.config_file)
39
41
  shutil.copyfile(src, dst)
40
42
 
41
- def get_version(self) -> str | None:
43
+ def get_version(self) -> Optional[str]:
42
44
  """
43
45
  Get config file 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(self, all: bool = False) -> dict | None:
57
+ def load(self, all: bool = False) -> Optional[Dict[str, Any]]:
56
58
  """
57
59
  Load config from JSON file
58
60
 
@@ -72,7 +74,7 @@ class JsonFileProvider(BaseProvider):
72
74
  print("FATAL ERROR: {}".format(e))
73
75
  return data
74
76
 
75
- def load_base(self) -> dict | None:
77
+ def load_base(self) -> Optional[Dict[str, Any]]:
76
78
  """
77
79
  Load config from JSON file
78
80
 
@@ -90,7 +92,7 @@ class JsonFileProvider(BaseProvider):
90
92
  print("FATAL ERROR: {}".format(e))
91
93
  return data
92
94
 
93
- def save(self, data: dict, filename: str = 'config.json'):
95
+ def save(self, data: Dict[str, Any], filename: str = 'config.json'):
94
96
  """
95
97
  Save config to JSON file
96
98
 
@@ -106,7 +108,7 @@ class JsonFileProvider(BaseProvider):
106
108
  except Exception as e:
107
109
  print("FATAL ERROR: {}".format(e))
108
110
 
109
- def get_options(self) -> dict | None:
111
+ def get_options(self) -> Optional[Dict[str, Any]]:
110
112
  """
111
113
  Load config settings options from JSON file
112
114
 
@@ -124,7 +126,7 @@ class JsonFileProvider(BaseProvider):
124
126
  print("FATAL ERROR: {}".format(e))
125
127
  return data
126
128
 
127
- def get_sections(self) -> dict | None:
129
+ def get_sections(self) -> Optional[Dict[str, Any]]:
128
130
  """
129
131
  Load config sections from JSON file
130
132
 
@@ -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.12.09 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import List, Dict, Optional
13
+
12
14
  from packaging.version import Version
13
15
 
14
16
  from pygpt_net.item.ctx import CtxMeta, CtxItem, CtxGroup
@@ -29,46 +31,46 @@ class BaseProvider:
29
31
  def patch(self, version: Version) -> bool:
30
32
  pass
31
33
 
32
- def append_item(self, meta: CtxMeta, item: CtxItem):
34
+ def append_item(self, meta: CtxMeta, item: CtxItem) -> bool:
33
35
  pass
34
36
 
35
- def update_item(self, item: CtxItem):
37
+ def update_item(self, item: CtxItem) -> bool:
36
38
  pass
37
39
 
38
- def create(self, meta: CtxMeta):
40
+ def create(self, meta: CtxMeta) -> int:
39
41
  pass
40
42
 
41
- def load(self, id) -> list:
43
+ def load(self, id: int) -> List[CtxItem]:
42
44
  return []
43
45
 
44
- def save(self, id, meta: CtxMeta, items: list):
46
+ def save(self, id: int, meta: CtxMeta, items: List[CtxItem]) -> bool:
45
47
  pass
46
48
 
47
- def remove(self, id):
49
+ def remove(self, id: int) -> bool:
48
50
  pass
49
51
 
50
- def remove_item(self, id):
52
+ def remove_item(self, id: int) -> bool:
51
53
  pass
52
54
 
53
- def remove_items_from(self, meta_id: int, item_id: int):
55
+ def remove_items_from(self, meta_id: int, item_id: int) -> bool:
54
56
  pass
55
57
 
56
- def truncate(self):
58
+ def truncate(self) -> bool:
57
59
  pass
58
60
 
59
61
  def get_meta(
60
62
  self,
61
- search_string: str = None,
62
- order_by: str = None,
63
- order_direction: str = None,
64
- limit: int = None,
65
- offset: int = None,
66
- filters: dict = None,
63
+ search_string: Optional[str] = None,
64
+ order_by: Optional[str] = None,
65
+ order_direction: Optional[str] = None,
66
+ limit: Optional[int] = None,
67
+ offset: Optional[int] = None,
68
+ filters: Optional[dict] = None,
67
69
  search_content: bool = False
68
- ):
70
+ ) -> Dict[int, CtxMeta]:
69
71
  pass
70
72
 
71
- def get_meta_indexed(self):
73
+ def get_meta_indexed(self) -> Dict[int, CtxMeta]:
72
74
  pass
73
75
 
74
76
  def get_item_by_id(self, id: int) -> CtxItem:
@@ -95,25 +97,25 @@ class BaseProvider:
95
97
  def clear_meta_indexed_all(self) -> bool:
96
98
  pass
97
99
 
98
- def get_groups(self) -> dict:
100
+ def get_groups(self) -> Dict[int, CtxGroup]:
99
101
  pass
100
102
 
101
- def insert_group(self, group: CtxGroup):
103
+ def insert_group(self, group: CtxGroup) -> int:
102
104
  pass
103
105
 
104
- def update_group(self, group: CtxGroup):
106
+ def update_group(self, group: CtxGroup) -> bool:
105
107
  pass
106
108
 
107
- def remove_group(self, id: int, all: bool = False):
109
+ def remove_group(self, id: int, all: bool = False) -> bool:
108
110
  pass
109
111
 
110
- def truncate_groups(self):
112
+ def truncate_groups(self) -> bool:
111
113
  pass
112
114
 
113
- def update_meta_group_id(self, meta_id: int, group_id: int):
115
+ def update_meta_group_id(self, meta_id: int, group_id: int) -> bool:
114
116
  pass
115
117
 
116
- def clear_meta(self, meta_id: int):
118
+ def clear_meta(self, meta_id: int) -> bool:
117
119
  pass
118
120
 
119
121