Skip to content

Commit bddfcb6

Browse files
committed
fix: Handle only regular content
1 parent 0d2ef37 commit bddfcb6

File tree

1 file changed

+9
-2
lines changed
  • tools/server/webui/src/lib/services

1 file changed

+9
-2
lines changed

tools/server/webui/src/lib/services/chat.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class ChatService {
208208
onError?.(contextError);
209209
return;
210210
}
211-
onComplete?.(fullResponse);
211+
onComplete?.(regularContent);
212212
return;
213213
}
214214

@@ -219,6 +219,9 @@ export class ChatService {
219219
hasReceivedData = true;
220220
fullResponse += content;
221221

222+
// Track the regular content before processing this chunk
223+
const regularContentBefore = regularContent;
224+
222225
// Process content character by character to handle think tags
223226
insideThinkTag = this.processContentForThinkTags(
224227
content,
@@ -231,7 +234,11 @@ export class ChatService {
231234
}
232235
);
233236

234-
onChunk?.(content);
237+
// Only send the new regular content that was added in this chunk
238+
const newRegularContent = regularContent.slice(regularContentBefore.length);
239+
if (newRegularContent) {
240+
onChunk?.(newRegularContent);
241+
}
235242
}
236243
} catch (e) {
237244
console.error('Error parsing JSON chunk:', e);

0 commit comments

Comments
 (0)