pygpt-net 2.4.41__py3-none-any.whl → 2.4.43__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 (146) hide show
  1. CHANGELOG.md +13 -0
  2. README.md +142 -70
  3. pygpt_net/CHANGELOG.txt +13 -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/attachment.py +36 -23
  9. pygpt_net/controller/chat/audio.py +2 -2
  10. pygpt_net/controller/config/placeholder.py +15 -1
  11. pygpt_net/controller/ui/mode.py +16 -21
  12. pygpt_net/core/attachments/__init__.py +1 -1
  13. pygpt_net/core/attachments/context.py +10 -8
  14. pygpt_net/core/audio/__init__.py +4 -1
  15. pygpt_net/core/audio/whisper.py +37 -0
  16. pygpt_net/core/bridge/worker.py +2 -2
  17. pygpt_net/core/db/__init__.py +2 -1
  18. pygpt_net/core/debug/events.py +22 -10
  19. pygpt_net/core/debug/tabs.py +6 -3
  20. pygpt_net/core/history.py +3 -2
  21. pygpt_net/core/idx/__init__.py +16 -4
  22. pygpt_net/core/idx/chat.py +15 -5
  23. pygpt_net/core/idx/indexing.py +24 -8
  24. pygpt_net/core/installer.py +2 -4
  25. pygpt_net/core/models.py +62 -17
  26. pygpt_net/core/modes.py +11 -13
  27. pygpt_net/core/notepad.py +4 -4
  28. pygpt_net/core/plugins.py +27 -16
  29. pygpt_net/core/presets.py +20 -9
  30. pygpt_net/core/profile.py +11 -3
  31. pygpt_net/core/render/web/parser.py +3 -1
  32. pygpt_net/core/settings.py +5 -5
  33. pygpt_net/core/tabs/tab.py +10 -2
  34. pygpt_net/core/tokens.py +8 -6
  35. pygpt_net/core/web/__init__.py +105 -0
  36. pygpt_net/core/{web.py → web/helpers.py} +93 -67
  37. pygpt_net/data/config/config.json +3 -3
  38. pygpt_net/data/config/models.json +3 -3
  39. pygpt_net/data/config/modes.json +3 -3
  40. pygpt_net/data/locale/locale.en.ini +1 -0
  41. pygpt_net/data/locale/plugin.cmd_web.en.ini +2 -0
  42. pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
  43. pygpt_net/item/ctx.py +66 -3
  44. pygpt_net/migrations/Version20241215110000.py +25 -0
  45. pygpt_net/migrations/__init__.py +3 -1
  46. pygpt_net/plugin/agent/__init__.py +7 -2
  47. pygpt_net/plugin/audio_output/__init__.py +6 -1
  48. pygpt_net/plugin/base/plugin.py +58 -26
  49. pygpt_net/plugin/base/worker.py +20 -17
  50. pygpt_net/plugin/cmd_history/config.py +2 -2
  51. pygpt_net/plugin/cmd_web/__init__.py +3 -4
  52. pygpt_net/plugin/cmd_web/config.py +71 -3
  53. pygpt_net/plugin/cmd_web/websearch.py +20 -12
  54. pygpt_net/plugin/cmd_web/worker.py +67 -4
  55. pygpt_net/plugin/idx_llama_index/config.py +3 -3
  56. pygpt_net/plugin/mailer/__init__.py +123 -0
  57. pygpt_net/plugin/mailer/config.py +149 -0
  58. pygpt_net/plugin/mailer/runner.py +285 -0
  59. pygpt_net/plugin/mailer/worker.py +123 -0
  60. pygpt_net/provider/agents/base.py +5 -2
  61. pygpt_net/provider/agents/openai.py +4 -2
  62. pygpt_net/provider/agents/openai_assistant.py +4 -2
  63. pygpt_net/provider/agents/planner.py +4 -2
  64. pygpt_net/provider/agents/react.py +4 -2
  65. pygpt_net/provider/audio_output/openai_tts.py +5 -11
  66. pygpt_net/provider/core/assistant/base.py +5 -3
  67. pygpt_net/provider/core/assistant/json_file.py +8 -5
  68. pygpt_net/provider/core/assistant_file/base.py +4 -3
  69. pygpt_net/provider/core/assistant_file/db_sqlite/__init__.py +4 -3
  70. pygpt_net/provider/core/assistant_file/db_sqlite/storage.py +3 -2
  71. pygpt_net/provider/core/assistant_store/base.py +6 -4
  72. pygpt_net/provider/core/assistant_store/db_sqlite/__init__.py +5 -4
  73. pygpt_net/provider/core/assistant_store/db_sqlite/storage.py +5 -3
  74. pygpt_net/provider/core/attachment/base.py +5 -3
  75. pygpt_net/provider/core/attachment/json_file.py +4 -3
  76. pygpt_net/provider/core/calendar/base.py +5 -3
  77. pygpt_net/provider/core/calendar/db_sqlite/__init__.py +6 -5
  78. pygpt_net/provider/core/calendar/db_sqlite/storage.py +5 -4
  79. pygpt_net/provider/core/config/base.py +8 -6
  80. pygpt_net/provider/core/config/json_file.py +9 -7
  81. pygpt_net/provider/core/ctx/base.py +27 -25
  82. pygpt_net/provider/core/ctx/db_sqlite/__init__.py +51 -35
  83. pygpt_net/provider/core/ctx/db_sqlite/storage.py +92 -38
  84. pygpt_net/provider/core/ctx/db_sqlite/utils.py +37 -11
  85. pygpt_net/provider/core/index/base.py +129 -23
  86. pygpt_net/provider/core/index/db_sqlite/__init__.py +130 -23
  87. pygpt_net/provider/core/index/db_sqlite/storage.py +130 -23
  88. pygpt_net/provider/core/index/db_sqlite/utils.py +4 -2
  89. pygpt_net/provider/core/mode/base.py +5 -3
  90. pygpt_net/provider/core/mode/json_file.py +7 -6
  91. pygpt_net/provider/core/model/base.py +6 -4
  92. pygpt_net/provider/core/model/json_file.py +9 -7
  93. pygpt_net/provider/core/notepad/base.py +5 -3
  94. pygpt_net/provider/core/notepad/db_sqlite/__init__.py +5 -4
  95. pygpt_net/provider/core/notepad/db_sqlite/storage.py +4 -3
  96. pygpt_net/provider/core/plugin_preset/base.py +4 -2
  97. pygpt_net/provider/core/plugin_preset/json_file.py +5 -3
  98. pygpt_net/provider/core/preset/base.py +6 -4
  99. pygpt_net/provider/core/preset/json_file.py +9 -9
  100. pygpt_net/provider/core/prompt/base.py +6 -3
  101. pygpt_net/provider/core/prompt/json_file.py +11 -6
  102. pygpt_net/provider/gpt/assistants.py +15 -6
  103. pygpt_net/provider/gpt/audio.py +5 -5
  104. pygpt_net/provider/gpt/chat.py +7 -5
  105. pygpt_net/provider/gpt/completion.py +8 -4
  106. pygpt_net/provider/gpt/image.py +3 -3
  107. pygpt_net/provider/gpt/store.py +46 -12
  108. pygpt_net/provider/gpt/vision.py +16 -11
  109. pygpt_net/provider/llms/anthropic.py +7 -2
  110. pygpt_net/provider/llms/azure_openai.py +26 -5
  111. pygpt_net/provider/llms/base.py +47 -9
  112. pygpt_net/provider/llms/google.py +7 -2
  113. pygpt_net/provider/llms/hugging_face.py +13 -3
  114. pygpt_net/provider/llms/hugging_face_api.py +18 -4
  115. pygpt_net/provider/llms/local.py +7 -2
  116. pygpt_net/provider/llms/ollama.py +30 -6
  117. pygpt_net/provider/llms/openai.py +32 -6
  118. pygpt_net/provider/vector_stores/__init__.py +45 -14
  119. pygpt_net/provider/vector_stores/base.py +35 -8
  120. pygpt_net/provider/vector_stores/chroma.py +13 -3
  121. pygpt_net/provider/vector_stores/ctx_attachment.py +32 -13
  122. pygpt_net/provider/vector_stores/elasticsearch.py +12 -3
  123. pygpt_net/provider/vector_stores/pinecode.py +12 -3
  124. pygpt_net/provider/vector_stores/redis.py +12 -3
  125. pygpt_net/provider/vector_stores/simple.py +12 -3
  126. pygpt_net/provider/vector_stores/temp.py +16 -4
  127. pygpt_net/provider/web/base.py +10 -3
  128. pygpt_net/provider/web/google_custom_search.py +9 -3
  129. pygpt_net/provider/web/microsoft_bing.py +9 -3
  130. pygpt_net/tools/__init__.py +13 -5
  131. pygpt_net/tools/audio_transcriber/__init__.py +4 -3
  132. pygpt_net/tools/base.py +15 -8
  133. pygpt_net/tools/code_interpreter/__init__.py +4 -3
  134. pygpt_net/tools/html_canvas/__init__.py +4 -3
  135. pygpt_net/tools/image_viewer/__init__.py +10 -4
  136. pygpt_net/tools/indexer/__init__.py +8 -7
  137. pygpt_net/tools/media_player/__init__.py +4 -3
  138. pygpt_net/tools/text_editor/__init__.py +36 -10
  139. pygpt_net/ui/layout/chat/output.py +2 -2
  140. pygpt_net/ui/layout/ctx/ctx_list.py +1 -1
  141. pygpt_net/ui/menu/audio.py +12 -1
  142. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/METADATA +143 -71
  143. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/RECORD +146 -138
  144. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/LICENSE +0 -0
  145. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/WHEEL +0 -0
  146. {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.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: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
@@ -360,7 +360,7 @@ class Chat:
360
360
  ctx: CtxItem,
361
361
  type: str,
362
362
  url: str,
363
- args: dict,
363
+ args: Dict[str, Any],
364
364
  query: str,
365
365
  model: Optional[ModelItem] = None
366
366
  ) -> str:
