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.12.09 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import time
13
+ from typing import List, Dict, Optional
13
14
  from uuid import uuid4
14
15
  from packaging.version import Version
15
16
 
@@ -29,6 +30,11 @@ class DbSqliteProvider(BaseProvider):
29
30
  self.type = "ctx"
30
31
 
31
32
  def attach(self, window):
33
+ """
34
+ Attach window
35
+
36
+ :param window: Window instance
37
+ """
32
38
  self.window = window
33
39
  self.storage.attach(window)
34
40
 
@@ -68,14 +74,14 @@ class DbSqliteProvider(BaseProvider):
68
74
 
69
75
  def get_meta(
70
76
  self,
71
- search_string: str = None,
72
- order_by: str = None,
73
- order_direction: str = None,
74
- limit: int = None,
75
- offset: int = None,
76
- filters: dict = None,
77
+ search_string: Optional[str] = None,
78
+ order_by: Optional[str] = None,
79
+ order_direction: Optional[str] = None,
80
+ limit: Optional[int] = None,
81
+ offset: Optional[int] = None,
82
+ filters: Optional[dict] = None,
77
83
  search_content: bool = False,
78
- ) -> dict:
84
+ ) -> Dict[int, CtxMeta]:
79
85
  """
80
86
  Return dict of ctx meta, TODO: add order, limit, offset, etc.
81
87
 
@@ -102,7 +108,7 @@ class DbSqliteProvider(BaseProvider):
102
108
  search_content=search_content,
103
109
  )
104
110
 
105
- def get_meta_indexed(self) -> dict:
111
+ def get_meta_indexed(self) -> Dict[int, CtxMeta]:
106
112
  """
107
113
  Return dict of ctx meta indexed by ID
108
114
 
@@ -118,7 +124,7 @@ class DbSqliteProvider(BaseProvider):
118
124
  """
119
125
  return self.storage.get_last_meta_id()
120
126
 
121
- def get_item_by_id(self, id: int) -> CtxItem:
127
+ def get_item_by_id(self, id: int) -> Optional[CtxItem]:
122
128
  """
123
129
  Get ctx item by ID
124
130
 
@@ -127,7 +133,7 @@ class DbSqliteProvider(BaseProvider):
127
133
  """
128
134
  return self.storage.get_item_by_id(id)
129
135
 
130
- def load(self, id: int) -> list:
136
+ def load(self, id: int) -> List[CtxItem]:
131
137
  """
132
138
  Load items for ctx ID
133
139
 
@@ -137,13 +143,14 @@ class DbSqliteProvider(BaseProvider):
137
143
  return self.storage.get_items(id)
138
144
 
139
145
  def get_ctx_count_by_day(
140
- self, year: int,
141
- month: int = None,
142
- day: int = None,
143
- search_string: str = None,
144
- filters: dict = None,
146
+ self,
147
+ year: int,
148
+ month: Optional[int] = None,
149
+ day: Optional[int] = None,
150
+ search_string: Optional[str] = None,
151
+ filters: Optional[dict] = None,
145
152
  search_content: bool = False,
146
- ) -> dict:
153
+ ) -> Dict[str, int]:
147
154
  """
148
155
  Get ctx count by day or by month if only year is provided
149
156
 
@@ -165,13 +172,14 @@ class DbSqliteProvider(BaseProvider):
165
172
  )
166
173
 
167
174
  def get_ctx_labels_count_by_day(
168
- self, year: int,
169
- month: int = None,
170
- day: int = None,
171
- search_string: str = None,
172
- filters: dict = None,
175
+ self,
176
+ year: int,
177
+ month: Optional[int] = None,
178
+ day: Optional[int] = None,
179
+ search_string: Optional[str] = None,
180
+ filters: Optional[dict] = None,
173
181
  search_content: bool = False,
174
- ) -> dict:
182
+ ) -> Dict[str, Dict[int, int]]:
175
183
  """
176
184
  Get ctx labels count by day or by month if only year is provided
177
185
 
@@ -213,7 +221,7 @@ class DbSqliteProvider(BaseProvider):
213
221
  self.storage.update_meta_ts(item.meta_id)
214
222
  return self.storage.update_item(item) is not None
215
223
 
216
- def save(self, id: int, meta: CtxMeta, items: list) -> bool:
224
+ def save(self, id: int, meta: CtxMeta, items: List[CtxItem]) -> bool:
217
225
  """
218
226
  Save ctx
219
227
 
@@ -225,7 +233,7 @@ class DbSqliteProvider(BaseProvider):
225
233
  if self.storage.update_meta(meta):
226
234
  return True # update only meta, items are appended separately
227
235
 
228
- def save_all(self, id: int, meta: CtxMeta, items: list) -> bool:
236
+ def save_all(self, id: int, meta: CtxMeta, items: List[CtxItem]) -> bool:
229
237
  """
