Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
81fb53e7
Unverified
Commit
81fb53e7
authored
Apr 26, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Apr 26, 2024
Browse files
Merge pull request #1780 from cheahjs/fix/harden-streaming
fix: harden openai streaming parsing
parents
add5269b
615e9e34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
src/lib/apis/streaming/index.ts
src/lib/apis/streaming/index.ts
+7
-3
No files found.
src/lib/apis/streaming/index.ts
View file @
81fb53e7
...
@@ -36,10 +36,14 @@ async function* openAIStreamToIterator(
...
@@ -36,10 +36,14 @@ async function* openAIStreamToIterator(
// OpenRouter sends heartbeats like ": OPENROUTER PROCESSING"
// OpenRouter sends heartbeats like ": OPENROUTER PROCESSING"
continue
continue
}
else
{
}
else
{
try
{
const
data
=
JSON
.
parse
(
line
.
replace
(
/^data: /
,
''
));
const
data
=
JSON
.
parse
(
line
.
replace
(
/^data: /
,
''
));
console
.
log
(
data
);
console
.
log
(
data
);
yield
{
done
:
false
,
value
:
data
.
choices
[
0
].
delta
.
content
??
''
};
yield
{
done
:
false
,
value
:
data
.
choices
?.[
0
]?.
delta
?.
content
??
''
};
}
catch
(
e
)
{
console
.
error
(
'
Error extracting delta from SSE event:
'
,
e
);
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment