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>.

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

eric ide

mercurial