230
238
  Save ctx
231
239
 
@@ -255,7 +263,7 @@ class DbSqliteProvider(BaseProvider):
255
263
  """
256
264
  return self.storage.delete_item_by_id(id)
257
265
 
258
- def remove_items_from(self, meta_id: int, item_id: int):
266
+ def remove_items_from(self, meta_id: int, item_id: int) -> bool:
259
267
  """
260
268
  Remove ctx items from meta_id
261
269
 
@@ -328,7 +336,7 @@ class DbSqliteProvider(BaseProvider):
328
336
  """
329
337
  return self.storage.clear_meta_indexed_all()
330
338
 
331
- def get_groups(self) -> dict:
339
+ def get_groups(self) -> Dict[int, CtxGroup]:
332
340
  """
333
341
  Return dict of groups
334
342
 
@@ -336,7 +344,7 @@ class DbSqliteProvider(BaseProvider):
336
344
  """
337
345
  return self.storage.get_groups()
338
346
 
339
- def get_meta_by_id(self, id: int) -> CtxMeta or None:
347
+ def get_meta_by_id(self, id: int) -> Optional[CtxMeta]:
340
348
  """
341
349
  Get meta by ID
342
350
 
@@ -353,15 +361,16 @@ class DbSqliteProvider(BaseProvider):
353
361
  """
354
362
  return self.storage.get_meta_by_root_id_and_preset_id(root_id, preset_id)
355
363
 
356
- def insert_group(self, group: CtxGroup):
364
+ def insert_group(self, group: CtxGroup) -> int:
357
365
  """
358
366
  Insert group
359
367
 
360
368
  :param group: CtxGroup
369
+ :return: group ID
361
370
  """
362
371
  return self.storage.insert_group(group)
363
372
 
364
- def update_group(self, group: CtxGroup):
373
+ def update_group(self, group: CtxGroup) -> bool:
365
374
  """
366
375
  Update group
367
376
 
@@ -369,32 +378,39 @@ class DbSqliteProvider(BaseProvider):
369
378
  """
370
379
  return self.storage.update_group(group)
371
380
 
372
- def remove_group(self, id: int, all: bool = False):
381
+ def remove_group(self, id: int, all: bool = False) -> bool:
373
382
  """
374
383
  Remove group by ID
375
384
 
376
385
  :param id: group ID
377
386
  :param all: remove items
387
+ :return: True if removed
378
388
  """
379
389
  return self.storage.delete_group(id, all=all)
380
390
 
381
- def truncate_groups(self):
382
- """Remove groups"""
391
+ def truncate_groups(self) -> bool:
392
+ """
393
+ Remove groups
394
+
395
+ :return: True if removed
396
+ """
383
397
  return self.storage.truncate_groups()
384
398
 
385
- def update_meta_group_id(self, id: int, group_id: int):
399
+ def update_meta_group_id(self, id: int, group_id: int) -> bool:
386
400
  """
387
401
  Update meta group ID
388
402
 
389
403
  :param id: ctx ID
390
404
  :param group_id: group ID
405
+ :return: True if updated
391
406
  """
392
407
  return self.storage.update_meta_group_id(id, group_id)
393
408
 
394
- def clear_meta(self, id: int):
409
+ def clear_meta(self, id: int) -> bool:
395
410
  """
396
411
  Clear meta by ID
397
412
 
398
413
  :param id: ctx ID
414
+ :return: True if cleared
399
415
  """
400
416
  return self.storage.clear_meta(id)
@@ -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.12.09 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from datetime import datetime
13
13
  import re
14
14
  import time
15
+ from typing import Dict, Optional, Tuple, List
15
16
 
16
17
  from sqlalchemy import text
17
18
 
@@ -46,11 +47,11 @@ class Storage:
46
47
 
47
48
  def prepare_query(
48
49
  self,
49
- search_string: str = None,
50
- filters: dict = None,
50
+ search_string: Optional[str] = None,
51
+ filters: Optional[dict] = None,
51
52
  search_content: bool = False,
52
53
  append_date_ranges: bool = True,
53
- ):
54
+ ) -> Tuple[str, str, dict]:
54
55
  """
55
56
  Prepare query for search_string and filters
56
57
 
@@ -122,14 +123,14 @@ class Storage:
122
123
 
