Skip to content

Commit

Permalink
UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
szczyglis-dev committed Dec 12, 2023
1 parent 698cf44 commit 587af58
Show file tree
Hide file tree
Showing 21 changed files with 225 additions and 89 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PYGPT v2

Release: **2.0.20** build: **2023.12.11** | Official website: https://pygpt.net | Docs: https://pygpt.readthedocs.io
Release: **2.0.21** build: **2023.12.12** | Official website: https://pygpt.net | Docs: https://pygpt.readthedocs.io

PyPi: https://pypi.org/project/pygpt-net

Expand Down Expand Up @@ -1077,6 +1077,13 @@ may consume additional tokens that are not displayed in the main window.

# CHANGELOG

## 2.0.21 (2023-12-12)

- Simplified assistant configuration
- Added assistant configuration validation
- Improved UI
- Improved language switcher

## 2.0.20 (2023-12-11)

- Improved Assistants API
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = 'PYGPT'
copyright = '2023, pygpt.net'
author = 'szczyglis-dev, Marcin Szczygliński'
release = '2.0.20'
release = '2.0.21'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
PYGPT v2 - pygpt.net
====================

| **Last update:** 2023-12-11 23:00
| **Last update:** 2023-12-12 01:00
| **Project website:** https://pygpt.net
| **GitHub:** https://github.com/szczyglis-dev/py-gpt
| **PyPI:** https://pypi.org/project/pygpt-net
| **Release:** 2.0.20 (2023-12-11)
| **Release:** 2.0.21 (2023-12-12)
.. toctree::
:maxdepth: 3
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pygpt-net"
version = "2.0.20"
version = "2.0.21"
description = "Desktop AI Assistant powered by GPT-4, GPT-4V, GPT-3, Whisper, TTS and DALL-E 3 with chatbot, assistant, text completion, vision and image generation, real-time internet access, commands and code execution, files upload and download and more"
readme = "README.md"
authors = [{ name = "Marcin Szczygliński", email = "[email protected]" }]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '2.0.20'
VERSION = '2.0.21'
DESCRIPTION = 'Desktop AI Assistant powered by GPT-4, GPT-4V, GPT-3, Whisper, TTS and DALL-E 3 with chatbot, assistant, text completion, ' \
'vision and image generation, real-time internet access, commands and code execution, files upload and download and more'
LONG_DESCRIPTION = 'Package containing a GPT-4, GPT-4V, GPT-3, Whisper, TTS and DALL-E 3 AI desktop assistant with chatbot, ' \
Expand All @@ -19,7 +19,7 @@
maintainer_email='[email protected]',
packages=find_packages('src'),
package_dir={'': 'src'},
package_data={'': ['CHANGELOG.txt', 'data/*', 'data/locale/*', 'data/config/*', 'data/config/presets/*']},
package_data={'': ['CHANGELOG.txt', 'data/*', 'data/css/*', 'data/fonts/*', 'data/fonts/Lato/*', 'data/locale/*', 'data/config/*', 'data/config/presets/*']},
url='https://github.com/szczyglis-dev/py-gpt',
keywords='py_gpt, py-gpt, pygpt, desktop, app, gpt, gpt4, gpt4-v, gpt3, gpt-4, gpt-3, tts, whisper, vision, chatgpt, dall-e, '
'chat, chatbot, assistant, text completion, image generation, ai, api, openai, api key, context memory, '
Expand Down
7 changes: 7 additions & 0 deletions src/pygpt_net/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.0.21 (2023-12-12)

- Simplified assistant configuration
- Added assistant configuration validation
- Improved UI
- Improved language switcher

2.0.20 (2023-12-11)

- Improved Assistants API
Expand Down
6 changes: 3 additions & 3 deletions src/pygpt_net/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# GitHub: https://github.com/szczyglis-dev/py-gpt #
# MIT License #
# Created By : Marcin Szczygliński #
# Updated Date: 2023.12.11 23:00:00 #
# Updated Date: 2023.12.12 01:00:00 #
# ================================================== #

__author__ = "Marcin Szczygliński"
__copyright__ = "Copyright 2023, Marcin Szczygliński"
__credits__ = ["Marcin Szczygliński"]
__license__ = "MIT"
__version__ = "2.0.20"
__build__ = "2023.12.11"
__version__ = "2.0.21"
__build__ = "2023.12.12"
__maintainer__ = "Marcin Szczygliński"
__github__ = "https://github.com/szczyglis-dev/py-gpt"
__website__ = "https://pygpt.net"
Expand Down
18 changes: 17 additions & 1 deletion src/pygpt_net/core/controller/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ def init_editor(self, id=None):
assistant = self.assistants.create()
assistant.model = "gpt-4-1106-preview" # default model

