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/idx/types/ctx.py
CHANGED
@@ -6,9 +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 00:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
+
from typing import Optional
|
13
|
+
|
14
|
+
|
12
15
|
class Ctx:
|
13
16
|
def __init__(self, window=None, provider=None):
|
14
17
|
"""
|
@@ -43,7 +46,12 @@ class Ctx:
|
|
43
46
|
doc_id=doc_id,
|
44
47
|
)
|
45
48
|
|
46
|
-
def exists(
|
49
|
+
def exists(
|
50
|
+
self,
|
51
|
+
store_id: str,
|
52
|
+
idx: str,
|
53
|
+
meta_id: int
|
54
|
+
) -> bool:
|
47
55
|
"""
|
48
56
|
Check if ctx meta is indexed
|
49
57
|
|
@@ -58,7 +66,12 @@ class Ctx:
|
|
58
66
|
meta_id=meta_id,
|
59
67
|
)
|
60
68
|
|
61
|
-
def get_doc_id(
|
69
|
+
def get_doc_id(
|
70
|
+
self,
|
71
|
+
store_id: str,
|
72
|
+
idx: str,
|
73
|
+
meta_id: int
|
74
|
+
) -> str:
|
62
75
|
"""
|
63
76
|
Get indexed document id by meta id
|
64
77
|
|
@@ -73,7 +86,11 @@ class Ctx:
|
|
73
86
|
meta_id=meta_id,
|
74
87
|
)
|
75
88
|
|
76
|
-
def update(
|
89
|
+
def update(
|
90
|
+
self,
|
91
|
+
meta_id: int,
|
92
|
+
doc_id: str
|
93
|
+
) -> bool:
|
77
94
|
"""
|
78
95
|
Update timestamp of indexed ctx meta
|
79
96
|
|
@@ -86,7 +103,12 @@ class Ctx:
|
|
86
103
|
doc_id=doc_id,
|
87
104
|
)
|
88
105
|
|
89
|
-
def remove(
|
106
|
+
def remove(
|
107
|
+
self,
|
108
|
+
store_id: str,
|
109
|
+
idx: str,
|
110
|
+
meta_id: str
|
111
|
+
):
|
90
112
|
"""
|
91
113
|
Remove document from index db
|
92
114
|
|
@@ -100,7 +122,11 @@ class Ctx:
|
|
100
122
|
meta_id=meta_id,
|
101
123
|
)
|
102
124
|
|
103
|
-
def truncate(
|
125
|
+
def truncate(
|
126
|
+
self,
|
127
|
+
store_id: Optional[str] = None,
|
128
|
+
idx: Optional[str] = None
|
129
|
+
):
|
104
130
|
"""
|
105
131
|
Truncate ctx meta from index db
|
106
132
|
|
@@ -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 00:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import datetime
|
13
13
|
import time
|
14
|
+
from typing import Optional
|
14
15
|
|
15
16
|
|
16
17
|
class External:
|
@@ -54,7 +55,13 @@ class External:
|
|
54
55
|
data=data,
|
55
56
|
)
|
56
57
|
|
57
|
-
def get_doc_id(
|
58
|
+
def get_doc_id(
|
59
|
+
self,
|
60
|
+
store_id: str,
|
61
|
+
idx: str,
|
62
|
+
content: str,
|
63
|
+
type: str
|
64
|
+
) -> str:
|
58
65
|
"""
|
59
66
|
Get indexed document id by content
|
60
67
|
|
@@ -71,7 +78,13 @@ class External:
|
|
71
78
|
type=type,
|
72
79
|
)
|
73
80
|
|
74
|
-
def exists(
|
81
|
+
def exists(
|
82
|
+
self,
|
83
|
+
store_id: str,
|
84
|
+
idx: str,
|
85
|
+
content: str,
|
86
|
+
type: str
|
87
|
+
) -> bool:
|
75
88
|
"""
|
76
89
|
Check if content is indexed
|
77
90
|
|
@@ -88,7 +101,13 @@ class External:
|
|
88
101
|
type=type,
|
89
102
|
)
|
90
103
|
|
91
|
-
def update(
|
104
|
+
def update(
|
105
|
+
self,
|
106
|
+
content: str,
|
107
|
+
type: str,
|
108
|
+
doc_id: str,
|
109
|
+
ts: int
|
110
|
+
) -> bool:
|
92
111
|
"""
|
93
112
|
Update timestamp of indexed external content
|
94
113
|
|
@@ -105,7 +124,12 @@ class External:
|
|
105
124
|
ts=ts,
|
106
125
|
)
|
107
126
|
|
108
|
-
def remove(
|
127
|
+
def remove(
|
128
|
+
self,
|
129
|
+
store_id: str,
|
130
|
+
idx: str,
|
131
|
+
doc_id: str
|
132
|
+
):
|
109
133
|
"""
|
110
134
|
Remove document from index
|
111
135
|
|
@@ -119,7 +143,11 @@ class External:
|
|
119
143
|
doc_id=doc_id,
|
120
144
|
)
|
121
145
|
|
122
|
-
def truncate(
|
146
|
+
def truncate(
|
147
|
+
self,
|
148
|
+
store_id: Optional[str] = None,
|
149
|
+
idx: Optional[str] = None
|
150
|
+
):
|
123
151
|
"""
|
124
152
|
Truncate external data from index
|
125
153
|
|
@@ -131,7 +159,13 @@ class External:
|
|
131
159
|
idx=idx,
|
132
160
|
)
|
133
161
|
|
134
|
-
def set_indexed(
|
162
|
+
def set_indexed(
|
163
|
+
self,
|
164
|
+
content: str,
|
165
|
+
type: str,
|
166
|
+
idx: str,
|
167
|
+
doc_id: str
|
168
|
+
) -> bool:
|
135
169
|
"""
|
136
170
|
Set external content as indexed
|
137
171
|
|
@@ -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 00:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import datetime
|
13
13
|
import os.path
|
14
|
+
from typing import Optional
|
14
15
|
|
15
16
|
|
16
17
|
class Files:
|
@@ -67,7 +68,12 @@ class Files:
|
|
67
68
|
path = path.replace("\\", "/").strip(r'\/')
|
68
69
|
return path
|
69
70
|
|
70
|
-
def get_doc_id(
|
71
|
+
def get_doc_id(
|
72
|
+
self,
|
73
|
+
store_id: str,
|
74
|
+
idx: str,
|
75
|
+
file_id: str
|
76
|
+
) -> str:
|
71
77
|
"""
|
72
78
|
Get indexed document id by file
|
73
79
|
|
@@ -82,7 +88,12 @@ class Files:
|
|
82
88
|
file_id=file_id,
|
83
89
|
)
|
84
90
|
|
85
|
-
def exists(
|
91
|
+
def exists(
|
92
|
+
self,
|
93
|
+
store_id: str,
|
94
|
+
idx: str,
|
95
|
+
file_id: str
|
96
|
+
) -> bool:
|
86
97
|
"""
|
87
98
|
Check if file is indexed
|
88
99
|
|
@@ -97,7 +108,12 @@ class Files:
|
|
97
108
|
file_id=file_id,
|
98
109
|
)
|
99
110
|
|
100
|
-
def update(
|
111
|
+
def update(
|
112
|
+
self,
|
113
|
+
id: int,
|
114
|
+
doc_id: str,
|
115
|
+
ts: int
|
116
|
+
) -> bool:
|
101
117
|
"""
|
102
118
|
Update timestamp of indexed file
|
103
119
|
|
@@ -112,7 +128,12 @@ class Files:
|
|
112
128
|
ts=ts,
|
113
129
|
)
|
114
130
|
|
115
|
-
def remove(
|
131
|
+
def remove(
|
132
|
+
self,
|
133
|
+
store_id: str,
|
134
|
+
idx: str,
|
135
|
+
doc_id: str
|
136
|
+
):
|
116
137
|
"""
|
117
138
|
Remove document from index
|
118
139
|
|
@@ -126,7 +147,11 @@ class Files:
|
|
126
147
|
doc_id=doc_id,
|
127
148
|
)
|
128
149
|
|
129
|
-
def truncate(
|
150
|
+
def truncate(
|
151
|
+
self,
|
152
|
+
store_id: Optional[str] = None,
|
153
|
+
idx: Optional[str] = None
|
154
|
+
):
|
130
155
|
"""
|
131
156
|
Truncate files from index
|
132
157
|
|
pygpt_net/core/image.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 os
|
13
|
+
from typing import List
|
13
14
|
|
14
15
|
from PySide6.QtCore import Slot, QObject
|
15
16
|
|
@@ -34,7 +35,12 @@ class Image(QObject):
|
|
34
35
|
os.makedirs(img_dir, exist_ok=True)
|
35
36
|
|
36
37
|
@Slot(object, list, str)
|
37
|
-
def handle_finished(
|
38
|
+
def handle_finished(
|
39
|
+
self,
|
40
|
+
ctx: CtxItem,
|
41
|
+
paths: List[str],
|
42
|
+
prompt: str
|
43
|
+
):
|
38
44
|
"""
|
39
45
|
Handle finished image generation
|
40
46
|
|
@@ -45,7 +51,12 @@ class Image(QObject):
|
|
45
51
|
self.window.controller.chat.image.handle_response(ctx, paths, prompt)
|
46
52
|
|
47
53
|
@Slot(object, list, str)
|
48
|
-
def handle_finished_inline(
|
54
|
+
def handle_finished_inline(
|
55
|
+
self,
|
56
|
+
ctx: CtxItem,
|
57
|
+
paths: List[str],
|
58
|
+
prompt: str
|
59
|
+
):
|
49
60
|
"""
|
50
61
|
Handle finished image generation
|
51
62
|
|
@@ -86,7 +97,7 @@ class Image(QObject):
|
|
86
97
|
self.window.update_status(msg)
|
87
98
|
self.window.core.debug.log(msg)
|
88
99
|
|
89
|
-
def save_image(self, path: str, image:
|
100
|
+
def save_image(self, path: str, image: bytes) -> bool:
|
90
101
|
"""
|
91
102
|
Save image to file
|
92
103
|
|
pygpt_net/core/installer.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date:
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
from pathlib import Path
|
@@ -23,9 +23,7 @@ class Installer:
|
|
23
23
|
self.window = window
|
24
24
|
|
25
25
|
def install(self):
|
26
|
-
"""
|
27
|
-
Install db, config data and directories
|
28
|
-
"""
|
26
|
+
"""Install db, config data and directories"""
|
29
27
|
try:
|
30
28
|
# create user config directory
|
31
29
|
path = Path(self.window.core.config.path)
|
pygpt_net/core/llm/__init__.py
CHANGED
@@ -6,9 +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
|
+
from typing import Optional, List
|
13
|
+
|
14
|
+
|
12
15
|
class LLM:
|
13
16
|
def __init__(self, window=None):
|
14
17
|
"""
|
@@ -19,7 +22,10 @@ class LLM:
|
|
19
22
|
self.window = window
|
20
23
|
self.llms = {}
|
21
24
|
|
22
|
-
def get_ids(
|
25
|
+
def get_ids(
|
26
|
+
self,
|
27
|
+
type: Optional[str] = None
|
28
|
+
) -> List[str]:
|
23
29
|
"""
|
24
30
|
Get providers ids
|
25
31
|
|
@@ -30,7 +36,11 @@ class LLM:
|
|
30
36
|
return [id for id in self.llms.keys() if type in self.llms[id].type]
|
31
37
|
return list(self.llms.keys())
|
32
38
|
|
33
|
-
def register(
|
39
|
+
def register(
|
40
|
+
self,
|
41
|
+
id: str,
|
42
|
+
llm
|
43
|
+
):
|
34
44
|
"""
|
35
45
|
Register LLM provider
|
36
46
|
|
pygpt_net/core/locale.py
CHANGED
@@ -6,18 +6,23 @@
|
|
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
12
|
import os
|
13
13
|
import configparser
|
14
14
|
import io
|
15
|
+
from typing import Optional
|
15
16
|
|
16
17
|
from pygpt_net.config import Config
|
17
18
|
|
18
19
|
|
19
20
|
class Locale:
|
20
|
-
def __init__(
|
21
|
+
def __init__(
|
22
|
+
self,
|
23
|
+
domain: Optional[str] = None,
|
24
|
+
config: Optional[Config] = None
|
25
|
+
):
|
21
26
|
"""
|
22
27
|
Locale loader
|
23
28
|
|
@@ -47,7 +52,7 @@ class Locale:
|
|
47
52
|
self.lang = self.config.get_lang()
|
48
53
|
self.load(self.lang)
|
49
54
|
|
50
|
-
def reload(self, domain: str = None):
|
55
|
+
def reload(self, domain: Optional[str] = None):
|
51
56
|
"""
|
52
57
|
Reload translations for domain
|
53
58
|
|
@@ -70,7 +75,11 @@ class Locale:
|
|
70
75
|
ini.read_string(data.read())
|
71
76
|
return dict(ini.items(self.ini_key))
|
72
77
|
|
73
|
-
def load_by_lang(
|
78
|
+
def load_by_lang(
|
79
|
+
self,
|
80
|
+
lang: str,
|
81
|
+
domain: Optional[str] = None
|
82
|
+
):
|
74
83
|
"""
|
75
84
|
Load translation data by language code
|
76
85
|
|
@@ -96,7 +105,11 @@ class Locale:
|
|
96
105
|
except Exception as e:
|
97
106
|
print(e)
|
98
107
|
|
99
|
-
def load(
|
108
|
+
def load(
|
109
|
+
self,
|
110
|
+
lang: str,
|
111
|
+
domain: Optional[str] = None
|
112
|
+
):
|
100
113
|
"""
|
101
114
|
Load translation data
|
102
115
|
|
@@ -109,7 +122,12 @@ class Locale:
|
|
109
122
|
self.load_by_lang(self.fallback, domain) # load fallback first
|
110
123
|
self.load_by_lang(lang, domain)
|
111
124
|
|
112
|
-
def get(
|
125
|
+
def get(
|
126
|
+
self,
|
127
|
+
key: str,
|
128
|
+
domain: Optional[str] = None,
|
129
|
+
params: Optional[dict] = None
|
130
|
+
) -> str:
|
113
131
|
"""
|
114
132
|
Return translation for key and domain
|
115
133
|
|
@@ -133,7 +151,11 @@ class Locale:
|
|
133
151
|
else:
|
134
152
|
return key
|
135
153
|
|
136
|
-
def get_base_path(
|
154
|
+
def get_base_path(
|
155
|
+
self,
|
156
|
+
domain: str,
|
157
|
+
lang: str
|
158
|
+
) -> str:
|
137
159
|
"""
|
138
160
|
Get base path for locale file
|
139
161
|
|
@@ -143,7 +165,11 @@ class Locale:
|
|
143
165
|
"""
|
144
166
|
return os.path.join(self.config.get_app_path(), 'data', 'locale', domain + '.' + lang + '.ini')
|
145
167
|
|
146
|
-
def get_user_path(
|
168
|
+
def get_user_path(
|
169
|
+
self,
|
170
|
+
domain: str,
|
171
|
+
lang: str
|
172
|
+
) -> str:
|
147
173
|
"""
|
148
174
|
Get user path for locale file (overwrites base path)
|
149
175
|
|
pygpt_net/core/models.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 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import copy
|
13
|
+
from typing import Optional, List, Dict
|
13
14
|
|
14
15
|
from packaging.version import Version
|
15
16
|
|
@@ -91,7 +92,7 @@ class Models:
|
|
91
92
|
if key in self.items:
|
92
93
|
return self.items[key]
|
93
94
|
|
94
|
-
def get_ids(self) ->
|
95
|
+
def get_ids(self) -> List[str]:
|
95
96
|
"""
|
96
97
|
Return models ids
|
97
98
|
|
@@ -117,7 +118,11 @@ class Models:
|
|
117
118
|
"""
|
118
119
|
return model in self.items
|
119
120
|
|
120
|
-
def is_allowed(
|
121
|
+
def is_allowed(
|
122
|
+
self,
|
123
|
+
model: str,
|
124
|
+
mode: str
|
125
|
+
) -> bool:
|
121
126
|
"""
|
122
127
|
Check if model is allowed for mode
|
123
128
|
|
@@ -129,7 +134,10 @@ class Models:
|
|
129
134
|
return mode in self.items[model].mode
|
130
135
|
return False
|
131
136
|
|
132
|
-
def get_id(
|
137
|
+
def get_id(
|
138
|
+
self,
|
139
|
+
key: str
|
140
|
+
) -> str:
|
133
141
|
"""
|
134
142
|
Return model internal ID
|
135
143
|
|
@@ -139,7 +147,11 @@ class Models:
|
|
139
147
|
if key in self.items:
|
140
148
|
return self.items[key].id
|
141
149
|
|
142
|
-
def get_by_idx(
|
150
|
+
def get_by_idx(
|
151
|
+
self,
|
152
|
+
idx: int,
|
153
|
+
mode: str
|
154
|
+
) -> str:
|
143
155
|
"""
|
144
156
|
Return model by index
|
145
157
|
|
@@ -150,7 +162,10 @@ class Models:
|
|
150
162
|
items = self.get_by_mode(mode)
|
151
163
|
return list(items.keys())[idx]
|
152
164
|
|
153
|
-
def get_by_mode(
|
165
|
+
def get_by_mode(
|
166
|
+
self,
|
167
|
+
mode: str
|
168
|
+
) -> Dict[str, ModelItem]:
|
154
169
|
"""
|
155
170
|
Return models for mode
|
156
171
|
|
@@ -163,7 +178,11 @@ class Models:
|
|
163
178
|
items[key] = self.items[key]
|
164
179
|
return items
|
165
180
|
|
166
|
-
def get_next(
|
181
|
+
def get_next(
|
182
|
+
self,
|
183
|
+
model: str,
|
184
|
+
mode: str
|
185
|
+
) -> str:
|
167
186
|
"""
|
168
187
|
Return next model
|
169
188
|
|
@@ -178,7 +197,11 @@ class Models:
|
|
178
197
|
return keys[idx + 1]
|
179
198
|
return keys[0]
|
180
199
|
|
181
|
-
def get_prev(
|
200
|
+
def get_prev(
|
201
|
+
self,
|
202
|
+
model: str,
|
203
|
+
mode: str
|
204
|
+
) -> str:
|
182
205
|
"""
|
183
206
|
Return previous model
|
184
207
|
|
@@ -217,7 +240,7 @@ class Models:
|
|
217
240
|
self.items[id] = model
|
218
241
|
return model
|
219
242
|
|
220
|
-
def get_all(self) ->
|
243
|
+
def get_all(self) -> Dict[str, ModelItem]:
|
221
244
|
"""
|
222
245
|
Return all models
|
223
246
|
|
@@ -247,7 +270,11 @@ class Models:
|
|
247
270
|
if model in self.items:
|
248
271
|
del self.items[model]
|
249
272
|
|
250
|
-
def has_model(
|
273
|
+
def has_model(
|
274
|
+
self,
|
275
|
+
mode: str,
|
276
|
+
model: str
|
277
|
+
) -> bool:
|
251
278
|
"""
|
252
279
|
Check if model exists for mode
|
253
280
|
|
@@ -258,7 +285,7 @@ class Models:
|
|
258
285
|
items = self.get_by_mode(mode)
|
259
286
|
return model in items
|
260
287
|
|
261
|
-
def get_default(self, mode: str) -> str
|
288
|
+
def get_default(self, mode: str) -> Optional[str]:
|
262
289
|
"""
|
263
290
|
Return default model for mode
|
264
291
|
|
@@ -295,8 +322,15 @@ class Models:
|
|
295
322
|
return self.items[model].ctx
|
296
323
|
return 4096
|
297
324
|
|
298
|
-
def restore_default(
|
299
|
-
|
325
|
+
def restore_default(
|
326
|
+
self,
|
327
|
+
model: Optional[str] = None
|
328
|
+
):
|
329
|
+
"""
|
330
|
+
Restore default models
|
331
|
+
|
332
|
+
:param model: model name
|
333
|
+
"""
|
300
334
|
# restore all models
|
301
335
|
if model is None:
|
302
336
|
self.load_base()
|
@@ -307,8 +341,12 @@ class Models:
|
|
307
341
|
if model in items:
|
308
342
|
self.items[model] = items[model]
|
309
343
|
|
310
|
-
def get_base(self) ->
|
311
|
-
"""
|
344
|
+
def get_base(self) -> Dict[str, ModelItem]:
|
345
|
+
"""
|
346
|
+
Get base models
|
347
|
+
|
348
|
+
:return: base models
|
349
|
+
"""
|
312
350
|
return self.provider.load_base()
|
313
351
|
|
314
352
|
def load_base(self):
|
@@ -329,7 +367,11 @@ class Models:
|
|
329
367
|
"""Save models"""
|
330
368
|
self.provider.save(self.items)
|
331
369
|
|
332
|
-
def get_supported_mode(
|
370
|
+
def get_supported_mode(
|
371
|
+
self,
|
372
|
+
model: ModelItem,
|
373
|
+
mode: str
|
374
|
+
) -> str:
|
333
375
|
"""
|
334
376
|
Get supported mode
|
335
377
|
|
@@ -352,5 +394,9 @@ class Models:
|
|
352
394
|
return mode
|
353
395
|
|
354
396
|
def get_version(self) -> str:
|
355
|
-
"""
|
397
|
+
"""
|
398
|
+
Get config version
|
399
|
+
|
400
|
+
:return: config version
|
401
|
+
"""
|
356
402
|
return self.provider.get_version()
|