@@ -552,7 +552,11 @@ class Chat:
552
552
  ]
553
553
  return ChatPromptTemplate(qa_msgs)
554
554
 
555
- def get_index(self, idx: str, model: ModelItem):
555
+ def get_index(
556
+ self,
557
+ idx: str,
558
+ model: ModelItem
559
+ ):
556
560
  """
557
561
  Get index instance
558
562
 
@@ -573,7 +577,10 @@ class Chat:
573
577
  index = self.storage.get(idx, service_context=service_context) # get index
574
578
  return index, service_context
575
579
 
576
- def get_metadata(self, source_nodes: Optional[list]) -> Dict[str, Any]:
580
+ def get_metadata(
581
+ self,
582
+ source_nodes: Optional[list]
583
+ ) -> Dict[str, Any]:
577
584
  """
578
585
  Get metadata from source nodes
579
586
 
@@ -601,7 +608,10 @@ class Chat:
601
608
  break
602
609
  return metadata
603
610
 
604
- def parse_metadata(self, metadata: Optional[Dict]) -> Dict[str, Any]:
611
+ def parse_metadata(
612
+ self,
613
+ metadata: Optional[Dict]
614
+ ) -> Dict[str, Any]:
605
615
  """
606
616
  Parse metadata
607
617
 
@@ -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: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import datetime
@@ -600,7 +600,10 @@ class Indexing:
600
600
 
601
601
  return indexed, errors
602
602
 
603
- def get_db_data_from_ts(self, updated_ts: int = 0) -> list:
603
+ def get_db_data_from_ts(
604
+ self,
605
+ updated_ts: int = 0
606
+ ) -> List[Document]:
604
607
  """