# if editing existing assistant
if id is not None and id != "":
if self.assistants.has(id):
assistant = self.assistants.get_by_id(id)
else:
# default instructions
assistant.instructions = 'You are a helpful assistant.'

if assistant.name is None:
assistant.name = ""
Expand Down Expand Up @@ -284,8 +288,20 @@ def assign_data(self, assistant):
'retrieval': self.window.config_option['assistant.tool.retrieval'].box.isChecked(),
'function': [], # functions are assigned separately
}

# assign functions
functions = self.window.config_option['assistant.tool.function'].items
functions = []
for function in self.window.config_option['assistant.tool.function'].items:
name = function['name']
params = function['params']
desc = function['desc']
if name is None or name == "":
continue
if params is None or params == "":
params = '{"type": "object", "properties": {}}'
if desc is None:
desc = ""
functions.append({"name": name, "params": params, "desc": desc})
if len(functions) > 0:
assistant.tools['function'] = functions

Expand Down
69 changes: 58 additions & 11 deletions src/pygpt_net/core/controller/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# GitHub: https://github.com/szczyglis-dev/py-gpt #
# MIT License #
# Created By : Marcin Szczygliński #
# Updated Date: 2023.12.05 22:00:00 #
# Updated Date: 2023.12.12 01:00:00 #
# ================================================== #

from PySide6.QtGui import QAction
from PySide6.QtGui import QAction, Qt

from ..utils import trans

Expand Down Expand Up @@ -56,9 +56,16 @@ def toggle(self, id):
self.update()

# output
self.window.data['chat.label'].setText(trans("chatbox.label"))
self.window.data['output.timestamp'].setText(trans('output.timestamp'))

self.window.tabs['output'].setTabText(0, trans('output.tab.chat'))
self.window.tabs['output'].setTabText(1, trans('output.tab.files'))
self.window.tabs['output'].setTabText(2, trans('output.tab.notepad') + " 1")
self.window.tabs['output'].setTabText(3, trans('output.tab.notepad') + " 2")
self.window.tabs['output'].setTabText(4, trans('output.tab.notepad') + " 3")
self.window.tabs['output'].setTabText(5, trans('output.tab.notepad') + " 4")
self.window.tabs['output'].setTabText(6, trans('output.tab.notepad') + " 5")

# context
self.window.data['contexts.label'].setText(trans("ctx.contexts.label"))
self.window.data['contexts.new'].setText(trans('context.new'))
Expand All @@ -79,40 +86,73 @@ def toggle(self, id):
self.window.data['input.label'].setText(trans("input.label"))
self.window.data['input.send_enter'].setText(trans("input.radio.enter"))
self.window.data['input.send_shift_enter'].setText(trans("input.radio.enter_shift"))
self.window.data['input.send_none'].setText(trans("input.radio.none"))
self.window.data['input.send_clear'].setText(trans('input.send_clear'))
self.window.data['input.send_btn'].setText(trans("input.btn.send"))
self.window.data['input.stop_btn'].setText(trans("input.btn.stop"))
self.window.data['input.stream'].setText(trans('input.stream'))
self.window.data['attachments.send_clear'].setText(trans('attachments.send_clear'))

self.window.models['attachments'].setHeaderData(0, Qt.Horizontal, trans('attachments.header.name'))
self.window.models['attachments'].setHeaderData(1, Qt.Horizontal, trans('attachments.header.path'))
self.window.models['attachments_uploaded'].setHeaderData(0, Qt.Horizontal, trans('attachments.header.name'))
self.window.models['attachments_uploaded'].setHeaderData(1, Qt.Horizontal, trans('attachments.header.path'))

# assistants
self.window.data['assistants.label'].setText(trans("toolbox.assistants.label"))
self.window.data['assistants.new'].setText(trans('assistant.new'))
self.window.data['assistants.import'].setText(trans('assistant.import'))
self.window.data['assistant.btn.current'].setText(trans("dialog.assistant.btn.current"))
self.window.data['assistant.btn.save'].setText(trans("dialog.assistant.btn.save"))
self.window.data['assistant.name.label'].setText(trans("assistant.name"))
self.window.data['assistant.id.label'].setText(trans("assistant.id"))
self.window.data['assistant.instructions.label'].setText(trans("assistant.instructions"))
self.window.data['assistant.model.label'].setText(trans("assistant.model"))
self.window.data['assistant.description.label'].setText(trans("assistant.description"))
self.window.data['assistant.functions.label'].setText(trans('assistant.functions.label'))
self.window.data['assistant.id_tip'].setText(trans("assistant.new.id_tip"))
self.window.config_option['assistant.tool.retrieval'].box.setText(trans('assistant.tool.retrieval'))
self.window.config_option['assistant.tool.code_interpreter'].box.setText(trans('assistant.tool.code_interpreter'))

