diff -r cd85a7eed7f7 -r ef9a85b8768a OllamaInterface/OllamaHistoryWidget.py --- a/OllamaInterface/OllamaHistoryWidget.py Thu Sep 12 15:41:58 2024 +0200 +++ b/OllamaInterface/OllamaHistoryWidget.py Mon Sep 16 19:05:50 2024 +0200 @@ -12,7 +12,7 @@ import uuid from PyQt6.QtCore import pyqtSignal, pyqtSlot -from PyQt6.QtWidgets import QInputDialog, QLineEdit, QWidget +from PyQt6.QtWidgets import QDialog, QWidget from eric7.EricGui import EricPixmapCache from eric7.EricWidgets.EricApplication import ericApp @@ -31,14 +31,17 @@ @signal viewChatHistory(id:str) emitted to indicate, that this chat history should be shown in a separate window @signal dataChanged(id:str) emitted to indicate a change of the chat history data + @signal parametersChanged(id:str, title:str, model:str) emitted to indicate a + change of editable chat parameters """ deleteChatHistory = pyqtSignal(str) newChatWithHistory = pyqtSignal(str) viewChatHistory = pyqtSignal(str) dataChanged = pyqtSignal(str) + parametersChanged = pyqtSignal(str, str, str) - def __init__(self, title, model, jsonStr=None, parent=None): + def __init__(self, title, model, mainWidget, jsonStr=None, parent=None): """ Constructor @@ -46,7 +49,9 @@ @type str @param model name of the model used for the chat @type str - @param jsonStr string containing JSON serialize chat history data + @param mainWidget reference to the Ollama main widget + @type OllamaWidget + @param jsonStr string containing JSON serialized chat history data (defaults to None) @type str (optional) @param parent reference to the parent widget (defaults to None) @@ -66,6 +71,8 @@ ) self.deleteButton.setIcon(EricPixmapCache.getIcon("trash")) + self.__ollamaWidget = mainWidget + if jsonStr is None: self.__title = title self.__model = model @@ -133,17 +140,19 @@ """ 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, + from .OllamaHistoryEditDialog import OllamaHistoryEditDialog + + dlg = OllamaHistoryEditDialog( + title=self.__title, + model=self.__model, + selectableModels=self.__ollamaWidget.getSelectableModels(), ) - if ok and bool(title): - self.__title = title - self.titleEdit.setText(title) + if dlg.exec() == QDialog.DialogCode.Accepted: + self.__title, self.__model = dlg.getData() + self.titleEdit.setText(self.__title) + self.modelEdit.setText(self.__model) self.dataChanged.emit(self.__id) + self.parametersChanged.emit(self.__id, self.__title, self.__model) @pyqtSlot() def on_viewButton_clicked(self):