605
608
  Get data from database from timestamp
606
609
 
@@ -640,7 +643,10 @@ class Indexing:
640
643
  documents.append(doc)
641
644
  return documents
642
645
 
643
- def get_db_meta_ids_from_ts(self, updated_ts: int = 0) -> list:
646
+ def get_db_meta_ids_from_ts(
647
+ self,
648
+ updated_ts: int = 0
649
+ ) -> List[int]:
644
650
  """
645
651
  Get IDs of meta from database from timestamp
646
652
 
@@ -664,7 +670,11 @@ class Indexing:
664
670
  ids.append(data["id"])
665
671
  return ids
666
672
 
667
- def get_db_data_by_id(self, id: int = 0, updated_ts: int = 0) -> list:
673
+ def get_db_data_by_id(
674
+ self,
675
+ id: int = 0,
676
+ updated_ts: int = 0
677
+ ) -> List[Document]:
668
678
  """
669
679
  Get data from database by meta id
670
680
 
@@ -726,7 +736,8 @@ class Indexing:
726
736
  self.window.core.idx.log("Indexing documents from database by meta id: {}".format(id))
727
737
  self.remove_old_meta_id(idx, id)
728
738
  elif from_ts > 0:
729
- self.window.core.idx.log("Indexing documents from database by meta id: {} from timestamp: {}".format(id, from_ts))
739
+ self.window.core.idx.log("Indexing documents from database by meta id: {} from timestamp: {}".
740
+ format(id, from_ts))
730
741
 
731
742
  # get items from database
732
743
  documents = self.get_db_data_by_id(id, from_ts)
@@ -736,7 +747,8 @@ class Indexing:
736
747
 
737
748
  self.index_document(index, d)
738
749
  doc_id = d.id_
739
- self.window.core.idx.log("Inserted ctx DB document: {} / {}, id: {}, metadata: {}".format(n+1, len(documents), d.id_, d.metadata))
750
+ self.window.core.idx.log("Inserted ctx DB document: {} / {}, id: {}, metadata: {}".
751
+ format(n+1, len(documents), d.id_, d.metadata))
740
752
  self.window.core.ctx.idx.set_meta_as_indexed(id, idx, doc_id) # update ctx
741
753
  n += 1
742
754
  except Exception as e:
@@ -850,7 +862,8 @@ class Indexing:
850
862
  idx=idx,
851
863
  doc_id=doc_id,
852
864
  ) # update external index
853
- self.window.core.idx.log("Inserted web document: {} / {}, id: {}, metadata: {}".format(n+1, len(documents), d.id_, d.metadata))
865
+ self.window.core.idx.log("Inserted web document: {} / {}, id: {}, metadata: {}".
866
+ format(n+1, len(documents), d.id_, d.metadata))
854
867
  n += 1
855
868
  except Exception as e:
856
869
  errors.append(str(e))
@@ -1044,7 +1057,10 @@ class Indexing:
1044
1057
  model = self.window.core.models.from_defaults()
1045
1058
 
1046
1059
  service_context = self.window.core.idx.llm.get_service_context(model=model)
1047
- index = self.window.core.idx.storage.get_ctx_idx(index_path, service_context=service_context) # get or create ctx index
1060
+ index = self.window.core.idx.storage.get_ctx_idx(
1061
+ index_path,
1062
+ service_context=service_context
1063
+ ) # get or create ctx index
1048
1064
 
1049
1065
  idx = "tmp:{}".format(index_path) # tmp index id
1050
1066
  self.window.core.idx.log("Indexing to context attachment index: {}...".format(idx))
@@ -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: 2023.12.31 04:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from pathlib import Path
@@ -23,9 +23,7 @@ class Installer:
23
23
  self.window = window
24
24
 
25
25
  def install(self):
26
- """
27
- Install db, config data and directories
28
- """
26
+ """Install db, config data and directories"""
29
27
  try:
30
28
  # create user config directory
31
29
  path = Path(self.window.core.config.path)
pygpt_net/core/models.py CHANGED
@@ -6,11 +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.14 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
13
- from typing import Optional
13
+ from typing import Optional, List, Dict
14
14
 
15
15
  from packaging.version import Version
16
16
 
@@ -92,7 +92,7 @@ class Models:
92
92
  if key in self.items:
93
93
  return self.items[key]
94
94
 
95
- def get_ids(self) -> list:
95
+ def get_ids(self) -> List[str]:
96
96
  """
97
97
  Return models ids
98
98
 
@@ -118,7 +118,11 @@ class Models:
118
118
  """
119
119
  return model in self.items
120
120
 
121
- def is_allowed(self, model: str, mode: str) -> bool:
121
+ def is_allowed(
122
+ self,
123
+ model: str,
124
+ mode: str
125
+ ) -> bool:
122
126
  """
123
127
  Check if model is allowed for mode
124
128
 
@@ -130,7 +134,10 @@ class Models:
130
134
  return mode in self.items[model].mode
131
135
  return False
132
136
 
133
- def get_id(self, key: str) -> str:
137
+ def get_id(
138
+ self,
139
+ key: str
140
+ ) -> str:
134
141
  """
135
142
  Return model internal ID
136
143
 
@@ -140,7 +147,11 @@ class Models:
140
147
  if key in self.items:
141
148
  return self.items[key].id
142
149
 
143
- def get_by_idx(self, idx: int, mode: str) -> str:
150
+ def get_by_idx(
151
+ self,
152
+ idx: int,
153
+ mode: str
154
+ ) -> str:
144
155
  """
145
156
  Return model by index
146
157
 
@@ -151,7 +162,10 @@ class Models:
151
162
  items = self.get_by_mode(mode)
152
163
  return list(items.keys())[idx]
153
164
 
154
- def get_by_mode(self, mode: str) -> dict:
165
+ def get_by_mode(
166
+ self,
167
+ mode: str
168
+ ) -> Dict[str, ModelItem]:
155
169
  """
156
170
  Return models for mode
157
171
 
@@ -164,7 +178,11 @@ class Models:
164
178
  items[key] = self.items[key]
165
179
  return items
166
180
 
167
- def get_next(self, model: str, mode: str) -> str:
181
+ def get_next(
182
+ self,
183
+ model: str,
184
+ mode: str
185
+ ) -> str:
168
186
  """
169
187
  Return next model
170
188
 
@@ -179,7 +197,11 @@ class Models:
179
197
  return keys[idx + 1]
180
198
  return keys[0]
181
199
 
182
- def get_prev(self, model: str, mode: str) -> str:
200
+ def get_prev(
201
+ self,
202
+ model: str,
203
+ mode: str
204
+ ) -> str:
183
205
  """
184
206
  Return previous model
185
207
 
@@ -218,7 +240,7 @@ class Models:
218
240
  self.items[id] = model
219
241
  return model
220
242
 
221
- def get_all(self) -> dict:
243
+ def get_all(self) -> Dict[str, ModelItem]:
222
244
  """
223
245
  Return all models
224
246
 
@@ -248,7 +270,11 @@ class Models:
248
270
  if model in self.items:
249
271
  del self.items[model]
250
272
 
251
- def has_model(self, mode: str, model: str) -> bool:
273
+ def has_model(
274
+ self,
275
+ mode: str,
276
+ model: str
277
+ ) -> bool:
252
278
  """
253
279
  Check if model exists for mode
254
280
 
@@ -296,8 +322,15 @@ class Models:
296
322
  return self.items[model].ctx
297
323
  return 4096
298
324
 
299
- def restore_default(self, model: Optional[str] = None):
300
- """Restore default models"""
325
+ def restore_default(
326
+ self,
327
+ model: Optional[str] = None
328
+ ):
329
+ """
330
+ Restore default models
331
+
332
+ :param model: model name
333
+ """
301
334
  # restore all models
302
335
  if model is None:
303
336
  self.load_base()
@@ -308,8 +341,12 @@ class Models:
308
341
  if model in items:
309
342
  self.items[model] = items[model]
310
343
 
311
- def get_base(self) -> dict:
312
- """Get base models"""
344
+ def get_base(self) -> Dict[str, ModelItem]:
345
+ """
346
+ Get base models
347
+
348
+ :return: base models
349
+ """
313
350
  return self.provider.load_base()
