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
be038ab8
Commit
be038ab8
authored
Apr 27, 2024
by
Jun Siang Cheah
Browse files
fix: handle carriage returns in OpenAI streams
parent
f8f9f27a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
src/lib/apis/streaming/index.ts
src/lib/apis/streaming/index.ts
+5
-1
No files found.
src/lib/apis/streaming/index.ts
View file @
be038ab8
...
@@ -26,7 +26,11 @@ async function* openAIStreamToIterator(
...
@@ -26,7 +26,11 @@ async function* openAIStreamToIterator(
break
;
break
;
}
}
const
lines
=
value
.
split
(
'
\n
'
);
const
lines
=
value
.
split
(
'
\n
'
);
for
(
const
line
of
lines
)
{
for
(
let
line
of
lines
)
{
if
(
line
.
endsWith
(
'
\r
'
))
{
// Remove trailing \r
line
=
line
.
slice
(
0
,
-
1
);
}
if
(
line
!==
''
)
{
if
(
line
!==
''
)
{
console
.
log
(
line
);
console
.
log
(
line
);
if
(
line
===
'
data: [DONE]
'
)
{
if
(
line
===
'
data: [DONE]
'
)
{
...
...
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