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,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.16 01:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import copy
|
@@ -15,7 +15,9 @@ import shutil
|
|
15
15
|
import uuid
|
16
16
|
|
17
17
|
from shutil import copyfile
|
18
|
-
from typing import Optional, List, Dict, Any
|
18
|
+
from typing import Optional, List, Dict, Any, Tuple
|
19
|
+
|
20
|
+
from llama_index.core import Document
|
19
21
|
|
20
22
|
from pygpt_net.core.bridge import BridgeContext
|
21
23
|
from pygpt_net.core.events import KernelEvent
|
@@ -125,7 +127,7 @@ class Context:
|
|
125
127
|
meta_path = self.get_dir(meta)
|
126
128
|
context = ""
|
127
129
|
if os.path.exists(meta_path) and os.path.isdir(meta_path):
|
128
|
-
for file in meta.
|
130
|
+
for file in meta.get_additional_ctx():
|
129
131
|
if ("type" not in file
|
130
132
|
or file["type"] not in ["local_file", "url"]):
|
131
133
|
continue
|
@@ -183,7 +185,7 @@ class Context:
|
|
183
185
|
|
184
186
|
indexed = False
|
185
187
|
# index files if not indexed by auto_index
|
186
|
-
for i, file in enumerate(meta.
|
188
|
+
for i, file in enumerate(meta.get_additional_ctx()):
|
187
189
|
if "indexed" not in file or not file["indexed"]:
|
188
190
|
file_id = file["uuid"]
|
189
191
|
file_idx_path = os.path.join(meta_path, file_id)
|
@@ -313,7 +315,7 @@ class Context:
|
|
313
315
|
prompt: str,
|
314
316
|
auto_index: bool = False,
|
315
317
|
real_path: Optional[str] = None
|
316
|
-
) ->
|
318
|
+
) -> Dict[str, Any]:
|
317
319
|
"""
|
318
320
|
Upload attachment for context
|
319
321
|
|
@@ -325,7 +327,10 @@ class Context:
|
|
325
327
|
:return: Dict with attachment data
|
326
328
|
"""
|
327
329
|
if self.is_verbose():
|
328
|
-
|
330
|
+
if meta.group:
|
331
|
+
print("Uploading for meta group ID: {}".format(meta.group.id))
|
332
|
+
else:
|
333
|
+
print("Uploading for meta ID: {}".format(meta.id))
|
329
334
|
|
330
335
|
# prepare idx dir
|
331
336
|
name = os.path.basename(attachment.path)
|
@@ -342,11 +347,18 @@ class Context:
|
|
342
347
|
if auto_index:
|
343
348
|
print("Attachments: vector index path: {}".format(index_path))
|
344
349
|
|
345
|
-
|
346
|
-
|
350
|
+
documents = None
|
351
|
+
|
352
|
+
# store content to read, and get docs if type == web
|
353
|
+
src_file, docs = self.store_content(attachment, file_idx_path)
|
354
|
+
if attachment.type == AttachmentItem.TYPE_URL:
|
355
|
+
documents = docs
|
356
|
+
|
357
|
+
# extract text content using data loader, and get docs if type == file
|
358
|
+
content, docs = self.read_content(attachment, src_file, prompt)
|
359
|
+
if attachment.type == AttachmentItem.TYPE_FILE:
|
360
|
+
documents = docs
|
347
361
|
|
348
|
-
# extract text content using data loader
|
349
|
-
content = self.read_content(attachment, src_file, prompt)
|
350
362
|
if content:
|
351
363
|
text_path = os.path.join(file_idx_path, file_id + ".txt")
|
352
364
|
with open(text_path, "w", encoding="utf-8") as f:
|
@@ -372,7 +384,7 @@ class Context:
|
|
372
384
|
source = src_file
|
373
385
|
if attachment.type == AttachmentItem.TYPE_URL:
|
374
386
|
source = attachment.path # URL
|
375
|
-
doc_ids = self.index_attachment(attachment.type, source, index_path)
|
387
|
+
doc_ids = self.index_attachment(attachment.type, source, index_path, documents=documents)
|
376
388
|
|
377
389
|
result = {
|
378
390
|
"name": name,
|
@@ -402,57 +414,61 @@ class Context:
|
|
402
414
|
attachment: AttachmentItem,
|
403
415
|
path: str,
|
404
416
|
prompt: str
|
405
|
-
) -> str:
|
417
|
+
) -> Tuple[str, List[Document]]:
|
406
418
|
"""
|
407
419
|
Read content from attachment
|
408
420
|
|
409
421
|
:param attachment: AttachmentItem instance
|
410
422
|
:param path: source file path
|
411
423
|
:param prompt: user input prompt
|
412
|
-
:return: content
|
424
|
+
:return: text content, list of documents
|
413
425
|
"""
|
414
426
|
content = ""
|
427
|
+
docs = []
|
415
428
|
if attachment.type == AttachmentItem.TYPE_FILE:
|
416
429
|
loader_kwargs = {
|
417
430
|
"prompt": prompt,
|
418
431
|
} # extra loader kwargs
|
419
|
-
content = self.window.core.idx.indexing.read_text_content(
|
432
|
+
content, docs = self.window.core.idx.indexing.read_text_content(
|
420
433
|
path=path,
|
421
434
|
loader_kwargs=loader_kwargs,
|
422
435
|
)
|
423
436
|
elif attachment.type == AttachmentItem.TYPE_URL:
|
424
|
-
# directly from path
|
437
|
+
# directly from before stored path
|
425
438
|
with open(path, "r", encoding="utf-8") as f:
|
426
|
-
content = f.read() # already crawled
|
427
|
-
|
428
|
-
return content
|
439
|
+
content = f.read() # data is already crawled in `store_content`
|
440
|
+
return content, docs
|
429
441
|
|
430
442
|
def store_content(
|
431
443
|
self,
|
432
444
|
attachment: AttachmentItem,
|
433
445
|
dir: str
|
434
|
-
) -> str:
|
446
|
+
) -> Tuple[str, List[Document]]:
|
435
447
|
"""
|
436
448
|
Prepare content for attachment
|
437
449
|
|
438
450
|
:param attachment: AttachmentItem instance
|
439
451
|
:param dir: directory to save content
|
440
|
-
:return:
|
452
|
+
:return: path, list of documents
|
441
453
|
"""
|
442
454
|
path = None
|
455
|
+
docs = []
|
443
456
|
if attachment.type == AttachmentItem.TYPE_FILE:
|
444
|
-
# copy raw file
|
457
|
+
# copy raw file only
|
445
458
|
name = os.path.basename(attachment.path)
|
446
459
|
path = os.path.join(dir, name)
|
447
460
|
if os.path.exists(path):
|
448
461
|
os.remove(path)
|
449
462
|
copyfile(attachment.path, path)
|
450
463
|
elif attachment.type == AttachmentItem.TYPE_URL:
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
464
|
+
loader = attachment.extra.get("loader")
|
465
|
+
input_params = attachment.extra.get("input_params")
|
466
|
+
input_config = attachment.extra.get("input_config")
|
467
|
+
self.window.core.idx.indexing.update_loader_args(loader, input_config) # update config
|
468
|
+
content, docs = self.window.core.idx.indexing.read_web_content(
|
469
|
+
url="",
|
470
|
+
type=loader,
|
471
|
+
extra_args=input_params,
|
456
472
|
)
|
457
473
|
# src file save
|
458
474
|
name = "url.txt"
|
@@ -461,14 +477,14 @@ class Context:
|
|
461
477
|
os.remove(path)
|
462
478
|
with open(path, "w", encoding="utf-8") as f:
|
463
479
|
f.write(content)
|
464
|
-
return path
|
480
|
+
return path, docs
|
465
481
|
|
466
482
|
def index_attachment(
|
467
483
|
self,
|
468
484
|
type: str,
|
469
485
|
source: str,
|
470
486
|
idx_path: str,
|
471
|
-
documents: Optional[
|
487
|
+
documents: Optional[List[Document]] = None
|
472
488
|
) -> list:
|
473
489
|
"""
|
474
490
|
Index attachment
|
@@ -496,7 +512,7 @@ class Context:
|
|
496
512
|
:param meta: CtxMeta instance
|
497
513
|
:return: list of attachments
|
498
514
|
"""
|
499
|
-
return meta.
|
515
|
+
return meta.get_additional_ctx()
|
500
516
|
|
501
517
|
def get_dir(self, meta: CtxMeta) -> str:
|
502
518
|
"""
|
@@ -506,6 +522,8 @@ class Context:
|
|
506
522
|
:return: directory path
|
507
523
|
"""
|
508
524
|
meta_uuid = str(meta.uuid)
|
525
|
+
if meta.group:
|
526
|
+
meta_uuid = str(meta.group.uuid)
|
509
527
|
return os.path.join(self.window.core.config.get_user_dir("ctx_idx"), meta_uuid)
|
510
528
|
|
511
529
|
def get_selected_model(self, mode: str = "summary"):
|
@@ -562,7 +580,7 @@ class Context:
|
|
562
580
|
:param meta: CtxMeta instance
|
563
581
|
:return: number of attachments
|
564
582
|
"""
|
565
|
-
return len(meta.
|
583
|
+
return len(meta.get_additional_ctx())
|
566
584
|
|
567
585
|
def delete(
|
568
586
|
self,
|
@@ -577,11 +595,11 @@ class Context:
|
|
577
595
|
:param item: Attachment item dict
|
578
596
|
:param delete_files: delete files
|
579
597
|
"""
|
580
|
-
meta.
|
598
|
+
meta.remove_additional_ctx(item)
|
581
599
|
self.window.core.ctx.save(meta.id)
|
582
600
|
if delete_files:
|
583
601
|
self.delete_local(meta, item)
|
584
|
-
if len(meta.
|
602
|
+
if len(meta.get_additional_ctx()) == 0:
|
585
603
|
self.delete_index(meta)
|
586
604
|
|
587
605
|
def delete_by_meta(self, meta: CtxMeta):
|
@@ -613,7 +631,7 @@ class Context:
|
|
613
631
|
:param meta: CtxMeta instance
|
614
632
|
:param delete_files: delete files
|
615
633
|
"""
|
616
|
-
meta.
|
634
|
+
meta.reset_additional_ctx()
|
617
635
|
self.window.core.ctx.save(meta.id)
|
618
636
|
if delete_files:
|
619
637
|
self.delete_index(meta)
|
@@ -644,7 +662,7 @@ class Context:
|
|
644
662
|
:param meta: CtxMeta instance
|
645
663
|
:param delete_files: delete files
|
646
664
|
"""
|
647
|
-
meta.
|
665
|
+
meta.reset_additional_ctx()
|
648
666
|
self.window.core.ctx.save(meta.id)
|
649
667
|
if delete_files:
|
650
668
|
self.delete_index(meta)
|
pygpt_net/core/audio/__init__.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.14
|
9
|
+
# Updated Date: 2024.12.14 18:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import re
|
@@ -17,6 +17,8 @@ from bs4 import UnicodeDammit
|
|
17
17
|
from pygpt_net.provider.audio_input.base import BaseProvider as InputBaseProvider
|
18
18
|
from pygpt_net.provider.audio_output.base import BaseProvider as OutputBaseProvider
|
19
19
|
|
20
|
+
from .whisper import Whisper
|
21
|
+
|
20
22
|
|
21
23
|
class Audio:
|
22
24
|
def __init__(self, window=None):
|
@@ -26,6 +28,7 @@ class Audio:
|
|
26
28
|
:param window: Window instance
|
27
29
|
"""
|
28
30
|
self.window = window
|
31
|
+
self.whisper = Whisper(window)
|
29
32
|
self.providers = {
|
30
33
|
"input": {},
|
31
34
|
"output": {},
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# ================================================== #
|
4
|
+
# This file is a part of PYGPT package #
|
5
|
+
# Website: https://pygpt.net #
|
6
|
+
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
|
+
# MIT License #
|
8
|
+
# Created By : Marcin Szczygliński #
|
9
|
+
# Updated Date: 2024.12.14 18:00:00 #
|
10
|
+
# ================================================== #
|
11
|
+
|
12
|
+
from typing import List
|
13
|
+
|
14
|
+
class Whisper:
|
15
|
+
def __init__(self, window=None):
|
16
|
+
"""
|
17
|
+
Whisper core
|
18
|
+
|
19
|
+
:param window: Window instance
|
20
|
+
"""
|
21
|
+
self.window = window
|
22
|
+
self.voices = [
|
23
|
+
"alloy",
|
24
|
+
"echo",
|
25
|
+
"fable",
|
26
|
+
"onyx",
|
27
|
+
"nova",
|
28
|
+
"shimmer",
|
29
|
+
]
|
30
|
+
|
31
|
+
def get_voices(self) -> List[str]:
|
32
|
+
"""
|
33
|
+
Get whisper voices
|
34
|
+
|
35
|
+
:return: whisper voice name
|
36
|
+
"""
|
37
|
+
return self.voices
|
pygpt_net/core/bridge/worker.py
CHANGED
@@ -60,14 +60,14 @@ class BridgeWorker(QObject, QRunnable):
|
|
60
60
|
extra=self.extra,
|
61
61
|
)
|
62
62
|
|
63
|
-
#
|
63
|
+
# LlamaIndex: chat with files
|
64
64
|
elif self.mode == MODE_LLAMA_INDEX:
|
65
65
|
result = self.window.core.idx.chat.call(
|
66
66
|
context=self.context,
|
67
67
|
extra=self.extra,
|
68
68
|
)
|
69
69
|
|
70
|
-
#
|
70
|
+
# LlamaIndex: agents
|
71
71
|
elif self.mode == MODE_AGENT_LLAMA:
|
72
72
|
result = self.window.core.agents.runner.call(
|
73
73
|
context=self.context,
|
pygpt_net/core/db/__init__.py
CHANGED
@@ -122,6 +122,7 @@ class Database:
|
|
122
122
|
'updated_ts',
|
123
123
|
'created_ts',
|
124
124
|
'uuid',
|
125
|
+
'additional_ctx_json',
|
125
126
|
]
|
126
127
|
columns["idx_ctx"] = [
|
127
128
|
'id',
|
@@ -242,7 +243,7 @@ class Database:
|
|
242
243
|
'sort_by': columns["ctx_group"],
|
243
244
|
'search_fields': ['id', 'name'],
|
244
245
|
'timestamp_columns': ['created_ts', 'updated_ts'],
|
245
|
-
'json_columns': [],
|
246
|
+
'json_columns': ['additional_ctx_json'],
|
246
247
|
'default_sort': 'id',
|
247
248
|
'default_order': 'DESC',
|
248
249
|
'primary_key': 'id',
|
pygpt_net/core/debug/events.py
CHANGED
@@ -6,10 +6,17 @@
|
|
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 19:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
|
-
from pygpt_net.core.events import
|
12
|
+
from pygpt_net.core.events import (
|
13
|
+
ControlEvent,
|
14
|
+
AppEvent,
|
15
|
+
Event,
|
16
|
+
KernelEvent,
|
17
|
+
RenderEvent,
|
18
|
+
BaseEvent
|
19
|
+
)
|
13
20
|
|
14
21
|
|
15
22
|
class EventsDebug:
|
@@ -25,19 +32,24 @@ class EventsDebug:
|
|
25
32
|
def update(self):
|
26
33
|
"""Update debug window."""
|
27
34
|
self.window.core.debug.begin(self.id)
|
28
|
-
self.window.core.debug.add(self.id, 'App Events:', str(AppEvent
|
29
|
-
self.window.core.debug.add(self.id, 'Control Events:', str(ControlEvent
|
30
|
-
self.window.core.debug.add(self.id, 'Kernel Events:', str(KernelEvent
|
31
|
-
self.window.core.debug.add(self.id, 'Render Events:', str(RenderEvent
|
32
|
-
self.window.core.debug.add(self.id, 'Plugin Events:', str(self.
|
35
|
+
self.window.core.debug.add(self.id, 'App Events:', str(self.extract_events(AppEvent)))
|
36
|
+
self.window.core.debug.add(self.id, 'Control Events:', str(self.extract_events(ControlEvent)))
|
37
|
+
self.window.core.debug.add(self.id, 'Kernel Events:', str(self.extract_events(KernelEvent)))
|
38
|
+
self.window.core.debug.add(self.id, 'Render Events:', str(self.extract_events(RenderEvent)))
|
39
|
+
self.window.core.debug.add(self.id, 'Plugin Events:', str(self.extract_events(Event)))
|
40
|
+
self.window.core.debug.add(self.id, '----', '')
|
33
41
|
self.window.core.debug.add(self.id, 'Voice Cmds (all):', str(self.window.core.access.voice.commands))
|
34
42
|
self.window.core.debug.add(self.id, 'Voice Cmds (allowed):', str(self.window.core.access.voice.get_commands()))
|
35
43
|
self.window.core.debug.end(self.id)
|
36
44
|
|
37
|
-
def
|
38
|
-
"""
|
45
|
+
def extract_events(self, events: BaseEvent) -> dict:
|
46
|
+
"""
|
47
|
+
Extract events
|
48
|
+
|
49
|
+
:param events: Events class
|
50
|
+
"""
|
39
51
|
result = {}
|
40
|
-
for property, value in vars(
|
52
|
+
for property, value in vars(events).items():
|
41
53
|
if (isinstance(value, str)
|
42
54
|
or isinstance(value, int)
|
43
55
|
or isinstance(value, float)
|
pygpt_net/core/debug/tabs.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.14 17:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
class TabsDebug:
|
@@ -22,10 +22,12 @@ class TabsDebug:
|
|
22
22
|
def update(self):
|
23
23
|
"""Update debug window."""
|
24
24
|
self.window.core.debug.begin(self.id)
|
25
|
-
self.window.core.debug.add(self.id, 'current
|
25
|
+
self.window.core.debug.add(self.id, 'current Col', str(self.window.controller.ui.tabs.get_current_column_idx()))
|
26
26
|
self.window.core.debug.add(self.id, 'current IDX', str(self.window.controller.ui.tabs.get_current_idx()))
|
27
|
+
self.window.core.debug.add(self.id, 'current Tab', str(self.window.controller.ui.tabs.get_current_tab()))
|
28
|
+
self.window.core.debug.add(self.id, 'current PID', str(self.window.controller.ui.tabs.get_current_pid()))
|
27
29
|
self.window.core.debug.add(self.id, 'current Type', str(self.window.controller.ui.tabs.get_current_type()))
|
28
|
-
self.window.core.debug.add(self.id, '
|
30
|
+
self.window.core.debug.add(self.id, '----', '')
|
29
31
|
self.window.core.debug.add(self.id, 'last_pid', str(self.window.core.tabs.last_pid))
|
30
32
|
self.window.core.debug.add(self.id, 'locked', str(self.window.controller.ui.tabs.locked))
|
31
33
|
self.window.core.debug.add(self.id, 'col', str(self.window.controller.ui.tabs.col))
|
@@ -40,6 +42,7 @@ class TabsDebug:
|
|
40
42
|
self.window.core.debug.add(self.id, "PID ["+str(pid)+"]", str(data))
|
41
43
|
|
42
44
|
# mapping PID => meta.id
|
45
|
+
self.window.core.debug.add(self.id, '----', '')
|
43
46
|
self.window.core.debug.add(self.id, 'PID => meta.id', str(self.window.core.ctx.output.mapping))
|
44
47
|
self.window.core.debug.add(self.id, '(last) meta.id => PID', str(self.window.core.ctx.output.last_pids))
|
45
48
|
self.window.core.debug.add(self.id, '(last) PID', str(self.window.core.ctx.output.last_pid))
|
pygpt_net/core/history.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 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import datetime
|
13
13
|
import os
|
14
|
+
from typing import List
|
14
15
|
|
15
16
|
from pygpt_net.item.ctx import CtxItem
|
16
17
|
from pygpt_net.provider.core.history.txt_file import TxtFileProvider
|
@@ -46,7 +47,7 @@ class History:
|
|
46
47
|
# delete all txt history files from history dir
|
47
48
|
self.provider.truncate()
|
48
49
|
|
49
|
-
def remove_items(self, items:
|
50
|
+
def remove_items(self, items: List[CtxItem]):
|
50
51
|
"""
|
51
52
|
Remove items from history (txt files)
|
52
53
|
|
pygpt_net/core/idx/__init__.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.
|
9
|
+
# Updated Date: 2024.12.16 01:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import datetime
|
@@ -24,6 +24,7 @@ from .indexing import Indexing
|
|
24
24
|
from .llm import Llm
|
25
25
|
from .chat import Chat
|
26
26
|
from .metadata import Metadata
|
27
|
+
from .ui import UI
|
27
28
|
|
28
29
|
from .types.ctx import Ctx
|
29
30
|
from .types.external import External
|
@@ -43,6 +44,7 @@ class Idx:
|
|
43
44
|
self.storage = Storage(window)
|
44
45
|
self.chat = Chat(window, self.storage)
|
45
46
|
self.metadata = Metadata(window)
|
47
|
+
self.ui = UI(window)
|
46
48
|
|
47
49
|
self.providers = {
|
48
50
|
"json_file": JsonFileProvider(window), # only for patching
|
@@ -406,7 +408,11 @@ class Idx:
|
|
406
408
|
return self.items[store_id]
|
407
409
|
return {}
|
408
410
|
|
409
|
-
def append(
|
411
|
+
def append(
|
412
|
+
self,
|
413
|
+
idx: str,
|
414
|
+
files: Dict[str, str]
|
415
|
+
):
|
410
416
|
"""
|
411
417
|
Append indexed files to index
|
412
418
|
|
@@ -454,7 +460,11 @@ class Idx:
|
|
454
460
|
self.items[store_id][idx].items[file_id]["id"] = doc_id
|
455
461
|
self.items[store_id][idx].items[file_id]["indexed_ts"] = ts
|
456
462
|
|
457
|
-
def remove_doc(
|
463
|
+
def remove_doc(
|
464
|
+
self,
|
465
|
+
idx: str,
|
466
|
+
doc_id: str
|
467
|
+
):
|
458
468
|
"""
|
459
469
|
Remove document from index
|
460
470
|
|
@@ -465,7 +475,11 @@ class Idx:
|
|
465
475
|
if self.storage.remove_document(idx, doc_id):
|
466
476
|
self.log("Removed document from index: " + idx + " - " + doc_id)
|
467
477
|
|
468
|
-
def remove_file(
|
478
|
+
def remove_file(
|
479
|
+
self,
|
480
|
+
idx: str,
|
481
|
+
file: str
|
482
|
+
):
|
469
483
|
"""
|
470
484
|
Remove file from index
|
471
485
|
|
@@ -517,7 +531,7 @@ class Idx:
|
|
517
531
|
self.items[store_id][idx].id = idx
|
518
532
|
self.items[store_id][idx].name = idx
|
519
533
|
|
520
|
-
def get_idx_ids(self) -> List[str]:
|
534
|
+
def get_idx_ids(self) -> List[Dict[str, str]]:
|
521
535
|
"""
|
522
536
|
Get list of indexes
|
523
537
|
|
@@ -527,7 +541,10 @@ class Idx:
|
|
527
541
|
data = self.window.core.config.get('llama.idx.list')
|
528
542
|
if data is not None:
|
529
543
|
for item in data:
|
530
|
-
|
544
|
+
name = item['name']
|
545
|
+
if name is None or name == "":
|
546
|
+
name = item['id']
|
547
|
+
ids.append({item['id']: name})
|
531
548
|
return ids
|
532
549
|
|
533
550
|
def clear(self, idx: str):
|
pygpt_net/core/idx/chat.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.12.14
|
9
|
+
# Updated Date: 2024.12.14 22:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import json
|
@@ -360,7 +360,7 @@ class Chat:
|
|
360
360
|
ctx: CtxItem,
|
361
361
|
type: str,
|
362
362
|
url: str,
|
363
|
-
args:
|
363
|
+
args: Dict[str, Any],
|
364
364
|
query: str,
|
365
365
|
model: Optional[ModelItem] = None
|
366
366
|
) -> str:
|
@@ -552,7 +552,11 @@ class Chat:
|
|
552
552
|
]
|
553
553
|
return ChatPromptTemplate(qa_msgs)
|
554
554
|
|
555
|
-
def get_index(
|
555
|
+
def get_index(
|
556
|
+
self,
|
557
|
+
idx: str,
|
558
|
+
model: ModelItem
|
559
|
+
):
|
556
560
|
"""
|
557
561
|
Get index instance
|
558
562
|
|
@@ -573,7 +577,10 @@ class Chat:
|
|
573
577
|
index = self.storage.get(idx, service_context=service_context) # get index
|
574
578
|
return index, service_context
|
575
579
|
|
576
|
-
def get_metadata(
|
580
|
+
def get_metadata(
|
581
|
+
self,
|
582
|
+
source_nodes: Optional[list]
|
583
|
+
) -> Dict[str, Any]:
|
577
584
|
"""
|
578
585
|
Get metadata from source nodes
|
579
586
|
|
@@ -601,7 +608,10 @@ class Chat:
|
|
601
608
|
break
|
602
609
|
return metadata
|
603
610
|
|
604
|
-
def parse_metadata(
|
611
|
+
def parse_metadata(
|
612
|
+
self,
|
613
|
+
metadata: Optional[Dict]
|
614
|
+
) -> Dict[str, Any]:
|
605
615
|
"""
|
606
616
|
Parse metadata
|
607
617
|
|