Skip to content

Commit

Permalink
server : (UI) fix missing async generator on safari (ggerganov#10857)
Browse files Browse the repository at this point in the history
* server : (UI) fix missing async generator on safari

* fix
  • Loading branch information
ngxson authored Dec 17, 2024
1 parent 7b1ec53 commit 227d7c5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Binary file modified examples/server/public/index.html.gz
Binary file not shown.
7 changes: 7 additions & 0 deletions examples/server/webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/server/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"vite": "^5.4.10"
},
"dependencies": {
"@sec-ant/readable-stream": "^0.6.0",
"@vscode/markdown-it-katex": "^1.1.1",
"autoprefixer": "^10.4.20",
"daisyui": "^4.12.14",
Expand Down
7 changes: 5 additions & 2 deletions examples/server/webui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import TextLineStream from 'textlinestream';

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

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

// ponyfill for missing ReadableStream asyncIterator on Safari
import { asyncIterator } from "@sec-ant/readable-stream/ponyfill/asyncIterator";

const isDev = import.meta.env.MODE === 'development';

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

0 comments on commit 227d7c5

Please sign in to comment.