Skip to content

Commit

Permalink
server : (UI) fix missing async generator on safari
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Dec 16, 2024
1 parent 160bc03 commit 5ba1fda
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 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
9 changes: 6 additions & 3 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 All @@ -33,7 +36,7 @@ const CONFIG_DEFAULT = {
systemMessage: 'You are a helpful assistant.',
showTokensPerSecond: false,
// make sure these default values are in sync with `common.h`
samplers: 'edkypmxt',
samplers: 'dkypmxt',
temperature: 0.8,
dynatemp_range: 0.0,
dynatemp_exponent: 1.0,
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 5ba1fda

Please sign in to comment.