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
4 changed files with 13 additions and 2 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue