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.
- CHANGELOG.md +13 -0
- README.md +142 -70
- pygpt_net/CHANGELOG.txt +13 -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/attachment.py +36 -23
- 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/attachments/__init__.py +1 -1
- pygpt_net/core/attachments/context.py +10 -8
- 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/db/__init__.py +2 -1
- 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 +66 -3
- pygpt_net/migrations/Version20241215110000.py +25 -0
- pygpt_net/migrations/__init__.py +3 -1
- 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 +92 -38
- pygpt_net/provider/core/ctx/db_sqlite/utils.py +37 -11
- 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 +32 -13
- 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/layout/ctx/ctx_list.py +1 -1
- pygpt_net/ui/menu/audio.py +12 -1
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/METADATA +143 -71
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/RECORD +146 -138
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.43.dist-info}/entry_points.txt +0 -0
@@ -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
|
|
@@ -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, Dict
|
13
|
+
|
12
14
|
from packaging.version import Version
|
13
15
|
|
14
16
|
from pygpt_net.item.preset import PresetItem
|
@@ -32,16 +34,16 @@ class BaseProvider:
|
|
32
34
|
def create(self, item: PresetItem):
|
33
35
|
pass
|
34
36
|
|
35
|
-
def load(self) ->
|
37
|
+
def load(self) -> Optional[Dict[str, PresetItem]]:
|
36
38
|
pass
|
37
39
|
|
38
|
-
def load_base(self) ->
|
40
|
+
def load_base(self) -> Optional[Dict[str, PresetItem]]:
|
39
41
|
pass
|
40
42
|
|
41
43
|
def save(self, id: str, item: PresetItem):
|
42
44
|
pass
|
43
45
|
|
44
|
-
def save_all(self, items:
|
46
|
+
def save_all(self, items: Dict[str, PresetItem]):
|
45
47
|
pass
|
46
48
|
|
47
49
|
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 Dict, Optional, Any
|
16
|
+
|
15
17
|
from packaging.version import Version
|
16
18
|
|
17
19
|
from pygpt_net.core.types import (
|
@@ -42,9 +44,7 @@ class JsonFileProvider(BaseProvider):
|
|
42
44
|
self.type = "preset"
|
43
45
|
|
44
46
|
def install(self):
|
45
|
-
"""
|
46
|
-
Install provider data
|
47
|
-
"""
|
47
|
+
"""Install provider data"""
|
48
48
|
# install presets
|
49
49
|
presets_dir = self.window.core.config.get_user_dir('presets')
|
50
50
|
src = os.path.join(self.window.core.config.get_app_path(), 'data', 'config', 'presets')
|
@@ -58,7 +58,7 @@ class JsonFileProvider(BaseProvider):
|
|
58
58
|
if not os.path.exists(dst_file):
|
59
59
|
shutil.copyfile(src_file, dst_file)
|
60
60
|
|
61
|
-
def load(self) ->
|
61
|
+
def load(self) -> Optional[Dict[str, PresetItem]]:
|
62
62
|
"""
|
63
63
|
Load presets from JSON files
|
64
64
|
|
@@ -82,7 +82,7 @@ class JsonFileProvider(BaseProvider):
|
|
82
82
|
|
83
83
|
return items
|
84
84
|
|
85
|
-
def load_base(self) ->
|
85
|
+
def load_base(self) -> Optional[Dict[str, PresetItem]]:
|
86
86
|
"""
|
87
87
|
Load base presets from JSON files
|
88
88
|
|
@@ -126,7 +126,7 @@ class JsonFileProvider(BaseProvider):
|
|
126
126
|
except Exception as e:
|
127
127
|
self.window.core.debug.log(e)
|
128
128
|
|
129
|
-
def save_all(self, items:
|
129
|
+
def save_all(self, items: Dict[str, PresetItem]):
|
130
130
|
"""
|
131
131
|
Save all presets to JSON files
|
132
132
|
|
@@ -171,7 +171,7 @@ class JsonFileProvider(BaseProvider):
|
|
171
171
|
return self.patcher.execute(version)
|
172
172
|
|
173
173
|
@staticmethod
|
174
|
-
def serialize(item: PresetItem) ->
|
174
|
+
def serialize(item: PresetItem) -> Dict[str, Any]:
|
175
175
|
"""
|
176
176
|
Serialize item to dict
|
177
177
|
|
@@ -207,7 +207,7 @@ class JsonFileProvider(BaseProvider):
|
|
207
207
|
}
|
208
208
|
|
209
209
|
@staticmethod
|
210
|
-
def deserialize(data:
|
210
|
+
def deserialize(data: Dict[str, Any], item: PresetItem):
|
211
211
|
"""
|
212
212
|
Deserialize item from dict
|
213
213
|
|
@@ -6,12 +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:
|
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
|
17
|
+
from pygpt_net.item.prompt import PromptItem
|
15
18
|
|
16
19
|
|
17
20
|
class BaseProvider:
|
@@ -32,10 +35,10 @@ class BaseProvider:
|
|
32
35
|
def create(self, attachment: AttachmentItem) -> str:
|
33
36
|
pass
|
34
37
|
|
35
|
-
def load(self) ->
|
38
|
+
def load(self) -> Dict[str, PromptItem]:
|
36
39
|
pass
|
37
40
|
|
38
|
-
def save(self, items:
|
41
|
+
def save(self, items: Dict[str, PromptItem]):
|
39
42
|
pass
|
40
43
|
|
41
44
|
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.
|
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
|
prompt.id = self.create_id()
|
47
48
|
return prompt.id
|
48
49
|
|
49
|
-
def load(self) ->
|
50
|
+
def load(self) -> Dict[str, PromptItem]:
|
50
51
|
"""
|
51
52
|
Load prompts from file
|
52
53
|
|
@@ -73,7 +74,7 @@ class JsonFileProvider(BaseProvider):
|
|
73
74
|
|
74
75
|
return items
|
75
76
|
|
76
|
-
def save(self, items:
|
77
|
+
def save(self, items: Dict[str, PromptItem]):
|
77
78
|
"""
|
78
79
|
Save prompts to file
|
79
80
|
"""
|
@@ -108,7 +109,11 @@ class JsonFileProvider(BaseProvider):
|
|
108
109
|
pass
|
109
110
|
|
110
111
|
def truncate(self, mode: str):
|
111
|
-
"""
|
112
|
+
"""
|
113
|
+
Delete all
|
114
|
+
|
115
|
+
:param mode: mode
|
116
|
+
"""
|
112
117
|
path = os.path.join(self.window.core.config.path, self.config_file)
|
113
118
|
data = {'__meta__': self.window.core.config.append_meta(), 'items': {}}
|
114
119
|
try:
|
@@ -128,7 +133,7 @@ class JsonFileProvider(BaseProvider):
|
|
128
133
|
return False
|
129
134
|
|
130
135
|
@staticmethod
|
131
|
-
def serialize(prompt: PromptItem) ->
|
136
|
+
def serialize(prompt: PromptItem) -> Dict[str, str]:
|
132
137
|
"""
|
133
138
|
Serialize item to dict
|
134
139
|
|
@@ -141,7 +146,7 @@ class JsonFileProvider(BaseProvider):
|
|
141
146
|
}
|
142
147
|
|
143
148
|
@staticmethod
|
144
|
-
def deserialize(data:
|
149
|
+
def deserialize(data: Dict[str, str], prompt: PromptItem):
|
145
150
|
"""
|
146
151
|
Deserialize item from dict
|
147
152
|
|
@@ -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
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
|
-
from typing import Optional
|
13
|
+
from typing import Optional, List, Dict
|
14
14
|
|
15
15
|
from pygpt_net.item.assistant import AssistantItem
|
16
16
|
from pygpt_net.item.ctx import CtxItem
|
@@ -38,7 +38,11 @@ class Assistants:
|
|
38
38
|
"""
|
39
39
|
return self.window.core.gpt.get_client()
|
40
40
|
|
41
|
-
def log(
|
41
|
+
def log(
|
42
|
+
self,
|
43
|
+
msg: str,
|
44
|
+
callback: Optional[callable] = None
|
45
|
+
):
|
42
46
|
"""
|
43
47
|
Log message
|
44
48
|
|
@@ -141,7 +145,12 @@ class Assistants:
|
|
141
145
|
thread_messages = client.beta.threads.messages.list(thread_id)
|
142
146
|
return thread_messages.data
|
143
147
|
|
144
|
-
def msg_send(
|
148
|
+
def msg_send(
|
149
|
+
self,
|
150
|
+
id: str,
|
151
|
+
text: str,
|
152
|
+
file_ids: Optional[list] = None
|
153
|
+
):
|
145
154
|
"""
|
146
155
|
Send message to thread
|
147
156
|
|
@@ -176,7 +185,7 @@ class Assistants:
|
|
176
185
|
if message is not None:
|
177
186
|
return message
|
178
187
|
|
179
|
-
def get_tools(self, assistant: AssistantItem) ->
|
188
|
+
def get_tools(self, assistant: AssistantItem) -> List[dict]:
|
180
189
|
"""
|
181
190
|
Get assistant tools
|
182
191
|
|
@@ -208,7 +217,7 @@ class Assistants:
|
|
208
217
|
)
|
209
218
|
return tools
|
210
219
|
|
211
|
-
def get_tool_resources(self, assistant: AssistantItem) -> dict:
|
220
|
+
def get_tool_resources(self, assistant: AssistantItem) -> Dict[str, dict]:
|
212
221
|
"""
|
213
222
|
Get assistant tool resources
|
214
223
|
|
pygpt_net/provider/gpt/audio.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
|
9
|
+
# Updated Date: 2024.12.14 18:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import base64
|
13
|
-
from typing import Optional
|
13
|
+
from typing import Optional, Union, List, Dict, Any
|
14
14
|
|
15
15
|
from pygpt_net.core.bridge.context import MultimodalContext
|
16
16
|
|
@@ -26,11 +26,11 @@ class Audio:
|
|
26
26
|
|
27
27
|
def build_content(
|
28
28
|
self,
|
29
|
-
content,
|
29
|
+
content: Optional[Union[str, list]] = None,
|
30
30
|
multimodal_ctx: Optional[MultimodalContext] = None,
|
31
|
-
) ->
|
31
|
+
) -> List[Dict[str, Any]]:
|
32
32
|
"""
|
33
|
-
Build audio content
|
33
|
+
Build audio content from multimodal context
|
34
34
|
|
35
35
|
:param content: previous content or input prompt
|
36
36
|
:param multimodal_ctx: multimodal context
|
pygpt_net/provider/gpt/chat.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
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
13
|
import time
|
14
|
-
from typing import Optional
|
14
|
+
from typing import Optional, Dict, Any, List
|
15
15
|
|
16
16
|
from pygpt_net.core.types import (
|
17
17
|
MODE_CHAT,
|
@@ -23,6 +23,8 @@ from pygpt_net.item.ctx import CtxItem
|
|
23
23
|
from pygpt_net.item.model import ModelItem
|
24
24
|
|
25
25
|
from .utils import sanitize_name
|
26
|
+
from ...item.attachment import AttachmentItem
|
27
|
+
|
26
28
|
|
27
29
|
class Chat:
|
28
30
|
def __init__(self, window=None):
|
@@ -37,7 +39,7 @@ class Chat:
|
|
37
39
|
def send(
|
38
40
|
self,
|
39
41
|
context: BridgeContext,
|
40
|
-
extra: Optional[
|
42
|
+
extra: Optional[Dict[str, Any]] = None
|
41
43
|
):
|
42
44
|
"""
|
43
45
|
Call OpenAI API for chat
|
@@ -152,8 +154,8 @@ class Chat:
|
|
152
154
|
prompt: str,
|
153
155
|
system_prompt: str,
|
154
156
|
model: ModelItem,
|
155
|
-
history: Optional[
|
156
|
-
attachments: Optional[
|
157
|
+
history: Optional[List[CtxItem]] = None,
|
158
|
+
attachments: Optional[Dict[str, AttachmentItem]] = None,
|
157
159
|
ai_name: Optional[str] = None,
|
158
160
|
user_name: Optional[str] = None,
|
159
161
|
multimodal_ctx: Optional[MultimodalContext] = None,
|
@@ -6,10 +6,10 @@
|
|
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
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
-
from typing import Optional
|
12
|
+
from typing import Optional, Dict, Any, List
|
13
13
|
|
14
14
|
from pygpt_net.core.types import (
|
15
15
|
MODE_COMPLETION,
|
@@ -29,7 +29,11 @@ class Completion:
|
|
29
29
|
self.window = window
|
30
30
|
self.input_tokens = 0
|
31
31
|
|
32
|
-
def send(
|
32
|
+
def send(
|
33
|
+
self,
|
34
|
+
context: BridgeContext,
|
35
|
+
extra: Optional[Dict[str, Any]] = None
|
36
|
+
):
|
33
37
|
"""
|
34
38
|
Call OpenAI API for completion
|
35
39
|
|
@@ -100,7 +104,7 @@ class Completion:
|
|
100
104
|
prompt: str,
|
101
105
|
system_prompt: str,
|
102
106
|
model: ModelItem,
|
103
|
-
history: Optional[
|
107
|
+
history: Optional[List[CtxItem]] = None,
|
104
108
|
ai_name: Optional[str] = None,
|
105
109
|
user_name: Optional[str] = None,
|
106
110
|
) -> str:
|