pygpt-net 2.4.37__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.
- CHANGELOG.md +37 -0
- README.md +176 -182
- pygpt_net/CHANGELOG.txt +37 -0
- pygpt_net/__init__.py +3 -3
- pygpt_net/app.py +3 -1
- pygpt_net/controller/__init__.py +7 -3
- pygpt_net/controller/access/control.py +1 -1
- pygpt_net/controller/access/voice.py +11 -5
- pygpt_net/controller/agent/experts.py +11 -6
- pygpt_net/controller/agent/legacy.py +8 -6
- pygpt_net/controller/agent/llama.py +4 -2
- pygpt_net/controller/assistant/__init__.py +9 -4
- pygpt_net/controller/assistant/batch.py +38 -21
- pygpt_net/controller/assistant/editor.py +7 -6
- pygpt_net/controller/assistant/files.py +23 -7
- pygpt_net/controller/assistant/store.py +20 -7
- pygpt_net/controller/assistant/threads.py +34 -8
- pygpt_net/controller/attachment.py +29 -10
- pygpt_net/controller/audio/__init__.py +26 -5
- pygpt_net/controller/calendar/__init__.py +23 -4
- pygpt_net/controller/calendar/note.py +57 -11
- pygpt_net/controller/camera.py +4 -12
- pygpt_net/controller/chat/__init__.py +5 -3
- pygpt_net/controller/chat/attachment.py +34 -7
- pygpt_net/controller/chat/audio.py +2 -2
- pygpt_net/controller/chat/command.py +4 -2
- pygpt_net/controller/chat/common.py +11 -4
- pygpt_net/controller/chat/files.py +10 -3
- pygpt_net/controller/chat/image.py +17 -5
- pygpt_net/controller/chat/input.py +10 -7
- pygpt_net/controller/chat/output.py +21 -6
- pygpt_net/controller/chat/render.py +100 -21
- pygpt_net/controller/chat/response.py +34 -7
- pygpt_net/controller/chat/stream.py +4 -2
- pygpt_net/controller/chat/text.py +6 -4
- pygpt_net/controller/command.py +11 -3
- pygpt_net/controller/config/__init__.py +34 -6
- pygpt_net/controller/config/field/checkbox.py +7 -4
- pygpt_net/controller/config/field/cmd.py +7 -5
- pygpt_net/controller/config/field/combo.py +14 -6
- pygpt_net/controller/config/field/dictionary.py +14 -11
- pygpt_net/controller/config/field/input.py +9 -6
- pygpt_net/controller/config/field/slider.py +11 -8
- pygpt_net/controller/config/field/textarea.py +8 -5
- pygpt_net/controller/config/placeholder.py +66 -21
- pygpt_net/controller/ctx/__init__.py +138 -49
- pygpt_net/controller/ctx/common.py +15 -4
- pygpt_net/controller/ctx/extra.py +11 -3
- pygpt_net/controller/ctx/summarizer.py +24 -5
- pygpt_net/controller/debug/__init__.py +27 -6
- pygpt_net/controller/dialogs/confirm.py +34 -7
- pygpt_net/controller/dialogs/debug.py +4 -2
- pygpt_net/controller/dialogs/info.py +7 -2
- pygpt_net/controller/files.py +48 -10
- pygpt_net/controller/finder.py +11 -5
- pygpt_net/controller/idx/__init__.py +10 -3
- pygpt_net/controller/idx/common.py +4 -2
- pygpt_net/controller/idx/indexer.py +25 -17
- pygpt_net/controller/idx/settings.py +9 -3
- pygpt_net/controller/kernel/__init__.py +34 -8
- pygpt_net/controller/kernel/reply.py +12 -3
- pygpt_net/controller/kernel/stack.py +5 -3
- pygpt_net/controller/lang/custom.py +2 -7
- pygpt_net/controller/lang/mapping.py +5 -3
- pygpt_net/controller/layout.py +2 -2
- pygpt_net/controller/mode.py +16 -4
- pygpt_net/controller/model/__init__.py +14 -3
- pygpt_net/controller/model/editor.py +8 -3
- pygpt_net/controller/notepad.py +26 -12
- pygpt_net/controller/painter/capture.py +23 -4
- pygpt_net/controller/painter/common.py +9 -7
- pygpt_net/controller/plugins/__init__.py +19 -5
- pygpt_net/controller/plugins/presets.py +15 -6
- pygpt_net/controller/plugins/settings.py +9 -3
- pygpt_net/controller/presets/__init__.py +55 -16
- pygpt_net/controller/presets/editor.py +26 -10
- pygpt_net/controller/settings/__init__.py +3 -2
- pygpt_net/controller/settings/editor.py +29 -7
- pygpt_net/controller/settings/profile.py +22 -5
- pygpt_net/controller/theme/__init__.py +54 -12
- pygpt_net/controller/theme/common.py +24 -2
- pygpt_net/controller/theme/markdown.py +32 -16
- pygpt_net/controller/theme/menu.py +26 -5
- pygpt_net/controller/theme/nodes.py +2 -5
- pygpt_net/controller/tools/__init__.py +40 -2
- pygpt_net/controller/ui/__init__.py +4 -6
- pygpt_net/controller/ui/mode.py +16 -21
- pygpt_net/controller/ui/tabs.py +363 -65
- pygpt_net/core/access/actions.py +6 -4
- pygpt_net/core/access/shortcuts.py +4 -3
- pygpt_net/core/access/voice.py +6 -5
- pygpt_net/core/agents/legacy.py +4 -2
- pygpt_net/core/agents/memory.py +7 -2
- pygpt_net/core/agents/observer/evaluation.py +15 -7
- pygpt_net/core/agents/provider.py +9 -4
- pygpt_net/core/agents/runner.py +61 -15
- pygpt_net/core/agents/tools.py +23 -5
- pygpt_net/core/assistants/__init__.py +6 -4
- pygpt_net/core/assistants/files.py +35 -12
- pygpt_net/core/assistants/store.py +20 -10
- pygpt_net/core/attachments/__init__.py +54 -15
- pygpt_net/core/attachments/context.py +92 -29
- pygpt_net/core/audio/__init__.py +74 -3
- pygpt_net/core/audio/context.py +7 -2
- pygpt_net/core/audio/whisper.py +37 -0
- pygpt_net/core/bridge/__init__.py +22 -6
- pygpt_net/core/bridge/context.py +5 -3
- pygpt_net/core/bridge/worker.py +2 -2
- pygpt_net/core/calendar/__init__.py +57 -11
- pygpt_net/core/chain/__init__.py +8 -2
- pygpt_net/core/chain/chat.py +10 -8
- pygpt_net/core/chain/completion.py +10 -7
- pygpt_net/core/command.py +62 -17
- pygpt_net/core/ctx/__init__.py +260 -58
- pygpt_net/core/ctx/bag.py +25 -4
- pygpt_net/core/ctx/container.py +28 -17
- pygpt_net/core/ctx/idx.py +45 -8
- pygpt_net/core/ctx/output.py +95 -74
- pygpt_net/core/ctx/reply.py +5 -2
- pygpt_net/core/db/__init__.py +8 -7
- pygpt_net/core/db/viewer.py +17 -11
- pygpt_net/core/debug/__init__.py +10 -9
- pygpt_net/core/debug/events.py +22 -10
- pygpt_net/core/debug/tabs.py +9 -3
- pygpt_net/core/docker/__init__.py +11 -5
- pygpt_net/core/docker/builder.py +11 -3
- pygpt_net/core/events/app.py +5 -3
- pygpt_net/core/events/base.py +11 -5
- pygpt_net/core/events/control.py +5 -3
- pygpt_net/core/events/event.py +17 -7
- pygpt_net/core/events/kernel.py +5 -3
- pygpt_net/core/events/render.py +5 -3
- pygpt_net/core/experts/__init__.py +5 -4
- pygpt_net/core/filesystem/__init__.py +52 -34
- pygpt_net/core/filesystem/actions.py +8 -5
- pygpt_net/core/filesystem/editor.py +13 -3
- pygpt_net/core/filesystem/types.py +12 -7
- pygpt_net/core/filesystem/url.py +7 -3
- pygpt_net/core/history.py +3 -2
- pygpt_net/core/idx/__init__.py +48 -27
- pygpt_net/core/idx/chat.py +51 -17
- pygpt_net/core/idx/context.py +6 -2
- pygpt_net/core/idx/indexing.py +107 -42
- pygpt_net/core/idx/llm.py +11 -3
- pygpt_net/core/idx/metadata.py +13 -3
- pygpt_net/core/idx/types/ctx.py +32 -6
- pygpt_net/core/idx/types/external.py +41 -7
- pygpt_net/core/idx/types/files.py +31 -6
- pygpt_net/core/image.py +15 -4
- pygpt_net/core/installer.py +2 -4
- pygpt_net/core/llm/__init__.py +13 -3
- pygpt_net/core/locale.py +34 -8
- pygpt_net/core/models.py +63 -17
- pygpt_net/core/modes.py +11 -13
- pygpt_net/core/notepad.py +10 -5
- pygpt_net/core/plugins.py +31 -19
- pygpt_net/core/presets.py +37 -17
- pygpt_net/core/profile.py +21 -7
- pygpt_net/core/prompt/__init__.py +10 -3
- pygpt_net/core/prompt/custom.py +7 -6
- pygpt_net/core/prompt/template.py +9 -3
- pygpt_net/core/render/base.py +117 -22
- pygpt_net/core/render/markdown/body.py +27 -7
- pygpt_net/core/render/markdown/renderer.py +119 -22
- pygpt_net/core/render/plain/body.py +22 -5
- pygpt_net/core/render/plain/renderer.py +97 -21
- pygpt_net/core/render/web/body.py +75 -25
- pygpt_net/core/render/web/parser.py +3 -1
- pygpt_net/core/render/web/renderer.py +313 -63
- pygpt_net/core/settings.py +10 -5
- pygpt_net/core/tabs/__init__.py +290 -103
- pygpt_net/core/tabs/tab.py +26 -5
- pygpt_net/core/tokens.py +47 -12
- pygpt_net/core/updater/__init__.py +20 -7
- pygpt_net/core/vision/analyzer.py +29 -6
- pygpt_net/core/{web.py → web/__init__.py} +29 -7
- pygpt_net/core/web/helpers.py +237 -0
- pygpt_net/data/config/config.json +15 -4
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/config/settings.json +55 -10
- pygpt_net/data/config/settings_section.json +3 -0
- pygpt_net/data/css/style.light.css +1 -0
- pygpt_net/data/css/{web.css → web-blocks.css} +162 -133
- pygpt_net/data/css/{web.light.css → web-blocks.light.css} +7 -0
- pygpt_net/data/css/web-chatgpt.css +350 -0
- pygpt_net/data/css/web-chatgpt.dark.css +64 -0
- pygpt_net/data/css/web-chatgpt.light.css +75 -0
- pygpt_net/data/css/web-chatgpt_wide.css +350 -0
- pygpt_net/data/css/web-chatgpt_wide.dark.css +64 -0
- pygpt_net/data/css/web-chatgpt_wide.light.css +75 -0
- pygpt_net/data/icons/split_screen.svg +1 -0
- pygpt_net/data/locale/locale.de.ini +12 -0
- pygpt_net/data/locale/locale.en.ini +18 -2
- pygpt_net/data/locale/locale.es.ini +12 -0
- pygpt_net/data/locale/locale.fr.ini +12 -0
- pygpt_net/data/locale/locale.it.ini +12 -0
- pygpt_net/data/locale/locale.pl.ini +12 -0
- pygpt_net/data/locale/locale.uk.ini +12 -0
- pygpt_net/data/locale/locale.zh.ini +12 -0
- pygpt_net/data/locale/plugin.cmd_web.de.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.en.ini +22 -10
- pygpt_net/data/locale/plugin.cmd_web.es.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.fr.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.it.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.pl.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.uk.ini +2 -0
- pygpt_net/data/locale/plugin.cmd_web.zh.ini +2 -0
- pygpt_net/data/locale/plugin.mailer.en.ini +21 -0
- pygpt_net/icons.qrc +1 -0
- pygpt_net/icons_rc.py +165 -136
- pygpt_net/item/ctx.py +58 -25
- pygpt_net/plugin/agent/__init__.py +7 -2
- pygpt_net/plugin/audio_input/simple.py +21 -5
- pygpt_net/plugin/audio_output/__init__.py +9 -1
- pygpt_net/plugin/base/config.py +4 -2
- pygpt_net/plugin/base/plugin.py +75 -23
- pygpt_net/plugin/base/worker.py +42 -11
- pygpt_net/plugin/cmd_code_interpreter/__init__.py +39 -37
- pygpt_net/plugin/cmd_code_interpreter/runner.py +25 -12
- pygpt_net/plugin/cmd_history/config.py +2 -2
- pygpt_net/plugin/cmd_web/__init__.py +48 -9
- pygpt_net/plugin/cmd_web/config.py +135 -41
- pygpt_net/plugin/cmd_web/websearch.py +74 -33
- pygpt_net/plugin/cmd_web/worker.py +142 -13
- 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/config/patch.py +43 -1
- pygpt_net/provider/core/ctx/base.py +30 -25
- pygpt_net/provider/core/ctx/db_sqlite/__init__.py +59 -34
- pygpt_net/provider/core/ctx/db_sqlite/storage.py +62 -30
- pygpt_net/provider/core/ctx/db_sqlite/utils.py +11 -9
- 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 +21 -11
- pygpt_net/provider/gpt/audio.py +6 -5
- pygpt_net/provider/gpt/chat.py +10 -7
- pygpt_net/provider/gpt/completion.py +11 -5
- pygpt_net/provider/gpt/image.py +9 -2
- pygpt_net/provider/gpt/store.py +53 -18
- pygpt_net/provider/gpt/vision.py +17 -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 +31 -12
- 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 +20 -4
- pygpt_net/tools/audio_transcriber/__init__.py +4 -3
- pygpt_net/tools/base.py +28 -7
- pygpt_net/tools/code_interpreter/__init__.py +177 -77
- pygpt_net/tools/code_interpreter/ui/dialogs.py +21 -103
- pygpt_net/tools/code_interpreter/ui/widgets.py +284 -9
- pygpt_net/tools/html_canvas/__init__.py +81 -25
- pygpt_net/tools/html_canvas/ui/dialogs.py +46 -62
- pygpt_net/tools/html_canvas/ui/widgets.py +96 -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/base/context_menu.py +2 -2
- pygpt_net/ui/layout/chat/input.py +10 -18
- pygpt_net/ui/layout/chat/output.py +27 -45
- pygpt_net/ui/layout/ctx/ctx_list.py +13 -4
- pygpt_net/ui/layout/toolbox/footer.py +18 -2
- pygpt_net/ui/main.py +2 -2
- pygpt_net/ui/menu/audio.py +12 -1
- pygpt_net/ui/menu/config.py +7 -11
- pygpt_net/ui/menu/debug.py +11 -1
- pygpt_net/ui/menu/theme.py +9 -2
- pygpt_net/ui/widget/filesystem/explorer.py +2 -2
- pygpt_net/ui/widget/lists/context.py +27 -5
- pygpt_net/ui/widget/tabs/Input.py +2 -2
- pygpt_net/ui/widget/tabs/body.py +2 -1
- pygpt_net/ui/widget/tabs/layout.py +195 -0
- pygpt_net/ui/widget/tabs/output.py +218 -55
- pygpt_net/ui/widget/textarea/html.py +11 -1
- pygpt_net/ui/widget/textarea/output.py +10 -1
- pygpt_net/ui/widget/textarea/search_input.py +4 -1
- pygpt_net/ui/widget/textarea/web.py +49 -9
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/METADATA +177 -183
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/RECORD +340 -325
- /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.37.dist-info → pygpt_net-2.4.42.dist-info}/entry_points.txt +0 -0
pygpt_net/core/access/actions.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.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import List, Dict
|
13
|
+
|
12
14
|
from pygpt_net.core.events import ControlEvent, AppEvent
|
13
15
|
|
14
16
|
|
@@ -21,7 +23,7 @@ class Actions:
|
|
21
23
|
"""
|
22
24
|
self.window = window
|
23
25
|
|
24
|
-
def get_access_choices(self) ->
|
26
|
+
def get_access_choices(self) -> List[Dict[str, str]]:
|
25
27
|
"""
|
26
28
|
Get app access events choices
|
27
29
|
|
@@ -74,7 +76,7 @@ class Actions:
|
|
74
76
|
choices.append({event: f"event.control.{event}"})
|
75
77
|
return choices
|
76
78
|
|
77
|
-
def get_speech_synthesis_choices(self) ->
|
79
|
+
def get_speech_synthesis_choices(self) -> List[Dict[str, str]]:
|
78
80
|
"""
|
79
81
|
Get app access events choices
|
80
82
|
|
@@ -115,7 +117,7 @@ class Actions:
|
|
115
117
|
choices.append({event: f"event.audio.{event}"})
|
116
118
|
return choices
|
117
119
|
|
118
|
-
def get_voice_control_choices(self) ->
|
120
|
+
def get_voice_control_choices(self) -> List[Dict[str, str]]:
|
119
121
|
"""
|
120
122
|
Get voice control choices
|
121
123
|
|
@@ -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 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import copy
|
13
|
+
from typing import List, Dict
|
13
14
|
|
14
15
|
from PySide6 import QtCore
|
15
16
|
from PySide6.QtCore import QObject, QEvent
|
@@ -26,7 +27,7 @@ class Shortcuts:
|
|
26
27
|
"""
|
27
28
|
self.window = window
|
28
29
|
|
29
|
-
def get_keys_choices(self) ->
|
30
|
+
def get_keys_choices(self) -> List[Dict[str, str]]:
|
30
31
|
"""
|
31
32
|
Get keys choices with identical key and value.
|
32
33
|
|
@@ -43,7 +44,7 @@ class Shortcuts:
|
|
43
44
|
keys.extend([{name: name} for name in symbols])
|
44
45
|
return keys
|
45
46
|
|
46
|
-
def get_modifiers_choices(self) ->
|
47
|
+
def get_modifiers_choices(self) -> List[Dict[str, str]]:
|
47
48
|
"""
|
48
49
|
Get modifiers choices with identical key and value.
|
49
50
|
|
pygpt_net/core/access/voice.py
CHANGED
@@ -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 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
13
|
import re
|
14
|
+
from typing import Optional, Dict, List, Any
|
14
15
|
|
15
16
|
from pygpt_net.core.bridge.context import BridgeContext
|
16
17
|
|
@@ -96,7 +97,7 @@ class Voice:
|
|
96
97
|
AppEvent.TAB_SELECTED, # notepad tabs can have custom names
|
97
98
|
]
|
98
99
|
|
99
|
-
def get_commands(self) ->
|
100
|
+
def get_commands(self) -> Dict[str, str]:
|
100
101
|
"""
|
101
102
|
Get available commands
|
102
103
|
|
@@ -152,7 +153,7 @@ class Voice:
|
|
152
153
|
|
153
154
|
return prompt.strip()
|
154
155
|
|
155
|
-
def get_inline_prompt(self, prefix: str = None) -> str:
|
156
|
+
def get_inline_prompt(self, prefix: Optional[str] = None) -> str:
|
156
157
|
"""
|
157
158
|
Get prompt for inline voice command recognition
|
158
159
|
|
@@ -174,7 +175,7 @@ class Voice:
|
|
174
175
|
|
175
176
|
return prompt.strip()
|
176
177
|
|
177
|
-
def extract_json(self, text: str) ->
|
178
|
+
def extract_json(self, text: str) -> List[Dict[str, Any]]:
|
178
179
|
"""
|
179
180
|
Extract JSON from text
|
180
181
|
|
@@ -206,7 +207,7 @@ class Voice:
|
|
206
207
|
self.window.core.debug.log(e)
|
207
208
|
return cmds
|
208
209
|
|
209
|
-
def recognize_commands(self, text: str) ->
|
210
|
+
def recognize_commands(self, text: str) -> List[Dict[str, Any]]:
|
210
211
|
"""
|
211
212
|
Recognize voice command
|
212
213
|
|
pygpt_net/core/agents/legacy.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.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import List
|
13
|
+
|
12
14
|
from pygpt_net.core.types import (
|
13
15
|
MODE_CHAT,
|
14
16
|
MODE_COMPLETION,
|
@@ -35,7 +37,7 @@ class Legacy:
|
|
35
37
|
MODE_AUDIO,
|
36
38
|
]
|
37
39
|
|
38
|
-
def get_allowed_modes(self) ->
|
40
|
+
def get_allowed_modes(self) -> List[str]:
|
39
41
|
"""
|
40
42
|
Get allowed modes
|
41
43
|
|
pygpt_net/core/agents/memory.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.
|
9
|
+
# Updated Date: 2024.12.14 00:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import List
|
13
|
+
|
12
14
|
from llama_index.core.llms import ChatMessage, MessageRole
|
13
15
|
from pygpt_net.core.bridge.context import BridgeContext
|
14
16
|
|
@@ -22,7 +24,10 @@ class Memory:
|
|
22
24
|
"""
|
23
25
|
self.window = window
|
24
26
|
|
25
|
-
def prepare(
|
27
|
+
def prepare(
|
28
|
+
self,
|
29
|
+
context: BridgeContext
|
30
|
+
) -> List[ChatMessage]:
|
26
31
|
"""
|
27
32
|
Prepare history for agent
|
28
33
|
|
@@ -6,11 +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: 2024.
|
9
|
+
# Updated Date: 2024.12.14 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import List
|
13
|
+
|
12
14
|
from llama_index.core.tools import FunctionTool
|
13
15
|
|
16
|
+
from pygpt_net.item.ctx import CtxItem
|
17
|
+
|
14
18
|
|
15
19
|
class Evaluation:
|
16
20
|
def __init__(self, window=None):
|
@@ -67,7 +71,7 @@ class Evaluation:
|
|
67
71
|
- Do not repeat the suggested improvements if they have already been correctly included in the agent's response.
|
68
72
|
"""
|
69
73
|
|
70
|
-
def get_last_user_input(self, history) -> str:
|
74
|
+
def get_last_user_input(self, history: List[CtxItem]) -> str:
|
71
75
|
"""
|
72
76
|
Get the last user input from the history
|
73
77
|
|
@@ -84,7 +88,7 @@ class Evaluation:
|
|
84
88
|
input = ctx.input
|
85
89
|
return input
|
86
90
|
|
87
|
-
def get_main_task(self, history) -> str:
|
91
|
+
def get_main_task(self, history: List[CtxItem]) -> str:
|
88
92
|
"""
|
89
93
|
Get the main task from the history
|
90
94
|
|
@@ -97,7 +101,7 @@ class Evaluation:
|
|
97
101
|
task = first.input
|
98
102
|
return task
|
99
103
|
|
100
|
-
def get_final_response(self, history) -> str:
|
104
|
+
def get_final_response(self, history: List[CtxItem]) -> str:
|
101
105
|
"""
|
102
106
|
Get the final response from the agent
|
103
107
|
|
@@ -111,7 +115,7 @@ class Evaluation:
|
|
111
115
|
output = ctx.output
|
112
116
|
return output
|
113
117
|
|
114
|
-
def get_prompt(self, history) -> str:
|
118
|
+
def get_prompt(self, history: List[CtxItem]) -> str:
|
115
119
|
"""
|
116
120
|
Return the evaluation prompt
|
117
121
|
|
@@ -128,7 +132,7 @@ class Evaluation:
|
|
128
132
|
output=final_response
|
129
133
|
)
|
130
134
|
|
131
|
-
def get_tools(self) ->
|
135
|
+
def get_tools(self) -> List[FunctionTool]:
|
132
136
|
"""
|
133
137
|
Get the tools for evaluating the result
|
134
138
|
|
@@ -144,7 +148,11 @@ class Evaluation:
|
|
144
148
|
tools.append(tool)
|
145
149
|
return tools
|
146
150
|
|
147
|
-
def handle_evaluation(
|
151
|
+
def handle_evaluation(
|
152
|
+
self,
|
153
|
+
instruction: str,
|
154
|
+
score: int
|
155
|
+
):
|
148
156
|
"""
|
149
157
|
Update the evaluation values of the agent response
|
150
158
|
|
@@ -6,9 +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 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import List
|
13
|
+
|
14
|
+
from pygpt_net.provider.agents.base import BaseAgent
|
15
|
+
|
16
|
+
|
12
17
|
class Provider:
|
13
18
|
def __init__(self, window=None):
|
14
19
|
"""
|
@@ -19,7 +24,7 @@ class Provider:
|
|
19
24
|
self.window = window
|
20
25
|
self.agents = {}
|
21
26
|
|
22
|
-
def get_ids(self) ->
|
27
|
+
def get_ids(self) -> List[str]:
|
23
28
|
"""
|
24
29
|
Get agent providers ids
|
25
30
|
|
@@ -36,7 +41,7 @@ class Provider:
|
|
36
41
|
"""
|
37
42
|
return id in self.agents
|
38
43
|
|
39
|
-
def get(self, id: str):
|
44
|
+
def get(self, id: str) -> BaseAgent:
|
40
45
|
"""
|
41
46
|
Get agent provider
|
42
47
|
|
@@ -54,7 +59,7 @@ class Provider:
|
|
54
59
|
"""
|
55
60
|
self.agents[id] = agent
|
56
61
|
|
57
|
-
def get_providers(self) ->
|
62
|
+
def get_providers(self) -> List[str]:
|
58
63
|
"""
|
59
64
|
Get agent providers list
|
60
65
|
|
pygpt_net/core/agents/runner.py
CHANGED
@@ -6,9 +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 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Optional, Dict, Any, List
|
13
|
+
|
14
|
+
from llama_index.core.tools import FunctionTool
|
15
|
+
|
12
16
|
from pygpt_net.core.bridge.context import BridgeContext
|
13
17
|
from pygpt_net.core.bridge.worker import BridgeSignals
|
14
18
|
from pygpt_net.core.events import Event, KernelEvent
|
@@ -32,7 +36,7 @@ class Runner:
|
|
32
36
|
def call(
|
33
37
|
self,
|
34
38
|
context: BridgeContext,
|
35
|
-
extra:
|
39
|
+
extra: Dict[str, Any],
|
36
40
|
signals: BridgeSignals
|
37
41
|
) -> bool:
|
38
42
|
"""
|
@@ -104,7 +108,7 @@ class Runner:
|
|
104
108
|
|
105
109
|
def run_steps(
|
106
110
|
self,
|
107
|
-
agent,
|
111
|
+
agent: Any,
|
108
112
|
ctx: CtxItem,
|
109
113
|
prompt: str,
|
110
114
|
signals: BridgeSignals,
|
@@ -202,7 +206,7 @@ class Runner:
|
|
202
206
|
|
203
207
|
def run_assistant(
|
204
208
|
self,
|
205
|
-
agent,
|
209
|
+
agent: Any,
|
206
210
|
ctx: CtxItem,
|
207
211
|
prompt: str,
|
208
212
|
signals: BridgeSignals,
|
@@ -250,7 +254,7 @@ class Runner:
|
|
250
254
|
|
251
255
|
def run_plan(
|
252
256
|
self,
|
253
|
-
agent,
|
257
|
+
agent: Any,
|
254
258
|
ctx: CtxItem,
|
255
259
|
prompt: str,
|
256
260
|
signals: BridgeSignals,
|
@@ -408,7 +412,12 @@ class Runner:
|
|
408
412
|
|
409
413
|
return True
|
410
414
|
|
411
|
-
def copy_step_results(
|
415
|
+
def copy_step_results(
|
416
|
+
self,
|
417
|
+
step_ctx: CtxItem,
|
418
|
+
ctx: CtxItem,
|
419
|
+
tools_output: List[Dict[str, Any]]
|
420
|
+
):
|
412
421
|
"""
|
413
422
|
Copy step results from base context item
|
414
423
|
|
@@ -433,7 +442,12 @@ class Runner:
|
|
433
442
|
if k != "agent_input":
|
434
443
|
del ctx.extra[k]
|
435
444
|
|
436
|
-
def run_once(
|
445
|
+
def run_once(
|
446
|
+
self,
|
447
|
+
input: str,
|
448
|
+
tools: List[FunctionTool],
|
449
|
+
model_name: Optional[str] = None
|
450
|
+
) -> str:
|
437
451
|
"""
|
438
452
|
Run agent once (quick call to ReAct agent)
|
439
453
|
|
@@ -460,7 +474,12 @@ class Runner:
|
|
460
474
|
agent = provider.get_agent(self.window, kwargs)
|
461
475
|
return agent.chat(self.prepare_input(input))
|
462
476
|
|
463
|
-
def run_next(
|
477
|
+
def run_next(
|
478
|
+
self,
|
479
|
+
context: BridgeContext,
|
480
|
+
extra: dict,
|
481
|
+
signals: BridgeSignals
|
482
|
+
) -> bool:
|
464
483
|
"""
|
465
484
|
Evaluate a response and run next step
|
466
485
|
|
@@ -484,7 +503,13 @@ class Runner:
|
|
484
503
|
self.run_once(prompt, tools, ctx.model) # tool will update evaluation
|
485
504
|
return self.handle_evaluation(ctx, self.next_instruction, self.prev_score, signals)
|
486
505
|
|
487
|
-
def handle_evaluation(
|
506
|
+
def handle_evaluation(
|
507
|
+
self,
|
508
|
+
ctx: CtxItem,
|
509
|
+
instruction: str,
|
510
|
+
score: int,
|
511
|
+
signals: BridgeSignals
|
512
|
+
):
|
488
513
|
"""
|
489
514
|
Handle evaluation
|
490
515
|
|
@@ -548,7 +573,10 @@ class Runner:
|
|
548
573
|
context.model = self.window.core.models.get(self.window.core.config.get('model'))
|
549
574
|
return self.call(context, extra, signals)
|
550
575
|
|
551
|
-
def add_ctx(
|
576
|
+
def add_ctx(
|
577
|
+
self,
|
578
|
+
from_ctx: CtxItem
|
579
|
+
) -> CtxItem:
|
552
580
|
"""
|
553
581
|
Add context item
|
554
582
|
|
@@ -568,7 +596,13 @@ class Runner:
|
|
568
596
|
ctx.live = True
|
569
597
|
return ctx
|
570
598
|
|
571
|
-
def send_response(
|
599
|
+
def send_response(
|
600
|
+
self,
|
601
|
+
ctx: CtxItem,
|
602
|
+
signals: BridgeSignals,
|
603
|
+
event_name: str,
|
604
|
+
**kwargs
|
605
|
+
):
|
572
606
|
"""
|
573
607
|
Send async response to chat window (BridgeSignals)
|
574
608
|
|
@@ -585,7 +619,11 @@ class Runner:
|
|
585
619
|
})
|
586
620
|
signals.response.emit(event)
|
587
621
|
|
588
|
-
def set_busy(
|
622
|
+
def set_busy(
|
623
|
+
self,
|
624
|
+
signals: BridgeSignals,
|
625
|
+
**kwargs
|
626
|
+
):
|
589
627
|
"""
|
590
628
|
Set busy status
|
591
629
|
|
@@ -600,7 +638,11 @@ class Runner:
|
|
600
638
|
data.update(kwargs)
|
601
639
|
signals.response.emit(event)
|
602
640
|
|
603
|
-
def set_idle(
|
641
|
+
def set_idle(
|
642
|
+
self,
|
643
|
+
signals: BridgeSignals,
|
644
|
+
**kwargs
|
645
|
+
):
|
604
646
|
"""
|
605
647
|
Set idle status
|
606
648
|
|
@@ -614,7 +656,11 @@ class Runner:
|
|
614
656
|
data.update(kwargs)
|
615
657
|
signals.response.emit(event)
|
616
658
|
|
617
|
-
def set_status(
|
659
|
+
def set_status(
|
660
|
+
self,
|
661
|
+
signals: BridgeSignals,
|
662
|
+
msg: str
|
663
|
+
):
|
618
664
|
"""
|
619
665
|
Set busy status
|
620
666
|
|
@@ -647,7 +693,7 @@ class Runner:
|
|
647
693
|
"""
|
648
694
|
return self.window.controller.kernel.stopped()
|
649
695
|
|
650
|
-
def get_error(self) -> Exception
|
696
|
+
def get_error(self) -> Optional[Exception]:
|
651
697
|
"""
|
652
698
|
Get last error
|
653
699
|
|
pygpt_net/core/agents/tools.py
CHANGED
@@ -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 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
13
|
+
from typing import List, Dict, Any
|
13
14
|
|
14
15
|
from llama_index.core.chat_engine.types import AgentChatResponse
|
15
16
|
from llama_index.core.tools import BaseTool, FunctionTool, QueryEngineTool, ToolMetadata
|
@@ -29,7 +30,12 @@ class Tools:
|
|
29
30
|
self.cmd_blacklist = []
|
30
31
|
self.verbose = False
|
31
32
|
|
32
|
-
def prepare(
|
33
|
+
def prepare(
|
34
|
+
self,
|
35
|
+
context: BridgeContext,
|
36
|
+
extra: Dict[str, Any],
|
37
|
+
verbose: bool = False
|
38
|
+
) -> List[BaseTool]:
|
33
39
|
"""
|
34
40
|
Prepare tools for agent
|
35
41
|
|
@@ -66,7 +72,11 @@ class Tools:
|
|
66
72
|
tools.extend(query_engine_tools)
|
67
73
|
return tools
|
68
74
|
|
69
|
-
def get_plugin_functions(
|
75
|
+
def get_plugin_functions(
|
76
|
+
self,
|
77
|
+
ctx: CtxItem,
|
78
|
+
verbose: bool = False
|
79
|
+
) -> list:
|
70
80
|
"""
|
71
81
|
Parse plugin functions
|
72
82
|
|
@@ -114,7 +124,10 @@ class Tools:
|
|
114
124
|
print(e)
|
115
125
|
return tools
|
116
126
|
|
117
|
-
def export_sources(
|
127
|
+
def export_sources(
|
128
|
+
self,
|
129
|
+
response: AgentChatResponse
|
130
|
+
) -> List[dict]:
|
118
131
|
"""
|
119
132
|
Export sources from response
|
120
133
|
|
@@ -148,7 +161,12 @@ class PluginToolMetadata(ToolMetadata):
|
|
148
161
|
super().__init__(name=name, description=description)
|
149
162
|
self.schema = None
|
150
163
|
|
151
|
-
def get_parameters_dict(self) ->
|
164
|
+
def get_parameters_dict(self) -> Dict[str, Any]:
|
165
|
+
"""
|
166
|
+
Get parameters dictionary
|
167
|
+
|
168
|
+
:return: parameters
|
169
|
+
"""
|
152
170
|
parameters = {
|
153
171
|
k: v
|
154
172
|
for k, v in self.schema.items()
|
@@ -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 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Optional, Dict
|
13
|
+
|
12
14
|
from pygpt_net.item.assistant import AssistantItem
|
13
15
|
from pygpt_net.item.attachment import AttachmentItem
|
14
16
|
from pygpt_net.provider.core.assistant.json_file import JsonFileProvider
|
@@ -58,7 +60,7 @@ class Assistants:
|
|
58
60
|
assistants = self.get_all()
|
59
61
|
return list(assistants.keys())[idx]
|
60
62
|
|
61
|
-
def get_by_id(self, id: str) -> AssistantItem
|
63
|
+
def get_by_id(self, id: str) -> Optional[AssistantItem]:
|
62
64
|
"""
|
63
65
|
Return assistant by ID
|
64
66
|
|
@@ -70,7 +72,7 @@ class Assistants:
|
|
70
72
|
return None
|
71
73
|
return assistants[id]
|
72
74
|
|
73
|
-
def get_all(self) ->
|
75
|
+
def get_all(self) -> Dict[str, AssistantItem]:
|
74
76
|
"""
|
75
77
|
Return assistants
|
76
78
|
|
@@ -143,7 +145,7 @@ class Assistants:
|
|
143
145
|
del assistant.attachments[old_id]
|
144
146
|
self.save()
|
145
147
|
|
146
|
-
def get_default_assistant(self) -> str
|
148
|
+
def get_default_assistant(self) -> Optional[str]:
|
147
149
|
"""
|
148
150
|
Return default assistant ID or None
|
149
151
|
|
@@ -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 08:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Optional, List, Dict
|
13
|
+
|
12
14
|
from packaging.version import Version
|
13
15
|
|
14
16
|
from pygpt_net.item.assistant import AssistantFileItem, AssistantItem
|
@@ -49,7 +51,7 @@ class Files:
|
|
49
51
|
if id in self.items:
|
50
52
|
return self.items[id]
|
51
53
|
|
52
|
-
def get_ids(self) ->
|
54
|
+
def get_ids(self) -> List[str]:
|
53
55
|
"""
|
54
56
|
Return all loaded file IDs
|
55
57
|
|
@@ -58,7 +60,7 @@ class Files:
|
|
58
60
|
return list(self.items.keys())
|
59
61
|
|
60
62
|
|
61
|
-
def get_all(self) ->
|
63
|
+
def get_all(self) -> Dict[str, AssistantFileItem]:
|
62
64
|
"""
|
63
65
|
Return all files
|
64
66
|
|
@@ -103,7 +105,7 @@ class Files:
|
|
103
105
|
file_id: str,
|
104
106
|
name: str,
|
105
107
|
path: str,
|
106
|
-
size: int) -> AssistantFileItem
|
108
|
+
size: int) -> Optional[AssistantFileItem]:
|
107
109
|
"""
|
108
110
|
Create new file
|
109
111
|
|
@@ -128,7 +130,10 @@ class Files:
|
|
128
130
|
self.items[file.id] = file
|
129
131
|
return file
|
130
132
|
|
131
|
-
def update(
|
133
|
+
def update(
|
134
|
+
self,
|
135
|
+
file: AssistantFileItem
|
136
|
+
) -> Optional[AssistantFileItem]:
|
132
137
|
"""
|
133
138
|
Update file
|
134
139
|
|
@@ -139,7 +144,7 @@ class Files:
|
|
139
144
|
self.provider.save(file)
|
140
145
|
return file
|
141
146
|
|
142
|
-
def get_names(self) ->
|
147
|
+
def get_names(self) -> Dict[str, str]:
|
143
148
|
"""
|
144
149
|
Get file name mapping id <> name
|
145
150
|
|
@@ -151,7 +156,11 @@ class Files:
|
|
151
156
|
names[id] = file.name
|
152
157
|
return names
|
153
158
|
|
154
|
-
def get_by_store_or_thread(
|
159
|
+
def get_by_store_or_thread(
|
160
|
+
self,
|
161
|
+
store_id: str,
|
162
|
+
thread_id: str
|
163
|
+
) -> Dict[str, AssistantFileItem]:
|
155
164
|
"""
|
156
165
|
Get files by store or thread
|
157
166
|
|
@@ -161,7 +170,11 @@ class Files:
|
|
161
170
|
"""
|
162
171
|
return self.provider.get_by_store_or_thread(store_id, thread_id)
|
163
172
|
|
164
|
-
def count_by_store_or_thread(
|
173
|
+
def count_by_store_or_thread(
|
174
|
+
self,
|
175
|
+
store_id: str,
|
176
|
+
thread_id: str
|
177
|
+
) -> int:
|
165
178
|
"""
|
166
179
|
Count files by store or thread
|
167
180
|
|
@@ -171,7 +184,12 @@ class Files:
|
|
171
184
|
"""
|
172
185
|
return self.provider.count_by_store_or_thread(store_id, thread_id)
|
173
186
|
|
174
|
-
def get_file_by_idx(
|
187
|
+
def get_file_by_idx(
|
188
|
+
self,
|
189
|
+
idx: int,
|
190
|
+
store_id: str,
|
191
|
+
thread_id: str
|
192
|
+
) -> Optional[AssistantFileItem]:
|
175
193
|
"""
|
176
194
|
Get file by list index
|
177
195
|
|
@@ -185,7 +203,12 @@ class Files:
|
|
185
203
|
return None
|
186
204
|
return list(files.values())[idx]
|
187
205
|
|
188
|
-
def get_file_id_by_idx(
|
206
|
+
def get_file_id_by_idx(
|
207
|
+
self,
|
208
|
+
idx: int,
|
209
|
+
store_id: str,
|
210
|
+
thread_id: str
|
211
|
+
) -> Optional[str]:
|
189
212
|
"""
|
190
213
|
Get file by list index
|
191
214
|
|
@@ -259,7 +282,7 @@ class Files:
|
|
259
282
|
self.items[record_id].name = name
|
260
283
|
return True
|
261
284
|
|
262
|
-
def truncate(self, store_id: str = None) -> bool:
|
285
|
+
def truncate(self, store_id: Optional[str] = None) -> bool:
|
263
286
|
"""
|
264
287
|
Truncate all files
|
265
288
|
|
@@ -272,7 +295,7 @@ class Files:
|
|
272
295
|
self.window.core.gpt.store.remove_from_stores() # remove files from all vector stores
|
273
296
|
return self.truncate_local(store_id) # truncate files in DB
|
274
297
|
|
275
|
-
def truncate_local(self, store_id: str = None) -> bool:
|
298
|
+
def truncate_local(self, store_id: Optional[str] = None) -> bool:
|
276
299
|
"""
|
277
300
|
Truncate all files (local only)
|
278
301
|
|