OllamaInterface/OllamaHistoryEditDialog.py

Mon, 07 Apr 2025 18:22:30 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 07 Apr 2025 18:22:30 +0200
changeset 69
eb9340034f26
parent 67
3c2bcbf7eeaf
permissions
-rw-r--r--

Created global tag <release-10.1.8>.

# -*- coding: utf-8 -*-

# Copyright (c) 2024 - 2025 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