123
124
  def get_meta(
124
125
  self,
125
- search_string: str = None,
126
- order_by: str = None,
127
- order_direction: str = None,
128
- limit: int = None,
129
- offset: int = None,
130
- filters: dict = None,
126
+ search_string: Optional[str] = None,
127
+ order_by: Optional[str] = None,
128
+ order_direction: Optional[str] = None,
129
+ limit: Optional[int] = None,
130
+ offset: Optional[int] = None,
131
+ filters: Optional[dict] = None,
131
132
  search_content: bool = False,
132
- ) -> dict:
133
+ ) -> Dict[int, CtxMeta]:
133
134
  """
134
135
  Return dict with CtxMeta objects, indexed by ID
135
136
 
@@ -169,7 +170,7 @@ class Storage:
169
170
 
170
171
  return items
171
172
 
172
- def get_meta_indexed(self) -> dict:
173
+ def get_meta_indexed(self) -> Dict[int, CtxMeta]:
173
174
  """
174
175
  Return dict with indexed CtxMeta objects, indexed by ID
175
176
 
@@ -189,7 +190,7 @@ class Storage:
189
190
  items[meta.id] = meta
190
191
  return items
191
192
 
192
- def get_item_by_id(self, id: int) -> CtxItem:
193
+ def get_item_by_id(self, id: int) -> Optional[CtxItem]:
193
194
  """
194
195
  Return ctx item by ID
195
196
 
@@ -210,7 +211,11 @@ class Storage:
210
211
  return item
211
212
  return None
212
213
 
213
- def get_meta_by_root_id_and_preset_id(self, root_id: int, preset_id: str) -> dict:
214
+ def get_meta_by_root_id_and_preset_id(
215
+ self,
216
+ root_id: int,
217
+ preset_id: str
218
+ ) -> Dict[int, CtxMeta]:
214
219
  """
215
220
  Return dict with indexed CtxMeta objects, indexed by ID
216
221
 
@@ -233,7 +238,7 @@ class Storage:
233
238
  items[meta.id] = meta
234
239
  return items
235
240
 
236
- def get_meta_by_id(self, id: int) -> CtxMeta or None:
241
+ def get_meta_by_id(self, id: int) -> Optional[CtxMeta]:
237
242
  """
238
243
  Return ctx meta by ID
239
244
 
@@ -269,7 +274,7 @@ class Storage:
269
274
  return int(row.id)
270
275
  return 0
271
276
 
272
- def get_items(self, id: int) -> list:
277
+ def get_items(self, id: int) -> List[CtxItem]:
273
278
  """
274
279
  Return ctx items list by ctx meta ID
275
280
 
@@ -428,7 +433,11 @@ class Storage:
428
433
  conn.execute(stmt)
429
434
  return True
430
435
 
431
- def update_meta_all(self, meta: CtxMeta, items: list) -> bool:
436
+ def update_meta_all(
437
+ self,
438
+ meta: CtxMeta,
439
+ items: List[CtxItem]
440
+ ) -> bool:
432
441
  """
433
442
  Update all, meta and items
434
443
 
@@ -891,12 +900,12 @@ class Storage:
891
900
  def get_ctx_count_by_day(
892
901
  self,
893
902
  year: int,
894
- month: int = None,
895
- day: int = None,
896
- search_string: str = None,
897
- filters: dict = None,
903
+ month: Optional[int] = None,
904
+ day: Optional[int] = None,
905
+ search_string: Optional[str] = None,
906
+ filters: Optional[dict] = None,
898
907
  search_content: bool = False,
899
- ) -> dict:
908
+ ) -> Dict[str, int]:
900
909
  """
901
910
  Return ctx counters by day for given year and month
902
911
 
@@ -987,12 +996,12 @@ class Storage:
987
996
  def get_ctx_labels_count_by_day(
988
997
  self,
989
998
  year: int,
990
- month: int = None,
991
- day: int = None,
992
- search_string: str = None,
993
- filters: dict = None,
999
+ month: Optional[int] = None,
1000
+ day: Optional[int] = None,
1001
+ search_string: Optional[str] = None,
1002
+ filters: Optional[dict] = None,
994
1003
  search_content: bool = False,
995
- ) -> dict:
1004
+ ) -> Dict[str, Dict[int, int]]:
996
1005
  """
997
1006
  Return ctx counters by day for given year and month
998
1007
 
@@ -1116,7 +1125,7 @@ class Storage:
1116
1125
 
1117
1126
  return result_dict
1118
1127
 
1119
- def get_groups(self) -> dict:
1128
+ def get_groups(self) -> Dict[int, CtxGroup]:
1120
1129
  """
1121
1130
  Return dict with CtxGroup objects, indexed by ID
1122
1131
 
@@ -1189,16 +1198,17 @@ class Storage:
1189
1198
  conn.execute(text("DELETE FROM sqlite_sequence WHERE name='ctx_group'"))
1190
1199
  return True
1191
1200
 
