OllamaInterface/OllamaHistoryEditDialog.py

changeset 44
ef9a85b8768a
child 67
3c2bcbf7eeaf
equal deleted inserted replaced
43:cd85a7eed7f7 44:ef9a85b8768a
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2024 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to edit parameters of a chat history.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_OllamaHistoryEditDialog import Ui_OllamaHistoryEditDialog
14
15
16 class OllamaHistoryEditDialog(QDialog, Ui_OllamaHistoryEditDialog):
17 """
18 Class implementing a dialog to edit parameters of a chat history.
19 """
20
21 def __init__(self, title, model, selectableModels, parent=None):
22 """
23 Constructor
24
25 @param title title of the chat
26 @type str
27 @param model current model used by the chat
28 @type str
29 @param selectableModels list of available models
30 @type list of str
31 @param parent reference to the parent widget (defaults to None)
32 @type QWidget (optional)
33 """
34 super().__init__(parent)
35 self.setupUi(self)
36
37 self.modelComboBox.addItems(selectableModels)
38
39 self.chatTitleEdit.setText(title)
40 self.modelComboBox.setCurrentText(model)
41
42 msh = self.minimumSizeHint()
43 self.resize(max(self.width(), msh.width()), msh.height())
44
45 @pyqtSlot(str)
46 def on_chatTitleEdit_textChanged(self, title):
47 """
48 Private slot to handle a change of the chat title.
49
50 @param title entered title text
51 @type str
52 """
53 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
54 bool(title)
55 )
56
57 def getData(self):
58 """
59 Public method to retrieve the entered chat parameters.
60
61 @return tuple containing the entered chat title and the selected model name
62 @rtype tuple of (str, str)
63 """
64 return (
65 self.chatTitleEdit.text(),
66 self.modelComboBox.currentText(),
67 )

eric ide

mercurial