314
351
 
315
352
  def load_base(self):
@@ -330,7 +367,11 @@ class Models:
330
367
  """Save models"""
331
368
  self.provider.save(self.items)
332
369
 
333
- def get_supported_mode(self, model: ModelItem, mode: str) -> str:
370
+ def get_supported_mode(
371
+ self,
372
+ model: ModelItem,
373
+ mode: str
374
+ ) -> str:
334
375
  """
335
376
  Get supported mode
336
377
 
@@ -353,5 +394,9 @@ class Models:
353
394
  return mode
354
395
 
355
396
  def get_version(self) -> str:
356
- """Get config version"""
397
+ """
398
+ Get config version
399
+
400
+ :return: config version
401
+ """
357
402
  return self.provider.get_version()
pygpt_net/core/modes.py CHANGED
@@ -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.11.26 19:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ from typing import Dict, List
13
+
12
14
  from pygpt_net.provider.core.mode.json_file import JsonFileProvider
13
15
  from pygpt_net.core.types import (
14
16
  MODE_AGENT,
@@ -51,7 +53,7 @@ class Modes:
51
53
  ]
52
54
  self.items = {}
53
55
 
54
- def get_by_idx(self, idx):
56
+ def get_by_idx(self, idx) -> str:
55
57
  """
56
58
  Return mode by index
57
59
 
@@ -61,7 +63,7 @@ class Modes:
61
63
  modes = self.get_all()
62
64
  return list(modes.keys())[idx]
63
65
 
64
- def get_idx_by_name(self, name):
66
+ def get_idx_by_name(self, name) -> int:
65
67
  """
66
68
  Return mode index by name
67
69
 
@@ -71,7 +73,7 @@ class Modes:
71
73
  modes = self.get_all()
72
74
  return list(modes.keys()).index(name)
73
75
 
74
- def get_all(self):
76
+ def get_all(self) -> Dict[str, List[str]]:
75
77
  """
76
78
  Return modes
77
79
 
@@ -79,7 +81,7 @@ class Modes:
79
81
  """
80
82
  return self.items
81
83
 
82
- def get_default(self):
84
+ def get_default(self) -> str:
83
85
  """
84
86
  Return default mode name
85
87
 
@@ -89,7 +91,7 @@ class Modes:
89
91
  if self.items[id].default:
90
92
  return id
91
93
 
92
- def get_next(self, mode: str):
94
+ def get_next(self, mode: str) -> str:
93
95
  """
94
96
  Return next mode
95
97
 
@@ -103,7 +105,7 @@ class Modes:
103
105
  return keys[idx + 1]
104
106
  return keys[0]
105
107
 
106
- def get_prev(self, mode: str):
108
+ def get_prev(self, mode: str) -> str:
107
109
  """
108
110
  Return previous mode
109
111
 
@@ -118,13 +120,9 @@ class Modes:
118
120
  return keys[-1]
119
121
 
120
122
  def load(self):
121
- """
122
- Load modes
123
- """
123
+ """Load modes"""
124
124
  self.items = self.provider.load()
125
125
 
126
126
  def save(self):
127
- """
128
- Save modes
129
- """
127
+ """Save modes"""
130
128
  self.provider.save(self.items)
pygpt_net/core/notepad.py CHANGED
@@ -6,12 +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.12.14 00:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import datetime
13
13
  import uuid
14
- from typing import Optional
14
+ from typing import Optional, Dict
15
15
 
16
16
  from packaging.version import Version
17
17
 
@@ -61,7 +61,7 @@ class Notepad:
61
61
  return self.items[idx]
62
62
  return None
63
63
 
64
- def get_all(self) -> dict:
64
+ def get_all(self) -> Dict[int, NotepadItem]:
65
65
  """
66
66
  Get all notepads
67
67
 
@@ -137,7 +137,7 @@ class Notepad:
137
137
  """Save all notepads"""
138
138
  self.provider.save_all(self.items)
139
139
 
140
- def import_from_db(self) -> Optional[dict]:
140
+ def import_from_db(self) -> Optional[Dict[int, dict]]:
141
141
  """