# settings dialog
self.window.data['settings.temperature.label'].setText(trans("settings.temperature"))
self.window.data['settings.top_p.label'].setText(trans("settings.top_p"))
self.window.data['settings.frequency_penalty.label'].setText(trans("settings.frequency_penalty"))
self.window.data['settings.presence_penalty.label'].setText(trans("settings.presence_penalty"))
self.window.config_option['use_context'].box.setText(trans("settings.use_context"))
self.window.config_option['store_history'].box.setText(trans("settings.store_history"))
self.window.config_option['store_history_time'].box.setText(trans("settings.store_history_time"))
self.window.data['settings.context_threshold.label'].setText(trans("settings.context_threshold"))
self.window.data['settings.max_output_tokens.label'].setText(trans("settings.max_output_tokens"))
self.window.data['settings.max_total_tokens.label'].setText(trans("settings.max_total_tokens"))
self.window.data['settings.img_resolution.label'].setText(trans("settings.img_resolution"))
self.window.data['settings.api_key.label'].setText(trans("settings.api_key"))
self.window.data['settings.organization_key.label'].setText(trans("settings.organization_key"))
self.window.config_option['use_context'].box.setText(trans("settings.use_context"))
self.window.config_option['store_history'].box.setText(trans("settings.store_history"))
self.window.config_option['store_history_time'].box.setText(trans("settings.store_history_time"))
self.window.dialog['config.settings'].setWindowTitle(trans('dialog.settings'))

# buttons
self.window.data['settings.btn.defaults'].setText(trans("dialog.settings.btn.defaults"))
self.window.data['settings.btn.save'].setText(trans("dialog.settings.btn.save"))

# preset dialog
self.window.dialog['editor.preset.presets'].setWindowTitle(trans('dialog.preset'))
self.window.data['preset.filename.label'].setText(trans("preset.filename"))
self.window.data['preset.name.label'].setText(trans("preset.name"))
self.window.data['preset.ai_name.label'].setText(trans("preset.ai_name"))
self.window.data['preset.user_name.label'].setText(trans("preset.user_name"))
self.window.data['preset.temperature.label'].setText(trans("preset.temperature"))
self.window.data['preset.prompt.label'].setText(trans("preset.prompt"))
self.window.data['cmd.enabled'].setText(trans('cmd.enabled'))
self.window.config_option['preset.chat'].box.setText(trans("preset.chat"))
self.window.config_option['preset.completion'].box.setText(trans("preset.completion"))
self.window.config_option['preset.img'].box.setText(trans("preset.img"))
self.window.data['preset.temperature.label'].setText(trans("preset.temperature"))
self.window.data['preset.prompt.label'].setText(trans("preset.prompt"))
self.window.dialog['editor.preset.presets'].setWindowTitle(trans('dialog.preset'))
self.window.config_option['img_raw'].setText(trans("img.raw"))

# vision
self.window.data['vision.capture.enable'].setText(trans("vision.capture.enable"))
self.window.data['vision.capture.auto'].setText(trans("vision.capture.auto"))
self.window.data['vision.capture.label'].setText(trans('vision.capture.options.title'))
self.window.data['video.preview'].label.setText(trans("vision.capture.label"))

# buttons
self.window.data['preset.btn.current'].setText(trans("dialog.preset.btn.current"))
Expand Down Expand Up @@ -155,16 +195,15 @@ def toggle(self, id):
self.window.email)
self.window.data['dialog.about.content'].setText(string)
self.window.dialog['info.about'].setWindowTitle(trans("dialog.about.title"))
self.window.dialog['editor.assistants'].setWindowTitle(trans('dialog.assistant'))

# menu
self.window.menu['menu.app'].setTitle(trans("menu.file"))
self.window.menu['app.exit'].setText(trans("menu.file.exit"))
self.window.menu['app.clear_history'].setText(trans("menu.file_clear_history"))

self.window.menu['menu.plugins'].setTitle(trans("menu.plugins"))

self.window.menu['menu.audio'].setTitle(trans("menu.audio"))
self.window.menu['audio.output'].setText(trans("menu.audio.output"))

self.window.menu['menu.config'].setTitle(trans("menu.config"))
self.window.menu['config.settings'].setText(trans("menu.config.settings"))
Expand Down Expand Up @@ -199,10 +238,18 @@ def toggle(self, id):
self.window.tabs['input'].setTabText(1, trans('attachments.tab'))
self.window.data['attachments.btn.add'].setText(trans('attachments.btn.add'))
self.window.data['attachments.btn.clear'].setText(trans('attachments.btn.clear'))
self.window.data['attachments_uploaded.btn.sync'].setText(trans('attachments_uploaded.btn.sync'))
self.window.data['attachments_uploaded.btn.clear'].setText(trans('attachments_uploaded.btn.clear'))
self.window.data['attachments_uploaded.sync.tip'].setText(trans('attachments_uploaded.sync.tip'))

