Commit
•
91e621a
1
Parent(s):
1b66f8d
🐛 Fix text generation
Browse files
src/routes/conversation/[id]/+page.svelte
CHANGED
@@ -49,16 +49,16 @@
|
|
49 |
if (!data) break;
|
50 |
|
51 |
if (!data.token.special) {
|
52 |
-
|
|
|
|
|
53 |
// First token has a space at the beginning, trim it
|
54 |
messages = [...messages, { from: 'assistant', content: data.token.text.trimStart() }];
|
55 |
} else {
|
56 |
const isEndOfText = endOfTextRegex.test(data.token.text);
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
: data.token.text;
|
61 |
-
messages = messages;
|
62 |
|
63 |
if (isEndOfText) break;
|
64 |
}
|
@@ -75,7 +75,7 @@
|
|
75 |
loading = true;
|
76 |
|
77 |
messages = [...messages, { from: 'user', content: message }];
|
78 |
-
|
79 |
const inputs =
|
80 |
messages
|
81 |
.map(
|
|
|
49 |
if (!data) break;
|
50 |
|
51 |
if (!data.token.special) {
|
52 |
+
const lastMessage = messages.at(-1);
|
53 |
+
|
54 |
+
if (lastMessage?.from !== 'assistant') {
|
55 |
// First token has a space at the beginning, trim it
|
56 |
messages = [...messages, { from: 'assistant', content: data.token.text.trimStart() }];
|
57 |
} else {
|
58 |
const isEndOfText = endOfTextRegex.test(data.token.text);
|
59 |
|
60 |
+
lastMessage.content += isEndOfText ? data.token.text.replace('<', '') : data.token.text;
|
61 |
+
messages = [...messages];
|
|
|
|
|
62 |
|
63 |
if (isEndOfText) break;
|
64 |
}
|
|
|
75 |
loading = true;
|
76 |
|
77 |
messages = [...messages, { from: 'user', content: message }];
|
78 |
+
|
79 |
const inputs =
|
80 |
messages
|
81 |
.map(
|