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