142
142
  Import notepad tabs from database
143
143
 
pygpt_net/core/plugins.py CHANGED
@@ -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: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
@@ -49,7 +49,7 @@ class Plugins:
49
49
  """
50
50
  return id in self.plugins
51
51
 
52
- def all(self) -> dict:
52
+ def all(self) -> Dict[str, BasePlugin]:
53
53
  """
54
54
  Get all plugins
55
55
 
@@ -57,7 +57,7 @@ class Plugins:
57
57
  """
58
58
  return self.plugins
59
59
 
60
- def get_ids(self) -> list:
60
+ def get_ids(self) -> List[str]:
61
61
  """
62
62
  Get all plugins ids
63
63
 
@@ -76,7 +76,7 @@ class Plugins:
76
76
  return self.plugins[id]
77
77
  return None
78
78
 
79
- def get_option(self, id: str, key: str) -> any:
79
+ def get_option(self, id: str, key: str) -> Any:
80
80
  """
81
81
  Get plugin option
82
82
 
@@ -172,7 +172,7 @@ class Plugins:
172
172
 
173
173
  def enable(self, id: str):
174
174
  """
175
- Enable plugin
175
+ Enable plugin by ID
176
176
 
177
177
  :param id: plugin id
178
178
  """
@@ -183,7 +183,7 @@ class Plugins:
183
183
 
184
184
  def disable(self, id: str):
185
185
  """
186
- Disable plugin
186
+ Disable plugin by ID
187
187
 
188
188
  :param id: plugin id
189
189
  """
@@ -318,7 +318,7 @@ class Plugins:
318
318
  """
319
319
  return id in self.presets
320
320
 
321
- def get_preset(self, id: str) -> dict:
321
+ def get_preset(self, id: str) -> Dict[str, Any]:
322
322
  """
323
323
  Get preset by id
324
324
 
@@ -328,7 +328,7 @@ class Plugins:
328
328
  if self.has_preset(id):
329
329
  return self.presets[id]
330
330
 
331
- def set_preset(self, id: str, preset: dict):
331
+ def set_preset(self, id: str, preset: Dict[str, Any]):
332
332
  """
333
333
  Set config value
334
334
 
@@ -337,7 +337,7 @@ class Plugins:
337
337
  """
338
338
  self.presets[id] = preset
339
339
 
340
- def replace_presets(self, presets: dict):
340
+ def replace_presets(self, presets: Dict[str, Any]):
341
341
  """
342
342
  Replace presets
343
343
 
@@ -349,7 +349,7 @@ class Plugins:
349
349
  """Load presets"""
350
350
  self.presets = self.provider.load()
351
351
 
352
- def get_presets(self) -> dict:
352
+ def get_presets(self) -> Dict[str, Any]:
353
353
  """
354
354
  Return all presets
355
355
 
@@ -357,7 +357,11 @@ class Plugins:
357
357
  """
358
358
  return self.presets
359
359
 
360
- def reset_options(self, plugin_id: str, keys: List[str]):
360
+ def reset_options(
361
+ self,
362
+ plugin_id: str,
363
+ keys: List[str]
364
+ ):
361
365
  """
362
366
  Reset plugin options
363
367
 
@@ -408,7 +412,11 @@ class Plugins:
408
412
  self.save_presets()
409
413
  print("[FIX] Removed invalid keys from plugin presets.")
410
414
 
411
- def remove_preset_values(self, plugin_id:str, key: str):
415
+ def remove_preset_values(
416
+ self,
417
+ plugin_id: str,
418
+ key: str
419
+ ):
412
420
  """
413
421
  Update preset value
414
422
 
@@ -431,7 +439,12 @@ class Plugins:
431
439
  if updated:
432
440
  self.save_presets()
433
441
 
