Skip to content

Commit bdceb7c

Browse files
authored
fix(tarko-agent-ui): support all SSE line separators in streaming (#1568)
1 parent b7af1e8 commit bdceb7c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

multimodal/tarko/agent-ui/src/common/services/apiService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ class ApiService {
255255

256256
// Process all complete events in the buffer
257257
let eventEndIndex;
258-
while ((eventEndIndex = buffer.indexOf('\n\n')) !== -1) {
258+
while ((eventEndIndex = buffer.search(/\r\n\r\n|\n\n|\r\r/)) !== -1) {
259259
const eventString = buffer.slice(0, eventEndIndex);
260-
// Move buffer to the next event
261-
buffer = buffer.slice(eventEndIndex + 2);
260+
const sepLength = buffer.substr(eventEndIndex, 4) === '\r\n\r\n' ? 4 : 2;
261+
buffer = buffer.slice(eventEndIndex + sepLength);
262262

263263
if (eventString.startsWith('data: ')) {
264264
try {

0 commit comments

Comments
 (0)