mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-25 13:58:46 +01:00
server : (UI) fix missing async generator on safari (#10857)
* server : (UI) fix missing async generator on safari * fix
This commit is contained in:
parent
7b1ec53f56
commit
227d7c5a7f
Binary file not shown.
7
examples/server/webui/package-lock.json
generated
7
examples/server/webui/package-lock.json
generated
@ -8,6 +8,7 @@
|
|||||||
"name": "webui",
|
"name": "webui",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@sec-ant/readable-stream": "^0.6.0",
|
||||||
"@vscode/markdown-it-katex": "^1.1.1",
|
"@vscode/markdown-it-katex": "^1.1.1",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"daisyui": "^4.12.14",
|
"daisyui": "^4.12.14",
|
||||||
@ -617,6 +618,12 @@
|
|||||||
"win32"
|
"win32"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@sec-ant/readable-stream": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-uiBh8DrB5FN35gP6/o8JEhEQ7/ci1jUsOZO/VMUjyvTpjtV54VstOXVj1TvTj/wsT23pfX6butxxh3qufsW3+g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@vscode/markdown-it-katex": {
|
"node_modules/@vscode/markdown-it-katex": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@vscode/markdown-it-katex/-/markdown-it-katex-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@vscode/markdown-it-katex/-/markdown-it-katex-1.1.1.tgz",
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"vite": "^5.4.10"
|
"vite": "^5.4.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@sec-ant/readable-stream": "^0.6.0",
|
||||||
"@vscode/markdown-it-katex": "^1.1.1",
|
"@vscode/markdown-it-katex": "^1.1.1",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"daisyui": "^4.12.14",
|
"daisyui": "^4.12.14",
|
||||||
|
@ -5,13 +5,16 @@ import TextLineStream from 'textlinestream';
|
|||||||
|
|
||||||
// math formula rendering
|
// math formula rendering
|
||||||
import 'katex/dist/katex.min.css';
|
import 'katex/dist/katex.min.css';
|
||||||
import markdownItKatexGpt, { renderLatexHTML } from './katex-gpt';
|
import markdownItKatexGpt from './katex-gpt';
|
||||||
import markdownItKatexNormal from '@vscode/markdown-it-katex';
|
import markdownItKatexNormal from '@vscode/markdown-it-katex';
|
||||||
|
|
||||||
// code highlighting
|
// code highlighting
|
||||||
import hljs from './highlight-config';
|
import hljs from './highlight-config';
|
||||||
import daisyuiThemes from 'daisyui/src/theming/themes';
|
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';
|
const isDev = import.meta.env.MODE === 'development';
|
||||||
|
|
||||||
// utility functions
|
// utility functions
|
||||||
@ -283,7 +286,7 @@ async function* sendSSEPostRequest(url, fetchOptions) {
|
|||||||
const lines = res.body
|
const lines = res.body
|
||||||
.pipeThrough(new TextDecoderStream())
|
.pipeThrough(new TextDecoderStream())
|
||||||
.pipeThrough(new TextLineStream());
|
.pipeThrough(new TextLineStream());
|
||||||
for await (const line of lines) {
|
for await (const line of asyncIterator(lines)) {
|
||||||
if (isDev) console.log({line});
|
if (isDev) console.log({line});
|
||||||
if (line.startsWith('data:') && !line.endsWith('[DONE]')) {
|
if (line.startsWith('data:') && !line.endsWith('[DONE]')) {
|
||||||
const data = JSON.parse(line.slice(5));
|
const data = JSON.parse(line.slice(5));
|
||||||
|
Loading…
Reference in New Issue
Block a user