Skip to content

Commit b06f4f9

Browse files
committed
Revert "combine assistant messages"
This reverts commit 7a5ba03.
1 parent 7a5ba03 commit b06f4f9

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/lib/components/InferencePlayground/InferencePlayground.svelte

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,18 @@
9292
9393
if (conversation.streaming) {
9494
const streamingMessage = { role: "assistant", content: "" };
95-
conversation.messages.push(streamingMessage);
95+
conversation.messages = [...conversation.messages, streamingMessage];
9696
abortController = new AbortController();
97-
let firstChunk = true;
98-
let previousContent = "";
9997
10098
await handleStreamingResponse(
10199
hf,
102100
conversation,
103101
content => {
104-
if (firstChunk && conversation.messages.at(-2)?.role === "assistant") {
105-
// if last two messages are both "assistant" messages, then combine the contexts
106-
const streamingMessage = conversation.messages.pop();
107-
const { content } = conversation.messages.pop();
108-
previousContent = content;
109-
if (previousContent && !/\s$/.test(previousContent)) {
110-
previousContent += " ";
111-
}
112-
conversation.messages = [...conversation.messages, streamingMessage];
102+
if (streamingMessage) {
103+
streamingMessage.content = content;
104+
conversation.messages = [...conversation.messages];
105+
generatedTokensCount += 1;
113106
}
114-
conversation.messages.at(-1).content = previousContent ? `${previousContent}${content}` : content;
115-
conversation.messages = [...conversation.messages];
116-
generatedTokensCount += 1;
117-
firstChunk = false;
118107
},
119108
abortController
120109
);

0 commit comments

Comments
 (0)