434
- def update_preset_values(self, plugin_id: str, key: str, value: Any):
442
+ def update_preset_values(
443
+ self,
444
+ plugin_id: str,
445
+ key: str,
446
+ value: Any
447
+ ):
435
448
  """
436
449
  Update preset value
437
450
 
@@ -471,9 +484,7 @@ class Plugins:
471
484
  self.dump_locale(self.plugins[id], path)
472
485
 
473
486
  def dump_locales(self):
474
- """
475
- Dump all locales
476
- """
487
+ """Dump all locales"""
477
488
  langs = ['en', 'pl']
478
489
  for id in self.plugins:
479
490
  domain = 'plugin.' + id
pygpt_net/core/presets.py CHANGED
@@ -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: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import copy
@@ -193,6 +193,7 @@ class Presets:
193
193
  """
194
194
  if id in self.items:
195
195
  self.items[id].enabled = True
196
+
196
197
  def disable(self, id: str):
197
198
  """
198
199
  Disable preset
@@ -366,7 +367,11 @@ class Presets:
366
367
  self.sort_by_name()
367
368
  return id
368
369
 
369
- def remove(self, id: str, remove_file: bool = True):
370
+ def remove(
371
+ self,
372
+ id: str,
373
+ remove_file: bool = True
374
+ ):
370
375
  """
371
376
  Delete preset
372
377
 
@@ -381,9 +386,7 @@ class Presets:
381
386
  # self.load_presets()
382
387
 
383
388
  def sort_by_name(self):
384
- """
385
- Sort presets by name
386
- """
389
+ """Sort presets by name"""
387
390
  self.items = dict(
388
391
  sorted(
389
392
  self.items.items(),
@@ -408,7 +411,7 @@ class Presets:
408
411
  self.items[preset.filename] = preset
409
412
  self.save(preset.filename)
410
413
 
411
- def get_all(self) -> dict:
414
+ def get_all(self) -> Dict[str, PresetItem]:
412
415
  """
413
416
  Return all presets
414
417
 
@@ -428,7 +431,7 @@ class Presets:
428
431
  self.items[id] = base[id]
429
432
  self.save(id)
430
433
 
431
- def load_base(self) -> dict:
434
+ def load_base(self) -> Dict[str, PresetItem]:
432
435
  """
433
436
  Load base presets
434
437
 
@@ -460,7 +463,11 @@ class Presets:
460
463
  """Save all presets"""
461
464
  self.provider.save_all(self.items)
462
465
 
463
- def add_expert(self, agent_uuid: str, expert_uuid: str):
466
+ def add_expert(
467
+ self,
468
+ agent_uuid: str,
469
+ expert_uuid: str
470
+ ):
464
471
  """
465
472
  Add expert to agent
466
473
 
@@ -474,7 +481,11 @@ class Presets:
474
481
  agent.experts.append(expert_uuid)
475
482
  self.save(agent.filename)
476
483
 
477
- def remove_expert(self, agent_uuid: str, expert_uuid: str):
484
+ def remove_expert(
485
+ self,
486
+ agent_uuid: str,
487
+ expert_uuid: str
488
+ ):
478
489
  """
479
490
  Remove expert from agent
480
491
  :param agent_uuid: agent uuid
pygpt_net/core/profile.py CHANGED
@@ -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: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2024.12.14 22:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
@@ -120,7 +120,11 @@ class Profile:
120
120
  with open(f, 'w', encoding='utf-8') as f:
121
121
  f.write(json_data)
122
122
 
123
- def add(self, name: str, workdir: str) -> str:
123
+ def add(
124
+ self,
125
+ name: str,
126
+ workdir: str
127
+ ) -> str:
124
128
  """
125
129
  Add new profile
126
130
 
@@ -228,7 +232,11 @@ class Profile:
228
232
  return tmp_dir
229
233
  return self.base_workdir
230
234
 
231
- def append(self, uuid: str, profile: Dict):
235
+ def append(
236
+ self,
237
+ uuid: str,
238
+ profile: Dict
239
+ ):
232
240
  """
233
241
  Append profile
234
242