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
9ddc243c
Unverified
Commit
9ddc243c
authored
Apr 28, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Apr 28, 2024
Browse files
Merge pull request #1829 from cheahjs/fix/fluid-streaming-background
fix: fluid streaming was "pausing" when tab was not visible
parents
9832e6ed
ed9e99e9
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 @
9ddc243c
...
@@ -73,7 +73,11 @@ async function* streamLargeDeltasAsRandomChunks(
...
@@ -73,7 +73,11 @@ async function* streamLargeDeltasAsRandomChunks(
const
chunkSize
=
Math
.
min
(
Math
.
floor
(
Math
.
random
()
*
3
)
+
1
,
content
.
length
);
const
chunkSize
=
Math
.
min
(
Math
.
floor
(
Math
.
random
()
*
3
)
+
1
,
content
.
length
);
const
chunk
=
content
.
slice
(
0
,
chunkSize
);
const
chunk
=
content
.
slice
(
0
,
chunkSize
);
yield
{
done
:
false
,
value
:
chunk
};
yield
{
done
:
false
,
value
:
chunk
};
await
sleep
(
5
);
// Do not sleep if the tab is hidden
// Timers are throttled to 1s in hidden tabs
if
(
document
?.
visibilityState
!==
'
hidden
'
)
{
await
sleep
(
5
);
}
content
=
content
.
slice
(
chunkSize
);
content
=
content
.
slice
(
chunkSize
);
}
}
}
}
...
...
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