Spaces:
Sleeping
Sleeping
feat(front): make frontend smoothing configurable
Browse files- .env +3 -1
- src/lib/utils/messageUpdates.ts +6 -0
.env
CHANGED
|
@@ -170,4 +170,6 @@ TOOLS=`[]`
|
|
| 170 |
BODY_SIZE_LIMIT=15728640
|
| 171 |
|
| 172 |
HF_ORG_ADMIN=
|
| 173 |
-
HF_ORG_EARLY_ACCESS=
|
|
|
|
|
|
|
|
|
| 170 |
BODY_SIZE_LIMIT=15728640
|
| 171 |
|
| 172 |
HF_ORG_ADMIN=
|
| 173 |
+
HF_ORG_EARLY_ACCESS=
|
| 174 |
+
|
| 175 |
+
PUBLIC_SMOOTH_UPDATES=false
|
src/lib/utils/messageUpdates.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
| 14 |
type MessageToolErrorUpdate,
|
| 15 |
type MessageToolResultUpdate,
|
| 16 |
} from "$lib/types/MessageUpdate";
|
|
|
|
| 17 |
|
| 18 |
export const isMessageWebSearchUpdate = (update: MessageUpdate): update is MessageWebSearchUpdate =>
|
| 19 |
update.type === MessageUpdateType.WebSearch;
|
|
@@ -94,6 +95,11 @@ export async function fetchMessageUpdates(
|
|
| 94 |
if (!response.body) {
|
| 95 |
throw Error("Body not defined");
|
| 96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
return smoothAsyncIterator(
|
| 98 |
streamMessageUpdatesToFullWords(endpointStreamToIterator(response, abortController))
|
| 99 |
);
|
|
|
|
| 14 |
type MessageToolErrorUpdate,
|
| 15 |
type MessageToolResultUpdate,
|
| 16 |
} from "$lib/types/MessageUpdate";
|
| 17 |
+
import { env as envPublic } from "$env/dynamic/public";
|
| 18 |
|
| 19 |
export const isMessageWebSearchUpdate = (update: MessageUpdate): update is MessageWebSearchUpdate =>
|
| 20 |
update.type === MessageUpdateType.WebSearch;
|
|
|
|
| 95 |
if (!response.body) {
|
| 96 |
throw Error("Body not defined");
|
| 97 |
}
|
| 98 |
+
|
| 99 |
+
if (!(envPublic.PUBLIC_SMOOTH_UPDATES === "true")) {
|
| 100 |
+
return endpointStreamToIterator(response, abortController);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
return smoothAsyncIterator(
|
| 104 |
streamMessageUpdatesToFullWords(endpointStreamToIterator(response, abortController))
|
| 105 |
);
|