Skip to content

Commit 13e694e

Browse files
authored
ChatView: make "stop" and "copy conversation" work again (#3336)
Signed-off-by: Adam Treat <treat.adam@gmail.com>
1 parent 93b4093 commit 13e694e

File tree

4 files changed

+70
-48
lines changed

4 files changed

+70
-48
lines changed

gpt4all-chat/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [3.6.1] - 2024-12-20
8+
9+
### Fixed
10+
- Fix the stop generation button no longer working in v3.6.0 ([#3336](https://github.com/nomic-ai/gpt4all/pull/3336))
11+
- Fix the copy entire conversation button no longer working in v3.6.0 ([#3336](https://github.com/nomic-ai/gpt4all/pull/3336))
12+
713
## [3.6.0] - 2024-12-19
814

915
### Added
@@ -239,6 +245,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
239245
- Fix several Vulkan resource management issues ([#2694](https://github.com/nomic-ai/gpt4all/pull/2694))
240246
- Fix crash/hang when some models stop generating, by showing special tokens ([#2701](https://github.com/nomic-ai/gpt4all/pull/2701))
241247

248+
[3.6.1]: https://github.com/nomic-ai/gpt4all/compare/v3.6.0...v3.6.1
242249
[3.6.0]: https://github.com/nomic-ai/gpt4all/compare/v3.5.3...v3.6.0
243250
[3.5.3]: https://github.com/nomic-ai/gpt4all/compare/v3.5.2...v3.5.3
244251
[3.5.2]: https://github.com/nomic-ai/gpt4all/compare/v3.5.1...v3.5.2

gpt4all-chat/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(APP_VERSION_MAJOR 3)
66
set(APP_VERSION_MINOR 6)
77
set(APP_VERSION_PATCH 1)
88
set(APP_VERSION_BASE "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}")
9-
set(APP_VERSION "${APP_VERSION_BASE}-dev0")
9+
set(APP_VERSION "${APP_VERSION_BASE}")
1010

1111
project(gpt4all VERSION ${APP_VERSION_BASE} LANGUAGES CXX C)
1212

gpt4all-chat/qml/ChatView.qml

+48-47
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ Rectangle {
3737

3838
Connections {
3939
target: currentChat
40-
function onResponseInProgressChanged() {
41-
if (MySettings.networkIsActive && !currentChat.responseInProgress)
42-
Network.sendConversation(currentChat.id, getConversationJson());
43-
}
40+
// FIXME: https://github.com/nomic-ai/gpt4all/issues/3334
41+
// function onResponseInProgressChanged() {
42+
// if (MySettings.networkIsActive && !currentChat.responseInProgress)
43+
// Network.sendConversation(currentChat.id, getConversationJson());
44+
// }
4445
function onModelLoadingErrorChanged() {
4546
if (currentChat.modelLoadingError !== "")
4647
modelLoadingErrorPopup.open()
@@ -116,42 +117,44 @@ Rectangle {
116117
}
117118
}
118119

119-
function getConversation() {
120-
var conversation = "";
121-
for (var i = 0; i < chatModel.count; i++) {
122-
var item = chatModel.get(i)
123-
var string = item.name;
124-
var isResponse = item.name === "Response: "
125-
string += chatModel.get(i).value
126-
if (isResponse && item.stopped)
127-
string += " <stopped>"
128-
string += "\n"
129-
conversation += string
130-
}
131-
return conversation
132-
}
133-
134-
function getConversationJson() {
135-
var str = "{\"conversation\": [";
136-
for (var i = 0; i < chatModel.count; i++) {
137-
var item = chatModel.get(i)
138-
var isResponse = item.name === "Response: "
139-
str += "{\"content\": ";
140-
str += JSON.stringify(item.value)
141-
str += ", \"role\": \"" + (isResponse ? "assistant" : "user") + "\"";
142-
if (isResponse && item.thumbsUpState !== item.thumbsDownState)
143-
str += ", \"rating\": \"" + (item.thumbsUpState ? "positive" : "negative") + "\"";
144-
if (isResponse && item.newResponse !== "")
145-
str += ", \"edited_content\": " + JSON.stringify(item.newResponse);
146-
if (isResponse && item.stopped)
147-
str += ", \"stopped\": \"true\""
148-
if (!isResponse)
149-
str += "},"
150-
else
151-
str += ((i < chatModel.count - 1) ? "}," : "}")
152-
}
153-
return str + "]}"
154-
}
120+
// FIXME: https://github.com/nomic-ai/gpt4all/issues/3334
121+
// function getConversation() {
122+
// var conversation = "";
123+
// for (var i = 0; i < chatModel.count; i++) {
124+
// var item = chatModel.get(i)
125+
// var string = item.name;
126+
// var isResponse = item.name === "Response: "
127+
// string += chatModel.get(i).value
128+
// if (isResponse && item.stopped)
129+
// string += " <stopped>"
130+
// string += "\n"
131+
// conversation += string
132+
// }
133+
// return conversation
134+
// }
135+
136+
// FIXME: https://github.com/nomic-ai/gpt4all/issues/3334
137+
// function getConversationJson() {
138+
// var str = "{\"conversation\": [";
139+
// for (var i = 0; i < chatModel.count; i++) {
140+
// var item = chatModel.get(i)
141+
// var isResponse = item.name === "Response: "
142+
// str += "{\"content\": ";
143+
// str += JSON.stringify(item.value)
144+
// str += ", \"role\": \"" + (isResponse ? "assistant" : "user") + "\"";
145+
// if (isResponse && item.thumbsUpState !== item.thumbsDownState)
146+
// str += ", \"rating\": \"" + (item.thumbsUpState ? "positive" : "negative") + "\"";
147+
// if (isResponse && item.newResponse !== "")
148+
// str += ", \"edited_content\": " + JSON.stringify(item.newResponse);
149+
// if (isResponse && item.stopped)
150+
// str += ", \"stopped\": \"true\""
151+
// if (!isResponse)
152+
// str += "},"
153+
// else
154+
// str += ((i < chatModel.count - 1) ? "}," : "}")
155+
// }
156+
// return str + "]}"
157+
// }
155158

156159
ChatDrawer {
157160
id: chatDrawer
@@ -932,10 +935,7 @@ Rectangle {
932935
visible: false
933936
}
934937
onClicked: {
935-
var conversation = getConversation()
936-
copyEdit.text = conversation
937-
copyEdit.selectAll()
938-
copyEdit.copy()
938+
chatModel.copyToClipboard()
939939
copyMessage.open()
940940
}
941941
ToolTip.visible: copyChatButton.hovered
@@ -1354,9 +1354,10 @@ Rectangle {
13541354
ToolTip.text: Accessible.description
13551355

13561356
onClicked: {
1357-
var index = Math.max(0, chatModel.count - 1);
1358-
var listElement = chatModel.get(index);
1359-
listElement.stopped = true
1357+
// FIXME: This no longer sets a 'stopped' field so conversations that
1358+
// are copied to clipboard or to datalake don't indicate if the user
1359+
// has prematurely stopped the response. This has been broken since
1360+
// v3.0.0 at least.
13601361
currentChat.stopGenerating()
13611362
}
13621363
}

gpt4all-chat/src/chatmodel.h

+14
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,20 @@ class ChatModel : public QAbstractListModel
982982
emit hasErrorChanged(value);
983983
}
984984

985+
Q_INVOKABLE void copyToClipboard()
986+
{
987+
QMutexLocker locker(&m_mutex);
988+
QString conversation;
989+
for (ChatItem *item : m_chatItems) {
990+
QString string = item->name;
991+
string += item->clipboardContent();
992+
string += "\n";
993+
conversation += string;
994+
}
995+
QClipboard *clipboard = QGuiApplication::clipboard();
996+
clipboard->setText(conversation, QClipboard::Clipboard);
997+
}
998+
985999
Q_INVOKABLE void copyToClipboard(int index)
9861000
{
9871001
QMutexLocker locker(&m_mutex);

0 commit comments

Comments
 (0)