Move the reset and id into the chat object.

pull/520/head
Adam Treat 1 year ago
parent d1e3198b65
commit e005ab8c0a

@ -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();

@ -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();

@ -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…
Cancel
Save