"src/git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "cd4121178ca26fe72d95247e07cdb2804b10f3d7"
Unverified Commit db5c4be6 authored by Timothy Jaeryang Baek's avatar Timothy Jaeryang Baek Committed by GitHub
Browse files

Merge pull request #1795 from cheahjs/fix/openai-handle-carriage-returns

fix: handle carriage returns in OpenAI streams
parents 6fbddb07 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]') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment