--- a/OllamaInterface/OllamaHistoryWidget.py Mon Aug 05 18:37:16 2024 +0200 +++ b/OllamaInterface/OllamaHistoryWidget.py Tue Aug 06 18:18:39 2024 +0200 @@ -10,7 +10,7 @@ import uuid from PyQt6.QtCore import pyqtSignal, pyqtSlot -from PyQt6.QtWidgets import QWidget +from PyQt6.QtWidgets import QInputDialog, QLineEdit, QWidget from eric7.EricGui import EricPixmapCache @@ -50,6 +50,7 @@ self.setupUi(self) self.newChatButton.setIcon(EricPixmapCache.getIcon("plus")) + self.editButton.setIcon(EricPixmapCache.getIcon("editRename")) self.deleteButton.setIcon(EricPixmapCache.getIcon("trash")) if jsonStr is None: @@ -64,15 +65,42 @@ self.titleEdit.setText(self.__title) self.modelEdit.setText(self.__model) + def getTitle(self): + """ + Public method to get the chat title. + + @return chat title + @rtype str + """ + return self.__title + + def getModel(self): + """ + Public method to get the model used by the chat. + + @return model name + @rtype str + """ + return self.__model + def getId(self): """ Public method to get the chat history ID. - + @return ID of the history entry @rtype str """ return self.__id + def getMessages(self): + """ + Public method to get the list of messages. + + @return list of stored messages + @rtype list[dict[str, str]] + """ + return self.__messages + @pyqtSlot() def on_deleteButton_clicked(self): """ @@ -87,6 +115,23 @@ """ self.newChatWithHistory.emit(self.__id) + @pyqtSlot() + def on_editButton_clicked(self): + """ + Private slot to edit the chat title. + """ + title, ok = QInputDialog.getText( + self, + self.tr("Edit Chat Title"), + self.tr("Enter the new title:"), + QLineEdit.EchoMode.Normal, + self.__title, + ) + if ok and bool(title): + self.__title = title + self.titleEdit.setText(title) + self.dataChanged.emit(self.__id) + def loadFromJson(self, jsonStr): """ Public method to load the chat history data from a JSON string.