OllamaInterface/OllamaHistoryEditDialog.py

changeset 44
ef9a85b8768a
child 67
3c2bcbf7eeaf
diff -r cd85a7eed7f7 -r ef9a85b8768a OllamaInterface/OllamaHistoryEditDialog.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OllamaInterface/OllamaHistoryEditDialog.py	Mon Sep 16 19:05:50 2024 +0200
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2024 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to edit parameters of a chat history.
+"""
+
+from PyQt6.QtCore import pyqtSlot
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox
+
+from .Ui_OllamaHistoryEditDialog import Ui_OllamaHistoryEditDialog
+
+
+class OllamaHistoryEditDialog(QDialog, Ui_OllamaHistoryEditDialog):
+    """
+    Class implementing a dialog to edit parameters of a chat history.
+    """
+
+    def __init__(self, title, model, selectableModels, parent=None):
+        """
+        Constructor
+
+        @param title title of the chat
+        @type str
+        @param model current model used by the chat
+        @type str
+        @param selectableModels list of available models
+        @type list of str
+        @param parent reference to the parent widget (defaults to None)
+        @type QWidget (optional)
+        """
+        super().__init__(parent)
+        self.setupUi(self)
+
+        self.modelComboBox.addItems(selectableModels)
+
+        self.chatTitleEdit.setText(title)
+        self.modelComboBox.setCurrentText(model)
+
+        msh = self.minimumSizeHint()
+        self.resize(max(self.width(), msh.width()), msh.height())
+
+    @pyqtSlot(str)
+    def on_chatTitleEdit_textChanged(self, title):
+        """
+        Private slot to handle a change of the chat title.
+
+        @param title entered title text
+        @type str
+        """
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
+            bool(title)
+        )
+
+    def getData(self):
+        """
+        Public method to retrieve the entered chat parameters.
+
+        @return tuple containing the entered chat title and the selected model name
+        @rtype tuple of (str, str)
+        """
+        return (
+            self.chatTitleEdit.text(),
+            self.modelComboBox.currentText(),
+        )

eric ide

mercurial