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
510afab3
Commit
510afab3
authored
Apr 26, 2024
by
Jun Siang Cheah
Browse files
fix: catch any errors parsing openai sse events
parent
e9ba8d74
Changes
1
Hide 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 @
510afab3
...
...
@@ -32,10 +32,14 @@ async function* openAIStreamToIterator(
if
(
line
===
'
data: [DONE]
'
)
{
yield
{
done
:
true
,
value
:
''
};
}
else
{
const
data
=
JSON
.
parse
(
line
.
replace
(
/^data: /
,
''
));
console
.
log
(
data
);
try
{
const
data
=
JSON
.
parse
(
line
.
replace
(
/^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