Skip to content

Commit 838f91d

Browse files
ngxsonarthw
authored andcommitted
server : (UI) fix missing async generator on safari (ggml-org#10857)
* server : (UI) fix missing async generator on safari * fix
1 parent 3b63e55 commit 838f91d

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

examples/server/public/index.html.gz

326 Bytes
Binary file not shown.

examples/server/webui/package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/server/webui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"vite": "^5.4.10"
1515
},
1616
"dependencies": {
17+
"@sec-ant/readable-stream": "^0.6.0",
1718
"@vscode/markdown-it-katex": "^1.1.1",
1819
"autoprefixer": "^10.4.20",
1920
"daisyui": "^4.12.14",

examples/server/webui/src/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ import TextLineStream from 'textlinestream';
55

66
// math formula rendering
77
import 'katex/dist/katex.min.css';
8-
import markdownItKatexGpt, { renderLatexHTML } from './katex-gpt';
8+
import markdownItKatexGpt from './katex-gpt';
99
import markdownItKatexNormal from '@vscode/markdown-it-katex';
1010

1111
// code highlighting
1212
import hljs from './highlight-config';
1313
import daisyuiThemes from 'daisyui/src/theming/themes';
1414

15+
// ponyfill for missing ReadableStream asyncIterator on Safari
16+
import { asyncIterator } from "@sec-ant/readable-stream/ponyfill/asyncIterator";
17+
1518
const isDev = import.meta.env.MODE === 'development';
1619

1720
// utility functions
@@ -283,7 +286,7 @@ async function* sendSSEPostRequest(url, fetchOptions) {
283286
const lines = res.body
284287
.pipeThrough(new TextDecoderStream())
285288
.pipeThrough(new TextLineStream());
286-
for await (const line of lines) {
289+
for await (const line of asyncIterator(lines)) {
287290
if (isDev) console.log({line});
288291
if (line.startsWith('data:') && !line.endsWith('[DONE]')) {
289292
const data = JSON.parse(line.slice(5));

0 commit comments

Comments
 (0)