1192
- def clear_meta(self, meta_id: int):
1201
+ def clear_meta(self, meta_id: int) -> bool:
1193
1202
  """
1194
1203
  Delete all items with meta ID
1195
1204
 
1196
1205
  :param meta_id: meta ID
1197
- :return:
1206
+ :return: True if cleared
1198
1207
  """
1199
1208
  db = self.window.core.db.get_db()
1200
1209
  with db.begin() as conn:
1201
1210
  conn.execute(text(f"DELETE FROM ctx_item WHERE meta_id = {meta_id}"))
1211
+ return True
1202
1212
 
1203
1213
  def update_group(self, group: CtxGroup) -> bool:
1204
1214
  """
@@ -1258,12 +1268,13 @@ class Storage:
1258
1268
  group.id = result.lastrowid
1259
1269
  return group.id
1260
1270
 
1261
- def update_meta_group_id(self, meta_id: int, group_id: int = None):
1271
+ def update_meta_group_id(self, meta_id: int, group_id: int = None) -> bool:
1262
1272
  """
1263
1273
  Update meta group ID
1264
1274
 
1265
1275
  :param meta_id: ctx meta ID
1266
1276
  :param group_id: ctx group ID
1277
+ :return: True if updated
1267
1278
  """
1268
1279
  db = self.window.core.db.get_db()
1269
1280
  stmt = text("""
@@ -6,18 +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: 2024.11.26 19:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
13
13
  import re
14
+
14
15
  from datetime import datetime, timedelta
16
+ from typing import List, Tuple, Any, Dict
15
17
 
16
18
  from pygpt_net.item.ctx import CtxMeta, CtxItem, CtxGroup
17
19
  from pygpt_net.utils import unpack_var
18
20
 
19
21
 
20
- def search_by_date_string(search_string: str) -> list:
22
+ def search_by_date_string(search_string: str) -> List[Tuple[Any, Any]]:
21
23
  """
22
24
  Prepare date ranges from search string if @date() syntax is used
23
25
 
@@ -64,7 +66,7 @@ def search_by_date_string(search_string: str) -> list:
64
66
  return date_ranges
65
67
 
66
68
 
67
- def get_month_start_end_timestamps(year: int, month: int) -> (int, int):
69
+ def get_month_start_end_timestamps(year: int, month: int) -> Tuple[int, int]:
68
70
  """
69
71
  Get start and end timestamps for given month
70
72
 
@@ -82,7 +84,7 @@ def get_month_start_end_timestamps(year: int, month: int) -> (int, int):
82
84
  return start_timestamp, end_timestamp
83
85
 
84
86
 
85
- def get_year_start_end_timestamps(year: int) -> (int, int):
87
+ def get_year_start_end_timestamps(year: int) -> Tuple[int, int]:
86
88
  """
87
89
  Get start and end timestamps for given year
88
90
 
@@ -96,7 +98,7 @@ def get_year_start_end_timestamps(year: int) -> (int, int):
96
98
  return start_timestamp, end_timestamp
97
99
 
98
100
 
99
- def pack_item_value(value: any) -> str:
101
+ def pack_item_value(value: Any) -> str:
100
102
  """
101
103
  Pack item value to JSON
102
104
 
@@ -108,7 +110,7 @@ def pack_item_value(value: any) -> str:
108
110
  return value
109
111
 
110
112
 
111
- def unpack_item_value(value: any) -> any:
113
+ def unpack_item_value(value: Any) -> Any:
112
114
  """
113
115
  Unpack item value from JSON
114
116
 
@@ -123,7 +125,7 @@ def unpack_item_value(value: any) -> any:
123
125
  return value
124
126
 
125
127
 
126
- def unpack_item(item: CtxItem, row: dict) -> CtxItem:
128
+ def unpack_item(item: CtxItem, row: Dict[str, Any]) -> CtxItem:
127
129
  """
128
130
  Unpack context item from DB row
129
131
 
@@ -183,7 +185,7 @@ def unpack_item(item: CtxItem, row: dict) -> CtxItem:
183
185
  return item
184
186
 
185
187
 
186
- def unpack_meta(meta: CtxMeta, row: dict) -> CtxMeta:
188
+ def unpack_meta(meta: CtxMeta, row: Dict[str, Any]) -> CtxMeta:
187
189
  """
188
190
  Unpack context meta data from DB row
189
191
 
@@ -222,7 +224,7 @@ def unpack_meta(meta: CtxMeta, row: dict) -> CtxMeta:
222
224
  return meta
223
225
 
224
226
 
225
- def unpack_group(group: CtxGroup, row: dict) -> CtxGroup:
227
+ def unpack_group(group: CtxGroup, row: Dict[str, Any]) -> CtxGroup:
226
228
  """
227
229
  Unpack context group data from DB row
228
230