mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-19 17:50:25 +00:00
Move the reset and id into the chat object.
This commit is contained in:
parent
bbffa7364b
commit
75c8bf28a1
6
chat.h
6
chat.h
@ -28,6 +28,12 @@ public:
|
||||
QString name() const { return m_name; }
|
||||
ChatModel *chatModel() { return m_chatModel; }
|
||||
|
||||
Q_INVOKABLE void reset()
|
||||
{
|
||||
m_id = Network::globalInstance()->generateUniqueId();
|
||||
m_chatModel->clear();
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void idChanged();
|
||||
void nameChanged();
|
||||
|
10
chatmodel.h
10
chatmodel.h
@ -125,6 +125,16 @@ public:
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void clear()
|
||||
{
|
||||
if (m_chatItems.isEmpty()) return;
|
||||
|
||||
beginResetModel();
|
||||
m_chatItems.clear();
|
||||
endResetModel();
|
||||
emit countChanged();
|
||||
}
|
||||
|
||||
Q_INVOKABLE ChatItem get(int index)
|
||||
{
|
||||
if (index < 0 || index >= m_chatItems.size()) return ChatItem();
|
||||
|
10
main.qml
10
main.qml
@ -18,7 +18,6 @@ Window {
|
||||
id: theme
|
||||
}
|
||||
|
||||
property string chatId: Network.generateUniqueId()
|
||||
property var chatModel: LLM.currentChat.chatModel
|
||||
|
||||
color: theme.textColor
|
||||
@ -172,7 +171,7 @@ Window {
|
||||
onActivated: {
|
||||
LLM.stopGenerating()
|
||||
LLM.modelName = comboBox.currentText
|
||||
chatModel.clear()
|
||||
LLM.currentChat.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -474,8 +473,7 @@ Window {
|
||||
onClicked: {
|
||||
LLM.stopGenerating()
|
||||
LLM.resetContext()
|
||||
chatId = Network.generateUniqueId()
|
||||
chatModel.clear()
|
||||
LLM.currentChat.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -750,7 +748,7 @@ Window {
|
||||
chatModel.updateNewResponse(index, response)
|
||||
chatModel.updateThumbsUpState(index, false)
|
||||
chatModel.updateThumbsDownState(index, true)
|
||||
Network.sendConversation(chatId, getConversationJson());
|
||||
Network.sendConversation(LLM.currentChat.id, getConversationJson());
|
||||
}
|
||||
}
|
||||
|
||||
@ -782,7 +780,7 @@ Window {
|
||||
chatModel.updateNewResponse(index, "")
|
||||
chatModel.updateThumbsUpState(index, true)
|
||||
chatModel.updateThumbsDownState(index, false)
|
||||
Network.sendConversation(chatId, getConversationJson());
|
||||
Network.sendConversation(LLM.currentChat.id, getConversationJson());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user