From f2e83e95b75e9dca9101d48c090b6bae8b2d1f68 Mon Sep 17 00:00:00 2001
From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com>
Date: Sat, 26 Oct 2024 12:01:42 -0600
Subject: [PATCH 1/4] add user table, switch to username from usertable rather
than chatbot
---
...956e3e2_move_username_to_separate_table.py | 47 ++++++++++++++
src/airunner/data/models/settings_models.py | 7 ++-
src/airunner/handlers/llm/agent/base_agent.py | 4 +-
.../llm/causal_lm_transformer_base_handler.py | 4 +-
src/airunner/styles/dark_theme/styles.qss | 4 ++
src/airunner/utils/convert_pil_to_qimage.py | 13 ++++
src/airunner/utils/convert_pil_to_qpixmap.py | 9 +++
src/airunner/utils/toggle_signals.py | 3 -
src/airunner/widgets/llm/bot_preferences.py | 13 ++--
.../widgets/llm/chat_prompt_widget.py | 10 ++-
src/airunner/widgets/llm/message_widget.py | 6 +-
.../widgets/llm/templates/bot_preferences.ui | 53 ++--------------
.../llm/templates/bot_preferences_ui.py | 20 ------
src/airunner/widgets/llm/templates/message.ui | 8 +--
.../widgets/user/templates/user_settings.ui | 63 +++++++++++++++++++
.../user/templates/user_settings_ui.py | 55 ++++++++++++++++
.../widgets/user/user_settings_widget.py | 27 ++++++++
src/airunner/windows/main/settings_mixin.py | 6 +-
.../windows/settings/airunner_settings.py | 9 ++-
19 files changed, 266 insertions(+), 95 deletions(-)
create mode 100644 src/airunner/alembic/versions/75020956e3e2_move_username_to_separate_table.py
create mode 100644 src/airunner/utils/convert_pil_to_qimage.py
create mode 100644 src/airunner/utils/convert_pil_to_qpixmap.py
delete mode 100644 src/airunner/utils/toggle_signals.py
create mode 100644 src/airunner/widgets/user/templates/user_settings.ui
create mode 100644 src/airunner/widgets/user/templates/user_settings_ui.py
create mode 100644 src/airunner/widgets/user/user_settings_widget.py
diff --git a/src/airunner/alembic/versions/75020956e3e2_move_username_to_separate_table.py b/src/airunner/alembic/versions/75020956e3e2_move_username_to_separate_table.py
new file mode 100644
index 000000000..24f17ebd8
--- /dev/null
+++ b/src/airunner/alembic/versions/75020956e3e2_move_username_to_separate_table.py
@@ -0,0 +1,47 @@
+from typing import Sequence, Union
+import os
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import sqlite
+
+# revision identifiers, used by Alembic.
+revision: str = '75020956e3e2'
+down_revision: Union[str, None] = '26a0d29a3af3'
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+def convert_image_to_binary(image_path):
+ with open(image_path, 'rb') as file:
+ binary_data = file.read()
+ return binary_data
+
+def upgrade():
+ try:
+ op.create_table(
+ 'users',
+ sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
+ sa.Column('username', sa.String, nullable=False),
+ )
+ op.execute(
+ sa.text("INSERT INTO users (username) VALUES ('User')")
+ )
+ except Exception as e:
+ print(f"Error during upgrade: {e}")
+
+ try:
+ op.drop_column('chatbots', 'username')
+ except Exception as e:
+ print(f"Column already dropped: {e}")
+
+def downgrade():
+ try:
+ op.add_column('chatbots', sa.Column('username', sa.String, nullable=True))
+ except Exception as e:
+ print(f"Column already exists: {e}")
+
+ try:
+ op.drop_table('users')
+ except Exception as e:
+ print(f"Table already dropped: {e}")
+ # ### end Alembic commands ###
diff --git a/src/airunner/data/models/settings_models.py b/src/airunner/data/models/settings_models.py
index f717d8a45..d89e686b7 100644
--- a/src/airunner/data/models/settings_models.py
+++ b/src/airunner/data/models/settings_models.py
@@ -345,7 +345,6 @@ class Chatbot(Base):
__tablename__ = 'chatbots'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String, default="Chatbot")
- username = Column(String, default="User")
botname = Column(String, default="Computer")
use_personality = Column(Boolean, default=True)
use_mood = Column(Boolean, default=True)
@@ -390,6 +389,12 @@ class Chatbot(Base):
messages = relationship("Message", back_populates="chatbot")
+class User(Base):
+ __tablename__ = 'users'
+ id = Column(Integer, primary_key=True, autoincrement=True)
+ username = Column(String, nullable=False)
+
+
class TargetFiles(Base):
__tablename__ = 'target_files'
id = Column(Integer, primary_key=True, autoincrement=True)
diff --git a/src/airunner/handlers/llm/agent/base_agent.py b/src/airunner/handlers/llm/agent/base_agent.py
index b902e73e3..de8e80df0 100644
--- a/src/airunner/handlers/llm/agent/base_agent.py
+++ b/src/airunner/handlers/llm/agent/base_agent.py
@@ -130,7 +130,7 @@ def available_actions(self):
@property
def username(self) -> str:
- return self.chatbot.username
+ return self.user.username
@property
def botname(self) -> str:
@@ -327,7 +327,7 @@ def build_system_prompt(
use_guardrails = self.chatbot.use_guardrails
bot_mood = self.bot_mood
bot_personality = self.chatbot.bot_personality
- username = self.chatbot.username
+ username = self.user.username
botname = self.chatbot.botname
if use_system_instructions:
system_instructions = self.chatbot.system_instructions
diff --git a/src/airunner/handlers/llm/causal_lm_transformer_base_handler.py b/src/airunner/handlers/llm/causal_lm_transformer_base_handler.py
index de54cd33a..5cf51b801 100644
--- a/src/airunner/handlers/llm/causal_lm_transformer_base_handler.py
+++ b/src/airunner/handlers/llm/causal_lm_transformer_base_handler.py
@@ -103,9 +103,7 @@ def chat_template(self):
@property
def username(self):
- if self.chatbot.assign_names:
- return self.chatbot.username
- return "User"
+ return self.user.username
@property
def botname(self):
diff --git a/src/airunner/styles/dark_theme/styles.qss b/src/airunner/styles/dark_theme/styles.qss
index a3c5222ba..6213aa4e1 100644
--- a/src/airunner/styles/dark_theme/styles.qss
+++ b/src/airunner/styles/dark_theme/styles.qss
@@ -752,3 +752,7 @@ QScrollArea#chat_container #message_container QPushButton:hover {
background-color: #000;
border: 1px solid #1f1f1f;
}
+
+#image {
+ border: 1px solid #1f1f1f;
+}
diff --git a/src/airunner/utils/convert_pil_to_qimage.py b/src/airunner/utils/convert_pil_to_qimage.py
new file mode 100644
index 000000000..4a447f7e6
--- /dev/null
+++ b/src/airunner/utils/convert_pil_to_qimage.py
@@ -0,0 +1,13 @@
+from PIL import Image
+from PIL.ImageQt import QImage
+
+
+def pil_to_qimage(pil_image):
+ if pil_image.mode == "RGB":
+ r, g, b = pil_image.split()
+ pil_image = Image.merge("RGBA", (r, g, b, Image.new("L", r.size, 255)))
+ elif pil_image.mode == "L":
+ pil_image = pil_image.convert("RGBA")
+ data = pil_image.tobytes("raw", "RGBA")
+ qimage = QImage(data, pil_image.size[0], pil_image.size[1], QImage.Format.Format_RGBA8888)
+ return qimage
diff --git a/src/airunner/utils/convert_pil_to_qpixmap.py b/src/airunner/utils/convert_pil_to_qpixmap.py
new file mode 100644
index 000000000..927d57a20
--- /dev/null
+++ b/src/airunner/utils/convert_pil_to_qpixmap.py
@@ -0,0 +1,9 @@
+from PIL.ImageQt import QPixmap
+
+from airunner.utils.convert_pil_to_qimage import pil_to_qimage
+
+
+def convert_pil_to_qpixmap(image):
+ qimage = pil_to_qimage(image)
+ pixmap = QPixmap.fromImage(qimage)
+ return pixmap
diff --git a/src/airunner/utils/toggle_signals.py b/src/airunner/utils/toggle_signals.py
deleted file mode 100644
index 6066dd29f..000000000
--- a/src/airunner/utils/toggle_signals.py
+++ /dev/null
@@ -1,3 +0,0 @@
-def toggle_signals(ui: object, elements: list, block: bool = True):
- for element in elements:
- getattr(ui, element).blockSignals(block)
diff --git a/src/airunner/widgets/llm/bot_preferences.py b/src/airunner/widgets/llm/bot_preferences.py
index 92df378c4..a6004b192 100644
--- a/src/airunner/widgets/llm/bot_preferences.py
+++ b/src/airunner/widgets/llm/bot_preferences.py
@@ -4,7 +4,6 @@
from airunner.data.models.settings_models import TargetFiles, Chatbot
from airunner.enums import SignalCode
from airunner.utils.open_file_path import open_file_path
-from airunner.utils.toggle_signals import toggle_signals
from airunner.widgets.base_widget import BaseWidget
from airunner.widgets.llm.document_widget import DocumentWidget
from airunner.widgets.llm.templates.bot_preferences_ui import Ui_bot_preferences
@@ -22,7 +21,6 @@ def showEvent(self, event):
def load_form_elements(self):
elements = [
- "username",
"botname",
"bot_personality",
"names_groupbox",
@@ -33,8 +31,7 @@ def load_form_elements(self):
"guardrails_groupbox",
"target_files",
]
- toggle_signals(self.ui, elements)
- self.ui.username.setText(self.chatbot.username)
+ self.toggle_signals(self.ui, elements)
self.ui.botname.setText(self.chatbot.botname)
self.ui.bot_personality.setPlainText(self.chatbot.bot_personality)
self.ui.names_groupbox.setChecked(self.chatbot.assign_names)
@@ -44,10 +41,12 @@ def load_form_elements(self):
self.ui.guardrails_prompt.setPlainText(self.chatbot.guardrails_prompt)
self.ui.guardrails_groupbox.setChecked(self.chatbot.use_guardrails)
self.load_documents()
- toggle_signals(self.ui, elements, False)
+ self.toggle_signals(self.ui, elements, False)
- def username_changed(self, val):
- self.update_chatbot("username", val)
+ @staticmethod
+ def toggle_signals(ui: object, elements: list, block: bool = True):
+ for element in elements:
+ getattr(ui, element).blockSignals(block)
def botname_changed(self, val):
self.update_chatbot("botname", val)
diff --git a/src/airunner/widgets/llm/chat_prompt_widget.py b/src/airunner/widgets/llm/chat_prompt_widget.py
index 6cf65cf5f..1a5bb0a00 100644
--- a/src/airunner/widgets/llm/chat_prompt_widget.py
+++ b/src/airunner/widgets/llm/chat_prompt_widget.py
@@ -192,7 +192,7 @@ def do_generate(self, image_override=None, prompt_override=None, callback=None,
self.generating = True
widget = self.add_message_to_conversation(
- name=self.chatbot.username,
+ name=self.user.username,
message=self.prompt,
is_bot=False
)
@@ -338,7 +338,13 @@ def add_message_to_conversation(
widget = None
if message != "":
- widget = MessageWidget(name=name, message=message, is_bot=is_bot, message_id=message_id, conversation_id=self.conversation_id)
+ widget = MessageWidget(
+ name=name,
+ message=message,
+ is_bot=is_bot,
+ message_id=message_id,
+ conversation_id=self.conversation_id
+ )
self.ui.scrollAreaWidgetContents.layout().addWidget(widget)
self.add_spacer()
diff --git a/src/airunner/widgets/llm/message_widget.py b/src/airunner/widgets/llm/message_widget.py
index eea3ac3d5..dbf29bfd2 100644
--- a/src/airunner/widgets/llm/message_widget.py
+++ b/src/airunner/widgets/llm/message_widget.py
@@ -1,12 +1,12 @@
-from airunner.data.models.settings_models import Message, Conversation
+from airunner.data.models.settings_models import Message
from airunner.enums import SignalCode
from airunner.widgets.base_widget import BaseWidget
from airunner.widgets.llm.templates.message_ui import Ui_message
-from PySide6.QtGui import QTextCursor, QFontDatabase, QFont
+from PySide6.QtGui import QFontDatabase, QFont
from PySide6.QtWidgets import QTextEdit, QApplication, QWidget
from PySide6.QtGui import QFontMetrics
-from PySide6.QtCore import Qt, QSize, Slot, QEvent, QTimer
+from PySide6.QtCore import Qt, QSize, Slot, QEvent
from PySide6.QtCore import Signal
diff --git a/src/airunner/widgets/llm/templates/bot_preferences.ui b/src/airunner/widgets/llm/templates/bot_preferences.ui
index 4fe5d4c06..290711c92 100644
--- a/src/airunner/widgets/llm/templates/bot_preferences.ui
+++ b/src/airunner/widgets/llm/templates/bot_preferences.ui
@@ -166,32 +166,6 @@
- -
-
-
-
-
-
-
- true
-
-
-
- User name
-
-
-
- -
-
-
- User
-
-
- User name
-
-
-
-
-
@@ -353,22 +327,6 @@
-
- username
- textChanged(QString)
- bot_preferences
- username_changed(QString)
-
-
- 674
- 460
-
-
- 55
- 0
-
-
-
botname
textChanged(QString)
@@ -392,8 +350,8 @@
bot_personality_changed()
- 392
- 971
+ 404
+ 1105
292
@@ -425,7 +383,7 @@
108
- 916
+ 995
0
@@ -440,8 +398,8 @@
guardrails_prompt_changed()
- 202
- 765
+ 214
+ 836
1
@@ -579,7 +537,6 @@
- username_changed(QString)
botname_changed(QString)
bot_personality_changed()
toggle_use_names(bool)
diff --git a/src/airunner/widgets/llm/templates/bot_preferences_ui.py b/src/airunner/widgets/llm/templates/bot_preferences_ui.py
index 86347eb46..a5b72d0a5 100644
--- a/src/airunner/widgets/llm/templates/bot_preferences_ui.py
+++ b/src/airunner/widgets/llm/templates/bot_preferences_ui.py
@@ -103,22 +103,6 @@ def setupUi(self, bot_preferences):
self.horizontalLayout.addLayout(self.verticalLayout_6)
- self.verticalLayout_5 = QVBoxLayout()
- self.verticalLayout_5.setObjectName(u"verticalLayout_5")
- self.label_3 = QLabel(self.names_groupbox)
- self.label_3.setObjectName(u"label_3")
- self.label_3.setFont(font)
-
- self.verticalLayout_5.addWidget(self.label_3)
-
- self.username = QLineEdit(self.names_groupbox)
- self.username.setObjectName(u"username")
-
- self.verticalLayout_5.addWidget(self.username)
-
-
- self.horizontalLayout.addLayout(self.verticalLayout_5)
-
self.gridLayout.addWidget(self.names_groupbox, 3, 0, 1, 1)
@@ -213,7 +197,6 @@ def setupUi(self, bot_preferences):
self.retranslateUi(bot_preferences)
- self.username.textChanged.connect(bot_preferences.username_changed)
self.botname.textChanged.connect(bot_preferences.botname_changed)
self.bot_personality.textChanged.connect(bot_preferences.bot_personality_changed)
self.names_groupbox.toggled.connect(bot_preferences.toggle_use_names)
@@ -242,9 +225,6 @@ def retranslateUi(self, bot_preferences):
self.label.setText(QCoreApplication.translate("bot_preferences", u"Assistant name", None))
self.botname.setText(QCoreApplication.translate("bot_preferences", u"AI Runner", None))
self.botname.setPlaceholderText(QCoreApplication.translate("bot_preferences", u"Bot name", None))
- self.label_3.setText(QCoreApplication.translate("bot_preferences", u"User name", None))
- self.username.setText(QCoreApplication.translate("bot_preferences", u"User", None))
- self.username.setPlaceholderText(QCoreApplication.translate("bot_preferences", u"User name", None))
self.guardrails_groupbox.setTitle(QCoreApplication.translate("bot_preferences", u"Guardrails", None))
self.guardrails_prompt.setPlaceholderText(QCoreApplication.translate("bot_preferences", u"The guardrails prompt is used to moderate results.", None))
self.groupBox.setTitle(QCoreApplication.translate("bot_preferences", u"Existing Agents", None))
diff --git a/src/airunner/widgets/llm/templates/message.ui b/src/airunner/widgets/llm/templates/message.ui
index 8cf9a7d42..91e6e5c42 100644
--- a/src/airunner/widgets/llm/templates/message.ui
+++ b/src/airunner/widgets/llm/templates/message.ui
@@ -147,8 +147,8 @@
delete()
- 435
- 19
+ 485
+ 30
391
@@ -163,8 +163,8 @@
copy()
- 469
- 28
+ 452
+ 34
451
diff --git a/src/airunner/widgets/user/templates/user_settings.ui b/src/airunner/widgets/user/templates/user_settings.ui
new file mode 100644
index 000000000..d4305f2f1
--- /dev/null
+++ b/src/airunner/widgets/user/templates/user_settings.ui
@@ -0,0 +1,63 @@
+
+
+ user_settings_widget
+
+
+
+ 0
+ 0
+ 500
+ 346
+
+
+
+ Form
+
+
+ -
+
+
+ Username
+
+
+
-
+
+
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+ username
+ textChanged(QString)
+ user_settings_widget
+ username_changed(QString)
+
+
+ 121
+ 59
+
+
+ 1
+ 2
+
+
+
+
+
diff --git a/src/airunner/widgets/user/templates/user_settings_ui.py b/src/airunner/widgets/user/templates/user_settings_ui.py
new file mode 100644
index 000000000..081dc3f50
--- /dev/null
+++ b/src/airunner/widgets/user/templates/user_settings_ui.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+
+################################################################################
+## Form generated from reading UI file 'user_settings.ui'
+##
+## Created by: Qt User Interface Compiler version 6.7.0
+##
+## WARNING! All changes made in this file will be lost when recompiling UI file!
+################################################################################
+
+from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
+ QMetaObject, QObject, QPoint, QRect,
+ QSize, QTime, QUrl, Qt)
+from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
+ QFont, QFontDatabase, QGradient, QIcon,
+ QImage, QKeySequence, QLinearGradient, QPainter,
+ QPalette, QPixmap, QRadialGradient, QTransform)
+from PySide6.QtWidgets import (QApplication, QGridLayout, QGroupBox, QLineEdit,
+ QSizePolicy, QSpacerItem, QWidget)
+
+class Ui_user_settings_widget(object):
+ def setupUi(self, user_settings_widget):
+ if not user_settings_widget.objectName():
+ user_settings_widget.setObjectName(u"user_settings_widget")
+ user_settings_widget.resize(500, 346)
+ self.gridLayout = QGridLayout(user_settings_widget)
+ self.gridLayout.setObjectName(u"gridLayout")
+ self.groupBox = QGroupBox(user_settings_widget)
+ self.groupBox.setObjectName(u"groupBox")
+ self.gridLayout_3 = QGridLayout(self.groupBox)
+ self.gridLayout_3.setObjectName(u"gridLayout_3")
+ self.username = QLineEdit(self.groupBox)
+ self.username.setObjectName(u"username")
+
+ self.gridLayout_3.addWidget(self.username, 0, 0, 1, 1)
+
+
+ self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
+
+ self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
+
+ self.gridLayout.addItem(self.verticalSpacer, 1, 0, 1, 1)
+
+
+ self.retranslateUi(user_settings_widget)
+ self.username.textChanged.connect(user_settings_widget.username_changed)
+
+ QMetaObject.connectSlotsByName(user_settings_widget)
+ # setupUi
+
+ def retranslateUi(self, user_settings_widget):
+ user_settings_widget.setWindowTitle(QCoreApplication.translate("user_settings_widget", u"Form", None))
+ self.groupBox.setTitle(QCoreApplication.translate("user_settings_widget", u"Username", None))
+ # retranslateUi
+
diff --git a/src/airunner/widgets/user/user_settings_widget.py b/src/airunner/widgets/user/user_settings_widget.py
new file mode 100644
index 000000000..e11756897
--- /dev/null
+++ b/src/airunner/widgets/user/user_settings_widget.py
@@ -0,0 +1,27 @@
+from PySide6.QtCore import Slot
+
+from airunner.data.models.settings_models import User
+from airunner.widgets.base_widget import BaseWidget
+from airunner.widgets.user.templates.user_settings_ui import Ui_user_settings_widget
+
+
+class UserSettingsWidget(BaseWidget):
+ widget_class_ = Ui_user_settings_widget
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ session = self.session
+ user = session.query(User).first()
+ if user is not None:
+ self.ui.username.setText(user.username)
+ else:
+ user = User()
+ session.add(user)
+ session.commit()
+
+ @Slot(str)
+ def username_changed(self, val):
+ session = self.session
+ user = session.query(User).first()
+ user.username = val
+ session.commit()
diff --git a/src/airunner/windows/main/settings_mixin.py b/src/airunner/windows/main/settings_mixin.py
index 45e0b1601..7a3c2a350 100644
--- a/src/airunner/windows/main/settings_mixin.py
+++ b/src/airunner/windows/main/settings_mixin.py
@@ -11,7 +11,7 @@
GeneratorSettings, WindowSettings, ApplicationSettings, ActiveGridSettings, ControlnetSettings, \
ImageToImageSettings, OutpaintSettings, DrawingPadSettings, MetadataSettings, \
LLMGeneratorSettings, TTSSettings, SpeechT5Settings, EspeakSettings, STTSettings, BrushSettings, GridSettings, \
- MemorySettings, Message, Conversation, Summary, ImageFilterValue, TargetFiles, WhisperSettings, Base
+ MemorySettings, Message, Conversation, Summary, ImageFilterValue, TargetFiles, WhisperSettings, Base, User
from airunner.enums import SignalCode
from airunner.utils.convert_binary_to_image import convert_binary_to_image
@@ -271,6 +271,10 @@ def chatbot(self) -> Type[Chatbot]:
self.llm_generator_settings.current_chatbot
)
+ @property
+ def user(self) -> Type[User]:
+ return self.session.query(User).first()
+
@property
def window_settings(self):
return self.load_window_settings()
diff --git a/src/airunner/windows/settings/airunner_settings.py b/src/airunner/windows/settings/airunner_settings.py
index 0346b954b..7ffecb638 100644
--- a/src/airunner/windows/settings/airunner_settings.py
+++ b/src/airunner/windows/settings/airunner_settings.py
@@ -10,8 +10,8 @@
from airunner.widgets.llm.prompt_templates_widget import PromptTemplatesWidget
from airunner.widgets.memory_preferences.memory_preferences_widget import MemoryPreferencesWidget
from airunner.widgets.paths.paths_widget import PathsWidget
-from airunner.widgets.stt.stt_settings_widget import STTSettingsWidget
from airunner.widgets.tts.tts_preferences_widget import TTSPreferencesWidget
+from airunner.widgets.user.user_settings_widget import UserSettingsWidget
from airunner.windows.settings.templates.airunner_settings_ui import Ui_airunner_settings
from airunner.windows.base_window import BaseWindow
@@ -68,6 +68,8 @@ def available_widgets(self, name):
return PromptTemplatesWidget
elif name == "bot_preferences":
return BotPreferencesWidget
+ elif name == "user_settings":
+ return UserSettingsWidget
elif name == "export_preferences":
return ExportPreferencesWidget
# elif name == "stt_preferences":
@@ -121,6 +123,11 @@ def initialize_window(self):
"display_name": "Agent Preferences",
"checkable": False
},
+ {
+ "name": "user_settings",
+ "display_name": "User Settings",
+ "checkable": False
+ },
{
"name": "tts_preferences",
"display_name": "Text-to-Speech",
From 0e3b5f14b8b2aae2d2b0041d2f9062b8fc66d562 Mon Sep 17 00:00:00 2001
From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com>
Date: Sat, 26 Oct 2024 12:01:58 -0600
Subject: [PATCH 2/4] bump version
---
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 8655b9e0b..26ad2c511 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@
setup(
name="airunner",
- version="3.1.4",
+ version="3.1.5",
author="Capsize LLC",
description="A Stable Diffusion GUI",
long_description=open("README.md", "r", encoding="utf-8").read(),
From 2677fbc5ef74361d44bd7d18fa6f4ef1ee372325 Mon Sep 17 00:00:00 2001
From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com>
Date: Sat, 26 Oct 2024 12:09:07 -0600
Subject: [PATCH 3/4] prevent empty conversations from show in llm history
---
src/airunner/widgets/llm/llm_history_widget.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/airunner/widgets/llm/llm_history_widget.py b/src/airunner/widgets/llm/llm_history_widget.py
index 6388706de..880dd8d25 100644
--- a/src/airunner/widgets/llm/llm_history_widget.py
+++ b/src/airunner/widgets/llm/llm_history_widget.py
@@ -43,6 +43,8 @@ def load_conversations(self):
self.ui.scrollAreaWidgetContents.setLayout(layout)
for conversation in conversations:
+ if conversation.title == "":
+ continue
llm_history_item_widget = LLMHistoryItemWidget(
conversation=conversation
)
From c1439219f0a20b894210ebd42dde490d5f6381b2 Mon Sep 17 00:00:00 2001
From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com>
Date: Sat, 26 Oct 2024 12:09:35 -0600
Subject: [PATCH 4/4] when creating a conversation, use the first found empty
conversation rather than creating a new empty conversation
---
src/airunner/windows/main/settings_mixin.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/airunner/windows/main/settings_mixin.py b/src/airunner/windows/main/settings_mixin.py
index 7a3c2a350..18ff87c98 100644
--- a/src/airunner/windows/main/settings_mixin.py
+++ b/src/airunner/windows/main/settings_mixin.py
@@ -715,6 +715,13 @@ def get_chatbot_by_id(self, chatbot_id) -> Type[Chatbot]:
return chatbot
def create_conversation(self):
+ # find conversation which has no title, bot_mood or messages
+ conversation = self.session.query(Conversation).filter_by(title="", bot_mood="").first()
+ if conversation:
+ # ensure there are no messages in the conversation
+ message = self.session.query(Message).filter_by(conversation_id=conversation.id).first()
+ if message is None:
+ return conversation
conversation = Conversation(
timestamp=datetime.datetime.now(datetime.timezone.utc),
title=""