]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server : (UI) fix missing async generator on safari (#10857)
authorXuan Son Nguyen <redacted>
Tue, 17 Dec 2024 08:52:09 +0000 (09:52 +0100)
committerGitHub <redacted>
Tue, 17 Dec 2024 08:52:09 +0000 (09:52 +0100)
* server : (UI) fix missing async generator on safari

* fix

examples/server/public/index.html.gz
examples/server/webui/package-lock.json
examples/server/webui/package.json
examples/server/webui/src/main.js

index 53d33feb344cd92d89ab2ca1f59e77722d7e6cfa..01dd41811d083cb3dfdf10860c00cc2b1f003832 100644 (file)
Binary files a/examples/server/public/index.html.gz and b/examples/server/public/index.html.gz differ
index 1d0ab023602a952e5ed2397575e87c62d2d5e8d0..bbebccbf20c6473a499726af968dbad4ed921358 100644 (file)
@@ -8,6 +8,7 @@
       "name": "webui",
       "version": "0.0.0",
       "dependencies": {
+        "@sec-ant/readable-stream": "^0.6.0",
         "@vscode/markdown-it-katex": "^1.1.1",
         "autoprefixer": "^10.4.20",
         "daisyui": "^4.12.14",
         "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": {
       "version": "1.1.1",
       "resolved": "https://registry.npmjs.org/@vscode/markdown-it-katex/-/markdown-it-katex-1.1.1.tgz",
index 48090c6dea53461ab08dfb80b587698e50f41df6..2836cce00d41d816ccd42bc6961985c09d32717e 100644 (file)
@@ -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",
index 441fd73519a6b888545ce9e6147184a83c26f0c6..2a3021ce98773dbbfd9b3d31d1d4ed0a7d290acf 100644 (file)
@@ -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
@@ -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));