# plugins info
self.window.controller.plugins.update_info()

mode = self.window.config.data['mode']
self.window.controller.attachment.update_tab_label(mode)
self.window.controller.assistant.update_tab_label()
self.window.tabs['input'].setTabText(0, trans('input.tab'))

for theme in self.window.menu['theme']:
name = self.window.controller.theme.trans_theme(theme)
self.window.menu['theme'][theme].setText(name)
Expand Down
5 changes: 3 additions & 2 deletions src/pygpt_net/core/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,9 @@ def assistant_get_tools(self, assistant):
if assistant.has_functions():
functions = assistant.get_functions()
for function in functions:
# unpack JSON from string
params = json.loads(function['params'])
if str(function['name']).strip() == '' or function['name'] is None:
continue
params = json.loads(function['params']) # unpack JSON from string
tools.append({"type": "function", "function": {"name": function['name'], "parameters": params, "description": function['desc']}})
return tools

Expand Down
2 changes: 1 addition & 1 deletion src/pygpt_net/core/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# GitHub: https://github.com/szczyglis-dev/py-gpt #
# MIT License #
# Created By : Marcin Szczygliński #
# Updated Date: 2023.12.05 22:00:00 #
# Updated Date: 2023.12.11 23:00:00 #
# ================================================== #

import tiktoken
Expand Down
20 changes: 10 additions & 10 deletions src/pygpt_net/core/ui/attachments_uploaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# GitHub: https://github.com/szczyglis-dev/py-gpt #
# MIT License #
# Created By : Marcin Szczygliński #
# Updated Date: 2023.12.11 23:00:00 #
# Updated Date: 2023.12.12 01:00:00 #
# ================================================== #

from PySide6.QtGui import QStandardItemModel, Qt
Expand Down Expand Up @@ -34,14 +34,14 @@ def setup(self):

self.setup_attachments()

label_sync = QLabel(trans('attachments_uploaded.sync.tip'))
label_sync.setAlignment(Qt.AlignCenter)
self.window.data['attachments_uploaded.sync.tip'] = QLabel(trans('attachments_uploaded.sync.tip'))
self.window.data['attachments_uploaded.sync.tip'].setAlignment(Qt.AlignCenter)

# buttons layout
buttons_layout = QHBoxLayout()
buttons_layout.addWidget(self.window.data['attachments.btn.sync'])
buttons_layout.addWidget(self.window.data['attachments.btn.clear'])
buttons_layout.addWidget(label_sync)
buttons_layout.addWidget(self.window.data['attachments_uploaded.btn.sync'])
buttons_layout.addWidget(self.window.data['attachments_uploaded.btn.clear'])
buttons_layout.addWidget(self.window.data['attachments_uploaded.sync.tip'])

# layout
layout = QVBoxLayout()
Expand All @@ -60,12 +60,12 @@ def setup_attachments(self):
self.window.data[id] = AttachmentUploadedSelectMenu(self.window)

# buttons
self.window.data['attachments.btn.sync'] = QPushButton(trans('attachments.btn.sync'))
self.window.data['attachments.btn.clear'] = QPushButton(trans('attachments.btn.clear'))
self.window.data['attachments_uploaded.btn.sync'] = QPushButton(trans('attachments_uploaded.btn.sync'))
self.window.data['attachments_uploaded.btn.clear'] = QPushButton(trans('attachments_uploaded.btn.clear'))

self.window.data['attachments.btn.sync'].clicked.connect(
self.window.data['attachments_uploaded.btn.sync'].clicked.connect(
lambda: self.window.controller.assistant.sync_files())
self.window.data['attachments.btn.clear'].clicked.connect(
self.window.data['attachments_uploaded.btn.clear'].clicked.connect(
lambda: self.window.controller.assistant.clear_files())

self.window.models[id] = self.create_model(self.window)
Expand Down
2 changes: 1 addition & 1 deletion src/pygpt_net/core/ui/chatbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def setup(self):
self.window.data['chat.model'].setAlignment(Qt.AlignRight)
context_layout = self.setup_context()

self.window.data['chat.label'] = QLabel(trans("chatbox.label"))
self.window.data['chat.label'] = QLabel('')
self.window.data['chat.label'].setStyleSheet(self.window.controller.theme.get_style('text_bold'))

self.window.data['chat.plugins'] = QLabel("")
Expand Down
Loading

0 comments on commit 587af58

Please sign in to comment.