pygpt-net 2.4.36.post1__py3-none-any.whl → 2.4.38__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 +14 -1
- README.md +54 -13
- pygpt_net/CHANGELOG.txt +14 -1
- pygpt_net/__init__.py +3 -3
- pygpt_net/controller/chat/attachment.py +7 -39
- pygpt_net/controller/config/placeholder.py +29 -0
- pygpt_net/controller/lang/mapping.py +2 -2
- pygpt_net/controller/settings/editor.py +6 -0
- pygpt_net/controller/theme/__init__.py +33 -8
- pygpt_net/controller/theme/common.py +22 -1
- pygpt_net/controller/theme/markdown.py +26 -14
- pygpt_net/controller/theme/menu.py +26 -5
- pygpt_net/core/attachments/context.py +145 -53
- pygpt_net/core/audio/__init__.py +59 -1
- pygpt_net/core/bridge/worker.py +16 -2
- pygpt_net/core/events/event.py +2 -1
- pygpt_net/core/filesystem/__init__.py +5 -19
- pygpt_net/core/idx/chat.py +22 -24
- pygpt_net/core/render/web/body.py +31 -15
- pygpt_net/data/config/config.json +11 -5
- pygpt_net/data/config/models.json +3 -3
- pygpt_net/data/config/modes.json +3 -3
- pygpt_net/data/config/settings.json +81 -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} +144 -133
- pygpt_net/data/css/web-chatgpt.css +342 -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 +342 -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/locale/locale.de.ini +16 -3
- pygpt_net/data/locale/locale.en.ini +24 -10
- pygpt_net/data/locale/locale.es.ini +16 -3
- pygpt_net/data/locale/locale.fr.ini +16 -3
- pygpt_net/data/locale/locale.it.ini +16 -3
- pygpt_net/data/locale/locale.pl.ini +17 -4
- pygpt_net/data/locale/locale.uk.ini +16 -3
- pygpt_net/data/locale/locale.zh.ini +17 -4
- pygpt_net/plugin/audio_input/simple.py +17 -3
- pygpt_net/plugin/idx_llama_index/__init__.py +2 -2
- pygpt_net/plugin/real_time/__init__.py +2 -2
- pygpt_net/provider/core/config/patch.py +26 -1
- pygpt_net/ui/menu/config.py +7 -11
- pygpt_net/ui/menu/theme.py +9 -2
- pygpt_net/ui/widget/lists/context.py +1 -0
- pygpt_net/ui/widget/textarea/search_input.py +4 -1
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.38.dist-info}/METADATA +55 -14
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.38.dist-info}/RECORD +55 -49
- /pygpt_net/data/css/{web.dark.css → web-blocks.dark.css} +0 -0
- /pygpt_net/data/css/{web.light.css → web-blocks.light.css} +0 -0
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.38.dist-info}/LICENSE +0 -0
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.38.dist-info}/WHEEL +0 -0
- {pygpt_net-2.4.36.post1.dist-info → pygpt_net-2.4.38.dist-info}/entry_points.txt +0 -0
CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 2.4.38 (2024-12-08)
|
4
|
+
|
5
|
+
- Added the ability to select a style for chat display between: Blocks, ChatGPT-like, and ChatGPT-like Wide. New option in the menu: Config -> Theme -> Style...
|
6
|
+
- Added configuration options for audio input in Settings -> Audio -> Audio Input Device, Channels, and Sampling rate.
|
7
|
+
|
8
|
+
## 2.4.37 (2024-11-30)
|
9
|
+
|
10
|
+
- The `Query only` mode in `Uploaded` tab has been renamed to `RAG`.
|
11
|
+
- New options have been added under `Settings -> Files and Attachments`:
|
12
|
+
- `Use history in RAG query`: When enabled, the content of the entire conversation will be used when preparing a query if the mode is set to RAG or Summary.
|
13
|
+
- `RAG limit`: This option is applicable only if 'Use history in RAG query' is enabled. It specifies the limit on how many recent entries in the conversation will be used when generating a query for RAG. A value of 0 indicates no limit.
|
14
|
+
- Cache: dynamic parts of the system prompt (from plugins) have been moved to the very end of the prompt stack to enable the use of prompt cache mechanisms in OpenAI.
|
15
|
+
|
3
16
|
## 2.4.36 (2024-11-28)
|
4
17
|
|
5
18
|
- Added a new command-line argument: --workdir="/path/to/workdir" to explicitly set the current working directory.
|
@@ -33,7 +46,7 @@
|
|
33
46
|
|
34
47
|
- Added an option checkbox `Auto-index on upload` in the `Attachments` tab:
|
35
48
|
|
36
|
-
**Tip:** To use the `
|
49
|
+
**Tip:** To use the `RAG` mode, the file must be indexed in the vector database. This occurs automatically at the time of upload if the `Auto-index on upload` option in the `Attachments` tab is enabled. When uploading large files, such indexing might take a while - therefore, if you are using the `Full context` option, which does not use the index, you can disable the `Auto-index` option to speed up the upload of the attachment. In this case, it will only be indexed when the `RAG` option is called for the first time, and until then, attachment will be available in the form of `Full context` and `Summary`.
|
37
50
|
|
38
51
|
- Added context menu options in `Uploaded attachments` tab: `Open`, `Open Source directory` and `Open Storage directory`.
|
39
52
|
|
README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://snapcraft.io/pygpt)
|
4
4
|
|
5
|
-
Release: **2.4.
|
5
|
+
Release: **2.4.38** | build: **2024.12.08** | Python: **>=3.10, <3.12**
|
6
6
|
|
7
7
|
> Official website: https://pygpt.net | Documentation: https://pygpt.readthedocs.io
|
8
8
|
>
|
@@ -603,11 +603,11 @@ Built-in file loaders:
|
|
603
603
|
- Webpages (crawling any webpage content)
|
604
604
|
- YouTube (transcriptions)
|
605
605
|
|
606
|
-
You can configure data loaders in `Settings / LlamaIndex / Data Loaders` by providing list of keyword arguments for specified loaders.
|
606
|
+
You can configure data loaders in `Settings / Indexes (LlamaIndex) / Data Loaders` by providing list of keyword arguments for specified loaders.
|
607
607
|
You can also develop and provide your own custom loader and register it within the application.
|
608
608
|
|
609
609
|
LlamaIndex is also integrated with context database - you can use data from database (your context history) as additional context in discussion.
|
610
|
-
Options for indexing existing context history or enabling real-time indexing new ones (from database) are available in `Settings / LlamaIndex` section.
|
610
|
+
Options for indexing existing context history or enabling real-time indexing new ones (from database) are available in `Settings / Indexes (LlamaIndex)` section.
|
611
611
|
|
612
612
|
**WARNING:** remember that when indexing content, API calls to the embedding model are used. Each indexing consumes additional tokens. Always control the number of tokens used on the OpenAI page.
|
613
613
|
|
@@ -669,7 +669,7 @@ You can set the limit of steps in such a loop by going to `Settings -> Agents an
|
|
669
669
|
|
670
670
|
You can change the prompt used for evaluating the response in `Settings -> Prompts -> Agent: evaluation prompt in loop`. Here, you can adjust it to suit your needs, for example, by defining more or less critical feedback for the responses received.
|
671
671
|
|
672
|
-
## Agent (
|
672
|
+
## Agent (Autonomous)
|
673
673
|
|
674
674
|
This is an older version of the Agent mode, still available as legacy. However, it is recommended to use the newer mode: `Agent (LlamaIndex)`.
|
675
675
|
|
@@ -817,11 +817,13 @@ The content from the uploaded attachments will be used in the current conversati
|
|
817
817
|
|
818
818
|
- `Full context`: Provides best results. This mode attaches the entire content of the read file to the user's prompt. This process happens in the background and may require a large number of tokens if you uploaded extensive content.
|
819
819
|
|
820
|
-
- `
|
820
|
+
- `RAG`: The indexed attachment will only be queried in real-time using LlamaIndex. This operation does not require any additional tokens, but it may not provide access to the full content of the file 1:1.
|
821
821
|
|
822
822
|
- `Summary`: When queried, an additional query will be generated in the background and executed by a separate model to summarize the content of the attachment and return the required information to the main model. You can change the model used for summarization in the settings under the `Files and attachments` section.
|
823
823
|
|
824
|
-
|
824
|
+
In the `RAG` and `Summary` mode, you can enable an additional setting by going to `Settings -> Files and attachments -> Use history in RAG query`. This allows for better preparation of queries for RAG. When this option is turned on, the entire conversation context is considered, rather than just the user's last query. This allows for better searching of the index for additional context. In the `RAG limit` option, you can set a limit on how many recent entries in a discussion should be considered (`0 = no limit, default: 3`).
|
825
|
+
|
826
|
+
**Important**: When using `Full context` mode, the entire content of the file is included in the prompt, which can result in high token usage each time. If you want to reduce the number of tokens used, instead use the `RAG` option, which will only query the indexed attachment in the vector database to provide additional context.
|
825
827
|
|
826
828
|
**Images as Additional Context**
|
827
829
|
|
@@ -829,7 +831,7 @@ Files such as jpg, png, and similar images are a special case. By default, image
|
|
829
831
|
|
830
832
|
**Uploading larger files and auto-index**
|
831
833
|
|
832
|
-
To use the `
|
834
|
+
To use the `RAG` mode, the file must be indexed in the vector database. This occurs automatically at the time of upload if the `Auto-index on upload` option in the `Attachments` tab is enabled. When uploading large files, such indexing might take a while - therefore, if you are using the `Full context` option, which does not use the index, you can disable the `Auto-index` option to speed up the upload of the attachment. In this case, it will only be indexed when the `RAG` option is called for the first time, and until then, attachment will be available in the form of `Full context` and `Summary`.
|
833
835
|
|
834
836
|
## Downloading files
|
835
837
|
|
@@ -2678,6 +2680,8 @@ Config -> Settings...
|
|
2678
2680
|
|
2679
2681
|
- `Zoom`: Adjusts the zoom in chat window (web render view). `WebEngine / Chromium` render mode only.
|
2680
2682
|
|
2683
|
+
- `Style (chat)`: Chat style (Blocks, or ChatGPT-like, or ChatGPT-like Wide. `WebEngine / Chromium` render mode only.
|
2684
|
+
|
2681
2685
|
- `Code syntax highlight`: Syntax highlight theme in code blocks. `WebEngine / Chromium` render mode only.
|
2682
2686
|
|
2683
2687
|
- `Font Size (chat window)`: Adjusts the font size in the chat window (plain-text) and notepads.
|
@@ -2700,8 +2704,6 @@ Config -> Settings...
|
|
2700
2704
|
|
2701
2705
|
- `Use theme colors in chat window`: Use color theme in chat window, Default: True.
|
2702
2706
|
|
2703
|
-
- `Disable markdown formatting in output`: Enables plain-text display in output window, Default: False.
|
2704
|
-
|
2705
2707
|
**Files and attachments**
|
2706
2708
|
|
2707
2709
|
- `Store attachments in the workdir upload directory`: Enable to store a local copy of uploaded attachments for future use. Default: True
|
@@ -2710,6 +2712,16 @@ Config -> Settings...
|
|
2710
2712
|
|
2711
2713
|
- `Directory for file downloads`: Subdirectory for downloaded files, e.g. in Assistants mode, inside "data". Default: "download"
|
2712
2714
|
|
2715
|
+
- `Verbose mode`: Enabled verbose mode when using attachment as additional context.
|
2716
|
+
|
2717
|
+
- `Model for querying index`: Model to use for preparing query and querying the index when the RAG option is selected.
|
2718
|
+
|
2719
|
+
- `Model for attachment content summary`: Model to use when generating a summary for the content of a file when the Summary option is selected.
|
2720
|
+
|
2721
|
+
- `Use history in RAG query`: When enabled, the content of the entire conversation will be used when preparing a query if mode is RAG or Summary.
|
2722
|
+
|
2723
|
+
- `RAG limit`: Only if the option `Use history in RAG query` is enabled. Specify the limit of how many recent entries in the conversation will be used when generating a query for RAG. 0 = no limit.
|
2724
|
+
|
2713
2725
|
**Context**
|
2714
2726
|
|
2715
2727
|
- `Context Threshold`: Sets the number of tokens reserved for the model to respond to the next prompt.
|
@@ -2802,14 +2814,22 @@ Config -> Settings...
|
|
2802
2814
|
|
2803
2815
|
**Vision**
|
2804
2816
|
|
2817
|
+
- `Vision: Camera Input Device`: Video capture camera index (index of the camera, default: 0).
|
2818
|
+
|
2805
2819
|
- `Vision: Camera capture width (px)`: Video capture resolution (width).
|
2806
2820
|
|
2807
2821
|
- `Vision: Camera capture height (px)`: Video capture resolution (height).
|
2808
2822
|
|
2809
|
-
- `Vision: Camera IDX (number)`: Video capture camera index (number of camera).
|
2810
|
-
|
2811
2823
|
- `Vision: Image capture quality`: Video capture image JPEG quality (%).
|
2812
2824
|
|
2825
|
+
**Audio**
|
2826
|
+
|
2827
|
+
- `Audio Input Device`: Selects the audio device for Microphone input.
|
2828
|
+
|
2829
|
+
- `Channels`: Input channels, default: 1
|
2830
|
+
|
2831
|
+
- `Sampling Rate`: Sampling rate, default: 44100
|
2832
|
+
|
2813
2833
|
**Indexes (LlamaIndex)**
|
2814
2834
|
|
2815
2835
|
- `Indexes`: List of created indexes.
|
@@ -3247,7 +3267,7 @@ If you want to only query index (without chat) you can enable `Query index only
|
|
3247
3267
|
|
3248
3268
|
You can create a custom vector store provider or data loader for your data and develop a custom launcher for the application.
|
3249
3269
|
|
3250
|
-
See the section `Extending PyGPT / Adding custom Vector Store provider` for more details.
|
3270
|
+
See the section `Extending PyGPT / Adding a custom Vector Store provider` for more details.
|
3251
3271
|
|
3252
3272
|
# Updates
|
3253
3273
|
|
@@ -3545,6 +3565,8 @@ Syntax: `event name` - triggered on, `event data` *(data type)*:
|
|
3545
3565
|
|
3546
3566
|
- `AI_NAME` - when preparing an AI name, `data['value']` *(string, name of the AI assistant)*
|
3547
3567
|
|
3568
|
+
- `AGENT_PROMPT` - on agent prompt in eval mode, `data['value']` *(string, prompt)*
|
3569
|
+
|
3548
3570
|
- `AUDIO_INPUT_RECORD_START` - start audio input recording
|
3549
3571
|
|
3550
3572
|
- `AUDIO_INPUT_RECORD_STOP` - stop audio input recording
|
@@ -3603,10 +3625,16 @@ Syntax: `event name` - triggered on, `event data` *(data type)*:
|
|
3603
3625
|
|
3604
3626
|
- `POST_PROMPT` - after preparing a system prompt, `data['value']` *(string, system prompt)*
|
3605
3627
|
|
3628
|
+
- `POST_PROMPT_ASYNC` - after preparing a system prompt, just before request in async thread, `data['value']` *(string, system prompt)*
|
3629
|
+
|
3630
|
+
- `POST_PROMPT_END` - after preparing a system prompt, just before request in async thread, at the very end `data['value']` *(string, system prompt)*
|
3631
|
+
|
3606
3632
|
- `PRE_PROMPT` - before preparing a system prompt, `data['value']` *(string, system prompt)*
|
3607
3633
|
|
3608
3634
|
- `SYSTEM_PROMPT` - when preparing a system prompt, `data['value']` *(string, system prompt)*
|
3609
3635
|
|
3636
|
+
- `TOOL_OUTPUT_RENDER` - when rendering extra content from tools from plugins, `data['content']` *(string, content)*
|
3637
|
+
|
3610
3638
|
- `UI_ATTACHMENTS` - when the attachment upload elements are rendered, `data['value']` *(bool, show True/False)*
|
3611
3639
|
|
3612
3640
|
- `UI_VISION` - when the vision elements are rendered, `data['value']` *(bool, show True/False)*
|
@@ -3845,6 +3873,19 @@ may consume additional tokens that are not displayed in the main window.
|
|
3845
3873
|
|
3846
3874
|
## Recent changes:
|
3847
3875
|
|
3876
|
+
**2.4.38 (2024-12-08)**
|
3877
|
+
|
3878
|
+
- Added the ability to select a style for chat display between: Blocks, ChatGPT-like, and ChatGPT-like Wide. New option in the menu: Config -> Theme -> Style...
|
3879
|
+
- Added configuration options for audio input in Settings -> Audio -> Audio Input Device, Channels, and Sampling rate.
|
3880
|
+
|
3881
|
+
**2.4.37 (2024-11-30)**
|
3882
|
+
|
3883
|
+
- The `Query only` mode in `Uploaded` tab has been renamed to `RAG`.
|
3884
|
+
- New options have been added under `Settings -> Files and Attachments`:
|
3885
|
+
- `Use history in RAG query`: When enabled, the content of the entire conversation will be used when preparing a query if the mode is set to RAG or Summary.
|
3886
|
+
- `RAG limit`: This option is applicable only if 'Use history in RAG query' is enabled. It specifies the limit on how many recent entries in the conversation will be used when generating a query for RAG. A value of 0 indicates no limit.
|
3887
|
+
- Cache: dynamic parts of the system prompt (from plugins) have been moved to the very end of the prompt stack to enable the use of prompt cache mechanisms in OpenAI.
|
3888
|
+
|
3848
3889
|
**2.4.36 (2024-11-28)**
|
3849
3890
|
|
3850
3891
|
- Added a new command-line argument: --workdir="/path/to/workdir" to explicitly set the current working directory.
|
@@ -3878,7 +3919,7 @@ may consume additional tokens that are not displayed in the main window.
|
|
3878
3919
|
|
3879
3920
|
- Added an option checkbox `Auto-index on upload` in the `Attachments` tab:
|
3880
3921
|
|
3881
|
-
**Tip:** To use the `
|
3922
|
+
**Tip:** To use the `RAG` mode, the file must be indexed in the vector database. This occurs automatically at the time of upload if the `Auto-index on upload` option in the `Attachments` tab is enabled. When uploading large files, such indexing might take a while - therefore, if you are using the `Full context` option, which does not use the index, you can disable the `Auto-index` option to speed up the upload of the attachment. In this case, it will only be indexed when the `RAG` option is called for the first time, and until then, attachment will be available in the form of `Full context` and `Summary`.
|
3882
3923
|
|
3883
3924
|
- Added context menu options in `Uploaded attachments` tab: `Open`, `Open Source directory` and `Open Storage directory`.
|
3884
3925
|
|
pygpt_net/CHANGELOG.txt
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
2.4.38 (2024-12-08)
|
2
|
+
|
3
|
+
- Added the ability to select a style for chat display between: Blocks, ChatGPT-like, and ChatGPT-like Wide. New option in the menu: Config -> Theme -> Style...
|
4
|
+
- Added configuration options for audio input in Settings -> Audio -> Audio Input Device, Channels, and Sampling rate.
|
5
|
+
|
6
|
+
2.4.37 (2024-11-30)
|
7
|
+
|
8
|
+
- The `Query only` mode in `Uploaded` tab has been renamed to `RAG`.
|
9
|
+
- New options have been added under `Settings -> Files and Attachments`:
|
10
|
+
- `Use history in RAG query`: When enabled, the content of the entire conversation will be used when preparing a query if the mode is set to RAG or Summary.
|
11
|
+
- `RAG limit`: This option is applicable only if 'Use history in RAG query' is enabled. It specifies the limit on how many recent entries in the conversation will be used when generating a query for RAG. A value of 0 indicates no limit.
|
12
|
+
- Cache: dynamic parts of the system prompt (from plugins) have been moved to the very end of the prompt stack to enable the use of prompt cache mechanisms in OpenAI.
|
13
|
+
|
1
14
|
2.4.36 (2024-11-28)
|
2
15
|
|
3
16
|
- Added a new command-line argument: --workdir="/path/to/workdir" to explicitly set the current working directory.
|
@@ -31,7 +44,7 @@
|
|
31
44
|
|
32
45
|
- Added an option checkbox `Auto-index on upload` in the `Attachments` tab:
|
33
46
|
|
34
|
-
Tip: To use the `
|
47
|
+
Tip: To use the `RAG` mode, the file must be indexed in the vector database. This occurs automatically at the time of upload if the `Auto-index on upload` option in the `Attachments` tab is enabled. When uploading large files, such indexing might take a while - therefore, if you are using the `Full context` option, which does not use the index, you can disable the `Auto-index` option to speed up the upload of the attachment. In this case, it will only be indexed when the `RAG` option is called for the first time, and until then, attachment will be available in the form of `Full context` and `Summary`.
|
35
48
|
|
36
49
|
- Added context menu options in `Uploaded attachments` tab: `Open`, `Open Source directory` and `Open Storage directory`.
|
37
50
|
|
pygpt_net/__init__.py
CHANGED
@@ -6,15 +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.08 01:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
__author__ = "Marcin Szczygliński"
|
13
13
|
__copyright__ = "Copyright 2024, Marcin Szczygliński"
|
14
14
|
__credits__ = ["Marcin Szczygliński"]
|
15
15
|
__license__ = "MIT"
|
16
|
-
__version__ = "2.4.
|
17
|
-
__build__ = "2024.
|
16
|
+
__version__ = "2.4.38"
|
17
|
+
__build__ = "2024.12.08"
|
18
18
|
__maintainer__ = "Marcin Szczygliński"
|
19
19
|
__github__ = "https://github.com/szczyglis-dev/py-gpt"
|
20
20
|
__website__ = "https://pygpt.net"
|
@@ -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.11.
|
9
|
+
# Updated Date: 2024.11.29 23:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
@@ -261,26 +261,22 @@ class Attachment(QObject):
|
|
261
261
|
"""
|
262
262
|
return self.mode
|
263
263
|
|
264
|
-
def get_context(self, ctx: CtxItem) -> str:
|
264
|
+
def get_context(self, ctx: CtxItem, history: list) -> str:
|
265
265
|
"""
|
266
266
|
Get additional context for attachment
|
267
267
|
|
268
268
|
:param ctx: CtxItem instance
|
269
|
+
:param history Context items (history)
|
269
270
|
:return: Additional context
|
270
271
|
"""
|
271
|
-
content = ""
|
272
|
-
meta = ctx.meta
|
273
272
|
if self.mode != self.MODE_DISABLED:
|
274
273
|
if self.is_verbose():
|
275
274
|
print("\nPreparing additional context...\nContext Mode: {}".format(self.mode))
|
276
275
|
|
277
|
-
self.window.core.attachments.context.reset()
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
content = self.get_query_context(meta, str(ctx.input))
|
282
|
-
elif self.mode == self.MODE_QUERY_CONTEXT_SUMMARY:
|
283
|
-
content = self.get_context_summary(ctx)
|
276
|
+
self.window.core.attachments.context.reset() # reset used files and urls
|
277
|
+
|
278
|
+
# get additional context from attachments
|
279
|
+
content = self.window.core.attachments.context.get_context(self.mode, ctx, history)
|
284
280
|
|
285
281
|
# append used files and urls to context
|
286
282
|
files = self.window.core.attachments.context.get_used_files()
|
@@ -296,34 +292,6 @@ class Attachment(QObject):
|
|
296
292
|
return "====================================\nADDITIONAL CONTEXT FROM ATTACHMENT(s): {}".format(content)
|
297
293
|
return ""
|
298
294
|
|
299
|
-
def get_full_context(self, ctx: CtxItem) -> str:
|
300
|
-
"""
|
301
|
-
Get full context for attachment
|
302
|
-
|
303
|
-
:param ctx: CtxItem instance
|
304
|
-
:return: Full context
|
305
|
-
"""
|
306
|
-
return self.window.core.attachments.context.get_context_text(ctx, filename=True)
|
307
|
-
|
308
|
-
def get_query_context(self, meta: CtxMeta, query: str) -> str:
|
309
|
-
"""
|
310
|
-
Get query context for attachment
|
311
|
-
|
312
|
-
:param meta: CtxMeta instance
|
313
|
-
:param query: Query string
|
314
|
-
:return: Query context
|
315
|
-
"""
|
316
|
-
return self.window.core.attachments.context.query_context(meta, query)
|
317
|
-
|
318
|
-
def get_context_summary(self, ctx: CtxItem) -> str:
|
319
|
-
"""
|
320
|
-
Get context summary
|
321
|
-
|
322
|
-
:param ctx: CtxItem instance
|
323
|
-
:return: Context summary
|
324
|
-
"""
|
325
|
-
return self.window.core.attachments.context.summary_context(ctx, ctx.input)
|
326
|
-
|
327
295
|
def get_uploaded_attachments(self, meta: CtxMeta) -> list:
|
328
296
|
"""
|
329
297
|
Get uploaded attachments for meta
|
@@ -86,6 +86,8 @@ class Placeholder:
|
|
86
86
|
return self.get_agent_providers()
|
87
87
|
elif id == "syntax_styles":
|
88
88
|
return self.get_syntax_styles()
|
89
|
+
elif id == "styles":
|
90
|
+
return self.get_styles()
|
89
91
|
elif id == "idx":
|
90
92
|
return self.get_idx()
|
91
93
|
elif id == "keys":
|
@@ -98,9 +100,23 @@ class Placeholder:
|
|
98
100
|
return self.get_speech_synthesis_actions()
|
99
101
|
elif id == "voice_control_actions":
|
100
102
|
return self.get_voice_control_actions()
|
103
|
+
elif id == "audio_input_devices":
|
104
|
+
return self.get_audio_input_devices()
|
101
105
|
else:
|
102
106
|
return []
|
103
107
|
|
108
|
+
def get_audio_input_devices(self) -> list:
|
109
|
+
"""
|
110
|
+
Get audio input devices list
|
111
|
+
|
112
|
+
:return: placeholders list
|
113
|
+
"""
|
114
|
+
devices = self.window.core.audio.get_input_devices()
|
115
|
+
data = []
|
116
|
+
for device in devices:
|
117
|
+
data.append({str(device[0]): device[1]})
|
118
|
+
return data
|
119
|
+
|
104
120
|
def get_langchain_providers(self) -> list:
|
105
121
|
"""
|
106
122
|
Get Langchain LLM provider placeholders list
|
@@ -276,6 +292,19 @@ class Placeholder:
|
|
276
292
|
data.append({id: id})
|
277
293
|
return data
|
278
294
|
|
295
|
+
def get_styles(self) -> list:
|
296
|
+
"""
|
297
|
+
Get styles list
|
298
|
+
|
299
|
+
:return: placeholders list
|
300
|
+
"""
|
301
|
+
styles = self.window.controller.theme.common.get_styles_list()
|
302
|
+
styles.sort()
|
303
|
+
data = []
|
304
|
+
for id in styles:
|
305
|
+
data.append({id: id})
|
306
|
+
return data
|
307
|
+
|
279
308
|
def get_keys(self) -> list:
|
280
309
|
"""
|
281
310
|
Get keys
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.07 21:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
from pygpt_net.utils import trans
|
@@ -357,7 +357,7 @@ class Mapping:
|
|
357
357
|
menu_text['config.profile.new'] = 'menu.config.profile.new'
|
358
358
|
menu_text['config.save'] = 'menu.config.save'
|
359
359
|
menu_text['theme.tooltips'] = 'menu.theme.tooltips'
|
360
|
-
menu_text['theme.
|
360
|
+
menu_text['theme.style'] = 'menu.theme.style'
|
361
361
|
menu_text['theme.settings'] = 'menu.theme.settings'
|
362
362
|
menu_text['plugins.presets.new'] = 'menu.plugins.presets.new'
|
363
363
|
menu_text['plugins.presets.edit'] = 'menu.plugins.presets.edit'
|
@@ -63,6 +63,7 @@ class Editor:
|
|
63
63
|
self.window.ui.add_hook("update.config.debug", self.hook_update)
|
64
64
|
self.window.ui.add_hook("update.config.notepad.num", self.hook_update)
|
65
65
|
self.window.ui.add_hook("update.config.render.code_syntax", self.hook_update)
|
66
|
+
self.window.ui.add_hook("update.config.theme.style", self.hook_update)
|
66
67
|
# self.window.ui.add_hook("llama.idx.storage", self.hook_update) # vector store update
|
67
68
|
# self.window.ui.add_hook("update.config.llama.idx.list", self.hook_update)
|
68
69
|
|
@@ -163,6 +164,11 @@ class Editor:
|
|
163
164
|
value = self.window.core.config.get('render.code_syntax')
|
164
165
|
self.window.controller.theme.toggle_syntax(value, update_menu=True)
|
165
166
|
|
167
|
+
# style
|
168
|
+
if self.config_changed('theme.style'):
|
169
|
+
value = self.window.core.config.get('theme.style')
|
170
|
+
self.window.controller.theme.toggle_style(value)
|
171
|
+
|
166
172
|
# convert lists
|
167
173
|
if self.config_changed('ctx.convert_lists'):
|
168
174
|
self.window.controller.ctx.refresh()
|
@@ -6,17 +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.07 21:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
13
13
|
|
14
|
+
from pygpt_net.core.events import RenderEvent
|
15
|
+
|
14
16
|
from .common import Common
|
15
17
|
from .markdown import Markdown
|
16
18
|
from .menu import Menu
|
17
19
|
from .nodes import Nodes
|
18
|
-
from ...core.events import RenderEvent
|
19
|
-
|
20
20
|
|
21
21
|
class Theme:
|
22
22
|
def __init__(self, window=None):
|
@@ -68,11 +68,22 @@ class Theme:
|
|
68
68
|
# update themes menu
|
69
69
|
self.menu.update_list()
|
70
70
|
self.menu.update_syntax()
|
71
|
-
self.window.ui.menu['theme.blocks'].setChecked(self.window.core.config.get("render.blocks"))
|
72
71
|
|
73
72
|
if force:
|
74
73
|
self.window.controller.ui.restore_state() # restore state after theme change
|
75
74
|
|
75
|
+
def toggle_style(self, name: str):
|
76
|
+
"""
|
77
|
+
Toggle theme style (web)
|
78
|
+
|
79
|
+
:param name: web style name
|
80
|
+
"""
|
81
|
+
self.window.core.config.set('theme.style', name)
|
82
|
+
self.window.core.config.save()
|
83
|
+
event = RenderEvent(RenderEvent.ON_THEME_CHANGE)
|
84
|
+
self.window.dispatch(event)
|
85
|
+
self.reload()
|
86
|
+
|
76
87
|
def toggle_option(self, name: str, value: any = None):
|
77
88
|
"""
|
78
89
|
Toggle theme menu option
|
@@ -120,10 +131,24 @@ class Theme:
|
|
120
131
|
if update_menu:
|
121
132
|
self.menu.update_syntax()
|
122
133
|
|
134
|
+
def update_style(self):
|
135
|
+
"""Update style"""
|
136
|
+
current = self.window.core.config.get('theme.style')
|
137
|
+
self.toggle_style(current)
|
138
|
+
|
139
|
+
def update_theme(self, force: bool = True):
|
140
|
+
"""
|
141
|
+
Update theme
|
142
|
+
|
143
|
+
:param force: force theme change (manual trigger)
|
144
|
+
"""
|
145
|
+
current = self.window.core.config.get('theme')
|
146
|
+
self.toggle(current, force=force)
|
147
|
+
|
123
148
|
def update_syntax(self):
|
124
149
|
"""Update syntax menu"""
|
125
|
-
|
126
|
-
self.toggle_syntax(
|
150
|
+
current = self.window.core.config.get('render.code_syntax')
|
151
|
+
self.toggle_syntax(current, update_menu=True)
|
127
152
|
|
128
153
|
def reload(self, force: bool = True):
|
129
154
|
"""
|
@@ -131,8 +156,7 @@ class Theme:
|
|
131
156
|
|
132
157
|
:param force: force theme change (manual trigger)
|
133
158
|
"""
|
134
|
-
|
135
|
-
self.toggle(current, force=force)
|
159
|
+
self.update_theme(force=force)
|
136
160
|
|
137
161
|
def apply(self, theme: str = 'dark_teal.xml', custom: str = None):
|
138
162
|
"""
|
@@ -183,4 +207,5 @@ class Theme:
|
|
183
207
|
def reload_all(self):
|
184
208
|
"""Reload all"""
|
185
209
|
self.setup()
|
210
|
+
self.update_style()
|
186
211
|
self.update_syntax()
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.07 21:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
@@ -156,3 +156,24 @@ class Common:
|
|
156
156
|
with open(path) as file:
|
157
157
|
content += file.read()
|
158
158
|
return content
|
159
|
+
|
160
|
+
def get_styles_list(self) -> list:
|
161
|
+
"""
|
162
|
+
Return a list of available styles
|
163
|
+
|
164
|
+
:return: list of styles names
|
165
|
+
"""
|
166
|
+
styles = []
|
167
|
+
app_dir = os.path.join(self.window.core.config.get_app_path(), 'data', 'css')
|
168
|
+
user_dir = os.path.join(self.window.core.config.path, 'css')
|
169
|
+
for path in [app_dir, user_dir]:
|
170
|
+
if not os.path.exists(path):
|
171
|
+
continue
|
172
|
+
for file in os.listdir(path):
|
173
|
+
if file.startswith("web-") and file.endswith('.css'):
|
174
|
+
to_replace = ['web-', '.css', '.light', '.dark']
|
175
|
+
for item in to_replace:
|
176
|
+
file = file.replace(item, '')
|
177
|
+
if file not in styles:
|
178
|
+
styles.append(file)
|
179
|
+
return sorted(styles)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# GitHub: https://github.com/szczyglis-dev/py-gpt #
|
7
7
|
# MIT License #
|
8
8
|
# Created By : Marcin Szczygliński #
|
9
|
-
# Updated Date: 2024.
|
9
|
+
# Updated Date: 2024.12.07 21:00:00 #
|
10
10
|
# ================================================== #
|
11
11
|
|
12
12
|
import os
|
@@ -23,6 +23,7 @@ class Markdown:
|
|
23
23
|
"""
|
24
24
|
self.window = window
|
25
25
|
self.css = {} # external styles
|
26
|
+
self.web_style = ""
|
26
27
|
|
27
28
|
def update(self, force: bool = False):
|
28
29
|
"""
|
@@ -60,7 +61,8 @@ class Markdown:
|
|
60
61
|
|
61
62
|
:return: stylesheet
|
62
63
|
"""
|
63
|
-
|
64
|
+
web_style = self.window.core.config.get("theme.style", "blocks")
|
65
|
+
if "web" not in self.css or self.web_style != web_style:
|
64
66
|
self.load()
|
65
67
|
if "web" in self.css:
|
66
68
|
return self.css["web"]
|
@@ -73,31 +75,41 @@ class Markdown:
|
|
73
75
|
self.window.dispatch(event) # per current engine
|
74
76
|
self.window.controller.ctx.refresh()
|
75
77
|
self.window.controller.ctx.refresh_output()
|
76
|
-
|
78
|
+
event = RenderEvent(RenderEvent.END, {
|
77
79
|
"meta": meta,
|
78
|
-
}
|
79
|
-
event = RenderEvent(RenderEvent.END, data)
|
80
|
+
})
|
80
81
|
self.window.dispatch(event)
|
81
82
|
|
82
83
|
def load(self):
|
83
84
|
"""Load markdown styles"""
|
84
|
-
parents = [
|
85
|
+
parents = [
|
86
|
+
"markdown",
|
87
|
+
"web",
|
88
|
+
]
|
89
|
+
web_style = self.window.core.config.get("theme.style", "blocks")
|
85
90
|
for base_name in parents:
|
91
|
+
suffix = ""
|
92
|
+
if base_name == 'web':
|
93
|
+
suffix = "-" + web_style
|
94
|
+
self.web_style = web_style
|
86
95
|
theme = self.window.core.config.get('theme')
|
87
96
|
name = str(base_name)
|
88
|
-
color_name = str(base_name)
|
89
97
|
if theme.startswith('light'):
|
90
|
-
|
98
|
+
color = '.light'
|
91
99
|
else:
|
92
|
-
|
100
|
+
color = '.dark'
|
101
|
+
|
102
|
+
# load CSS, app + user
|
103
|
+
file_base = name + suffix + '.css'
|
104
|
+
file_color = name + suffix + color + '.css'
|
93
105
|
paths = []
|
94
|
-
paths.append(os.path.join(self.window.core.config.get_app_path(), 'data', 'css',
|
95
|
-
paths.append(os.path.join(self.window.core.config.get_app_path(), 'data', 'css',
|
96
|
-
paths.append(os.path.join(self.window.core.config.get_user_path(), 'css',
|
97
|
-
paths.append(os.path.join(self.window.core.config.get_user_path(), 'css',
|
106
|
+
paths.append(os.path.join(self.window.core.config.get_app_path(), 'data', 'css', file_base))
|
107
|
+
paths.append(os.path.join(self.window.core.config.get_app_path(), 'data', 'css', file_color))
|
108
|
+
paths.append(os.path.join(self.window.core.config.get_user_path(), 'css', file_base))
|
109
|
+
paths.append(os.path.join(self.window.core.config.get_user_path(), 'css', file_color))
|
98
110
|
content = ''
|
99
111
|
for path in paths:
|
100
|
-
if os.path.exists(path):
|
112
|
+
if os.path.exists(path) and os.path.isfile(path):
|
101
113
|
with open(path, 'r') as file:
|
102
114
|
content += file.read()
|
103
115
|
|