coyotte508 HF staff commited on
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
- if (messages.at(-1)?.from !== 'assistant') {
 
 
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
- messages.at(-1)!.content += isEndOfText
59
- ? data.token.text.replace('<', '')
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
- message = '';
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(