8 |
8 |
9 import json |
9 import json |
10 import uuid |
10 import uuid |
11 |
11 |
12 from PyQt6.QtCore import pyqtSignal, pyqtSlot |
12 from PyQt6.QtCore import pyqtSignal, pyqtSlot |
13 from PyQt6.QtWidgets import QWidget |
13 from PyQt6.QtWidgets import QInputDialog, QLineEdit, QWidget |
14 |
14 |
15 from eric7.EricGui import EricPixmapCache |
15 from eric7.EricGui import EricPixmapCache |
16 |
16 |
17 from .Ui_OllamaHistoryWidget import Ui_OllamaHistoryWidget |
17 from .Ui_OllamaHistoryWidget import Ui_OllamaHistoryWidget |
18 |
18 |
62 self.loadFromJson(jsonStr) |
63 self.loadFromJson(jsonStr) |
63 |
64 |
64 self.titleEdit.setText(self.__title) |
65 self.titleEdit.setText(self.__title) |
65 self.modelEdit.setText(self.__model) |
66 self.modelEdit.setText(self.__model) |
66 |
67 |
|
68 def getTitle(self): |
|
69 """ |
|
70 Public method to get the chat title. |
|
71 |
|
72 @return chat title |
|
73 @rtype str |
|
74 """ |
|
75 return self.__title |
|
76 |
|
77 def getModel(self): |
|
78 """ |
|
79 Public method to get the model used by the chat. |
|
80 |
|
81 @return model name |
|
82 @rtype str |
|
83 """ |
|
84 return self.__model |
|
85 |
67 def getId(self): |
86 def getId(self): |
68 """ |
87 """ |
69 Public method to get the chat history ID. |
88 Public method to get the chat history ID. |
70 |
89 |
71 @return ID of the history entry |
90 @return ID of the history entry |
72 @rtype str |
91 @rtype str |
73 """ |
92 """ |
74 return self.__id |
93 return self.__id |
|
94 |
|
95 def getMessages(self): |
|
96 """ |
|
97 Public method to get the list of messages. |
|
98 |
|
99 @return list of stored messages |
|
100 @rtype list[dict[str, str]] |
|
101 """ |
|
102 return self.__messages |
75 |
103 |
76 @pyqtSlot() |
104 @pyqtSlot() |
77 def on_deleteButton_clicked(self): |
105 def on_deleteButton_clicked(self): |
78 """ |
106 """ |
79 Private slot to delet this chat history entry.. |
107 Private slot to delet this chat history entry.. |
84 def on_newChatButton_clicked(self): |
112 def on_newChatButton_clicked(self): |
85 """ |
113 """ |
86 Private slot to start a new chat using the saved chat history. |
114 Private slot to start a new chat using the saved chat history. |
87 """ |
115 """ |
88 self.newChatWithHistory.emit(self.__id) |
116 self.newChatWithHistory.emit(self.__id) |
|
117 |
|
118 @pyqtSlot() |
|
119 def on_editButton_clicked(self): |
|
120 """ |
|
121 Private slot to edit the chat title. |
|
122 """ |
|
123 title, ok = QInputDialog.getText( |
|
124 self, |
|
125 self.tr("Edit Chat Title"), |
|
126 self.tr("Enter the new title:"), |
|
127 QLineEdit.EchoMode.Normal, |
|
128 self.__title, |
|
129 ) |
|
130 if ok and bool(title): |
|
131 self.__title = title |
|
132 self.titleEdit.setText(title) |
|
133 self.dataChanged.emit(self.__id) |
89 |
134 |
90 def loadFromJson(self, jsonStr): |
135 def loadFromJson(self, jsonStr): |
91 """ |
136 """ |
92 Public method to load the chat history data from a JSON string. |
137 Public method to load the chat history data from a JSON string. |
93 |
138 |