pygpt-net 2.4.41__py3-none-any.whl → 2.4.44__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 +19 -0
- README.md +151 -71
- pygpt_net/CHANGELOG.txt +19 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +3 -1
- pygpt_net/controller/attachment.py +31 -3
- pygpt_net/controller/audio/__init__.py +2 -2
- pygpt_net/controller/camera.py +1 -10
- pygpt_net/controller/chat/attachment.py +37 -36
- pygpt_net/controller/chat/audio.py +2 -2
- pygpt_net/controller/config/placeholder.py +20 -4
- pygpt_net/controller/idx/common.py +7 -3
- pygpt_net/controller/ui/mode.py +16 -21
- pygpt_net/core/attachments/__init__.py +7 -2
- pygpt_net/core/attachments/context.py +52 -34
- 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/attachments.py +1 -0
- 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 +23 -6
- pygpt_net/core/idx/chat.py +15 -5
- pygpt_net/core/idx/indexing.py +47 -14
- pygpt_net/core/idx/ui/__init__.py +22 -0
- pygpt_net/core/idx/ui/loaders.py +217 -0
- 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 +4 -4
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/config/settings.json +5 -5
- pygpt_net/data/locale/locale.de.ini +3 -3
- pygpt_net/data/locale/locale.en.ini +12 -9
- pygpt_net/data/locale/locale.es.ini +3 -3
- pygpt_net/data/locale/locale.fr.ini +3 -3
- pygpt_net/data/locale/locale.it.ini +3 -3
- pygpt_net/data/locale/locale.pl.ini +3 -3
- pygpt_net/data/locale/locale.uk.ini +3 -3
- pygpt_net/data/locale/locale.zh.ini +3 -3
- pygpt_net/data/locale/plugin.cmd_web.en.ini +2 -0
- pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
- pygpt_net/item/attachment.py +5 -1
- pygpt_net/item/ctx.py +111 -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_files/__init__.py +3 -2
- 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 +7 -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/config/patch.py +6 -0
- 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/loaders/base.py +14 -0
- pygpt_net/provider/loaders/hub/yt/base.py +5 -0
- pygpt_net/provider/loaders/web_database.py +13 -5
- pygpt_net/provider/loaders/web_github_issues.py +5 -1
- pygpt_net/provider/loaders/web_google_calendar.py +9 -1
- pygpt_net/provider/loaders/web_google_docs.py +6 -1
- pygpt_net/provider/loaders/web_google_drive.py +10 -1
- pygpt_net/provider/loaders/web_google_gmail.py +2 -1
- pygpt_net/provider/loaders/web_google_keep.py +5 -1
- pygpt_net/provider/loaders/web_google_sheets.py +5 -1
- pygpt_net/provider/loaders/web_microsoft_onedrive.py +15 -1
- pygpt_net/provider/loaders/web_page.py +4 -2
- pygpt_net/provider/loaders/web_rss.py +2 -1
- pygpt_net/provider/loaders/web_sitemap.py +2 -1
- pygpt_net/provider/loaders/web_twitter.py +4 -2
- pygpt_net/provider/loaders/web_yt.py +17 -2
- 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 +15 -46
- pygpt_net/tools/indexer/ui/web.py +20 -78
- 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 +86 -18
- pygpt_net/ui/menu/audio.py +12 -1
- pygpt_net/ui/widget/dialog/url.py +151 -14
- pygpt_net/ui/widget/element/group.py +15 -2
- pygpt_net/ui/widget/lists/context.py +23 -9
- pygpt_net/utils.py +1 -1
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.44.dist-info}/METADATA +152 -72
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.44.dist-info}/RECORD +183 -173
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.44.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.44.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.41.dist-info → pygpt_net-2.4.44.dist-info}/entry_points.txt +0 -0
@@ -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:
|
pygpt_net/provider/gpt/image.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 datetime
|
13
13
|
import os
|
14
|
-
from typing import Optional
|
14
|
+
from typing import Optional, Dict, Any
|
15
15
|
|
16
16
|
import requests
|
17
17
|
|
@@ -36,7 +36,7 @@ class Image:
|
|
36
36
|
def generate(
|
37
37
|
self,
|
38
38
|
context: BridgeContext,
|
39
|
-
extra: Optional[
|
39
|
+
extra: Optional[Dict[str, Any]] = None,
|
40
40
|
sync: bool = True
|
41
41
|
):
|
42
42
|
"""
|
pygpt_net/provider/gpt/store.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 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
13
|
-
from typing import Optional
|
13
|
+
from typing import Optional, List
|
14
14
|
|
15
15
|
from pygpt_net.item.assistant import AssistantStoreItem
|
16
16
|
|
@@ -32,7 +32,11 @@ class Store:
|
|
32
32
|
"""
|
33
33
|
return self.window.core.gpt.get_client()
|
34
34
|
|
35
|
-
def log(
|
35
|
+
def log(
|
36
|
+
self,
|
37
|
+
msg: str,
|
38
|
+
callback: Optional[callable] = None
|
39
|
+
):
|
36
40
|
"""
|
37
41
|
Log message
|
38
42
|
|
@@ -133,7 +137,7 @@ class Store:
|
|
133
137
|
)
|
134
138
|
return items
|
135
139
|
|
136
|
-
def get_files_ids(self) ->
|
140
|
+
def get_files_ids(self) -> List[str]:
|
137
141
|
"""
|
138
142
|
Get all files IDs
|
139
143
|
|
@@ -149,7 +153,10 @@ class Store:
|
|
149
153
|
items.append(id)
|
150
154
|
return items
|
151
155
|
|
152
|
-
def remove_files(
|
156
|
+
def remove_files(
|
157
|
+
self,
|
158
|
+
callback: Optional[callable] = None
|
159
|
+
) -> int:
|
153
160
|
"""
|
154
161
|
Remove all files
|
155
162
|
|
@@ -168,7 +175,11 @@ class Store:
|
|
168
175
|
self.log(msg, callback)
|
169
176
|
return num
|
170
177
|
|
171
|
-
def remove_store_files(
|
178
|
+
def remove_store_files(
|
179
|
+
self,
|
180
|
+
store_id: str,
|
181
|
+
callback: Optional[callable] = None
|
182
|
+
) -> int:
|
172
183
|
"""
|
173
184
|
Remove all files from store
|
174
185
|
|
@@ -240,7 +251,11 @@ class Store:
|
|
240
251
|
)
|
241
252
|
return items
|
242
253
|
|
243
|
-
def create_store(
|
254
|
+
def create_store(
|
255
|
+
self,
|
256
|
+
name: str,
|
257
|
+
expire_days: int = 0
|
258
|
+
):
|
244
259
|
"""
|
245
260
|
Create vector store
|
246
261
|
|
@@ -262,7 +277,12 @@ class Store:
|
|
262
277
|
if vector_store is not None:
|
263
278
|
return vector_store
|
264
279
|
|
265
|
-
def update_store(
|
280
|
+
def update_store(
|
281
|
+
self,
|
282
|
+
id: str,
|
283
|
+
name: str,
|
284
|
+
expire_days: int = 0
|
285
|
+
):
|
266
286
|
"""
|
267
287
|
Update vector store
|
268
288
|
|
@@ -427,7 +447,10 @@ class Store:
|
|
427
447
|
num += 1
|
428
448
|
return num
|
429
449
|
|
430
|
-
def remove_all(
|
450
|
+
def remove_all(
|
451
|
+
self,
|
452
|
+
callback: Optional[callable] = None
|
453
|
+
) -> int:
|
431
454
|
"""
|
432
455
|
Remove all vector stores
|
433
456
|
|
@@ -446,7 +469,11 @@ class Store:
|
|
446
469
|
self.log(msg, callback)
|
447
470
|
return num
|
448
471
|
|
449
|
-
def add_file(
|
472
|
+
def add_file(
|
473
|
+
self,
|
474
|
+
store_id: str,
|
475
|
+
file_id: str
|
476
|
+
):
|
450
477
|
"""
|
451
478
|
Add file to vector store
|
452
479
|
|
@@ -480,7 +507,11 @@ class Store:
|
|
480
507
|
if deleted_file is not None:
|
481
508
|
return deleted_file.id
|
482
509
|
|
483
|
-
def delete_store_file(
|
510
|
+
def delete_store_file(
|
511
|
+
self,
|
512
|
+
store_id: str,
|
513
|
+
file_id: str
|
514
|
+
):
|
484
515
|
"""
|
485
516
|
Delete file from vector store
|
486
517
|
|
@@ -496,7 +527,10 @@ class Store:
|
|
496
527
|
if vector_store_file is not None:
|
497
528
|
return vector_store_file
|
498
529
|
|
499
|
-
def import_stores_files(
|
530
|
+
def import_stores_files(
|
531
|
+
self,
|
532
|
+
callback: Optional[callable] = None
|
533
|
+
) -> int:
|
500
534
|
"""
|
501
535
|
Import all vector stores files
|
502
536
|
|
pygpt_net/provider/gpt/vision.py
CHANGED
@@ -6,18 +6,19 @@
|
|
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 base64
|
13
13
|
import os
|
14
14
|
import re
|
15
|
-
from typing import Optional, Union
|
15
|
+
from typing import Optional, Union, Dict, Any, List
|
16
16
|
|
17
17
|
from pygpt_net.core.types import (
|
18
18
|
MODE_VISION,
|
19
19
|
)
|
20
20
|
from pygpt_net.core.bridge.context import BridgeContext
|
21
|
+
from pygpt_net.item.attachment import AttachmentItem
|
21
22
|
from pygpt_net.item.ctx import CtxItem
|
22
23
|
from pygpt_net.item.model import ModelItem
|
23
24
|
|
@@ -34,7 +35,11 @@ class Vision:
|
|
34
35
|
self.urls = []
|
35
36
|
self.input_tokens = 0
|
36
37
|
|
37
|
-
def send(
|
38
|
+
def send(
|
39
|
+
self,
|
40
|
+
context: BridgeContext,
|
41
|
+
extra: Optional[Dict[str, Any]] = None
|
42
|
+
):
|
38
43
|
"""
|
39
44
|
Call OpenAI API for chat with vision
|
40
45
|
|
@@ -78,9 +83,9 @@ class Vision:
|
|
78
83
|
prompt: str,
|
79
84
|
system_prompt: str,
|
80
85
|
model: ModelItem,
|
81
|
-
history: Optional[
|
82
|
-
attachments: Optional[
|
83
|
-
) ->
|
86
|
+
history: Optional[List[CtxItem]] = None,
|
87
|
+
attachments: Optional[Dict[str, AttachmentItem]] = None,
|
88
|
+
) -> List[dict]:
|
84
89
|
"""
|
85
90
|
Build chat messages list
|
86
91
|
|
@@ -162,8 +167,8 @@ class Vision:
|
|
162
167
|
def build_content(
|
163
168
|
self,
|
164
169
|
content: Union[str, list],
|
165
|
-
attachments: Optional[
|
166
|
-
) ->
|
170
|
+
attachments: Optional[Dict[str, AttachmentItem]] = None,
|
171
|
+
) -> List[dict]:
|
167
172
|
"""
|
168
173
|
Build vision content
|
169
174
|
|
@@ -219,7 +224,7 @@ class Vision:
|
|
219
224
|
|
220
225
|
return content
|
221
226
|
|
222
|
-
def extract_urls(self, text: str) ->
|
227
|
+
def extract_urls(self, text: str) -> List[str]:
|
223
228
|
"""
|
224
229
|
Extract img urls from text
|
225
230
|
|
@@ -261,7 +266,7 @@ class Vision:
|
|
261
266
|
"""Reset input tokens counter"""
|
262
267
|
self.input_tokens = 0
|
263
268
|
|
264
|
-
def get_attachments(self) ->
|
269
|
+
def get_attachments(self) -> Dict[str, str]:
|
265
270
|
"""
|
266
271
|
Get attachments
|
267
272
|
|
@@ -269,7 +274,7 @@ class Vision:
|
|
269
274
|
"""
|
270
275
|
return self.attachments
|
271
276
|
|
272
|
-
def get_urls(self) ->
|
277
|
+
def get_urls(self) -> List[str]:
|
273
278
|
"""
|
274
279
|
Get urls
|
275
280
|
|
@@ -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.
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
from llama_index.llms.anthropic import Anthropic
|
@@ -32,7 +32,12 @@ class AnthropicLLM(BaseLLM):
|
|
32
32
|
self.id = "anthropic"
|
33
33
|
self.type = [MODE_LLAMA_INDEX]
|
34
34
|
|
35
|
-
def llama(
|
35
|
+
def llama(
|
36
|
+
self,
|
37
|
+
window,
|
38
|
+
model: ModelItem,
|
39
|
+
stream: bool = False
|
40
|
+
) -> LlamaBaseLLM:
|
36
41
|
"""
|
37
42
|
Return LLM provider instance for llama
|
38
43
|
|