Fix invalid json in AI doc SSE stream (#20706)

fix: invalid json in ai doc sse stream
This commit is contained in:
Greg Richardson authored and GitHub committed 2024-01-24 13:00:26 -07:00
1 parent 00aac39f77
commit 0417b8d96e
7 files changed
+7 -54

No files matched your search

-12
View File
@@ -1,12 +0,0 @@
declare module 'sse.js' {
export type SSEOptions = EventSourceInit & {
headers?: Record<string, string>
payload?: string
method?: string
}
export class SSE extends EventSource {
constructor(url: string | URL, sseOptions?: SSEOptions)
stream(): void
}
}
-12
View File
@@ -1,12 +0,0 @@
declare module 'sse.js' {
export type SSEOptions = EventSourceInit & {
headers?: Record<string, string>
payload?: string
method?: string
}
export class SSE extends EventSource {
constructor(url: string | URL, sseOptions?: SSEOptions)
stream(): void
}
}
-12
View File
@@ -1,12 +0,0 @@
declare module 'sse.js' {
export type SSEOptions = EventSourceInit & {
headers?: Record<string, string>
payload?: string
method?: string
}
export class SSE extends EventSource {
constructor(url: string | URL, sseOptions?: SSEOptions)
stream(): void
}
}
+4 -3
View File
@@ -32964,8 +32964,9 @@
}
},
"node_modules/sse.js": {
"version": "0.6.1",
"license": "Apache-2.0"
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/sse.js/-/sse.js-2.2.0.tgz",
"integrity": "sha512-v1ciaikunC99FKS23rS973HYU0DnnvugtX13UggNvrgRUSungaGeLmKlm57t0dI2E1TcCqzc2Pj2njBDXFIpKQ=="
},
"node_modules/ssr-window": {
"version": "3.0.0",
@@ -37217,7 +37218,7 @@
"react-tooltip": "^4.2.17",
"reactflow": "^11.10.1",
"remark-gfm": "^3.0.1",
"sse.js": "^0.6.1",
"sse.js": "^2.2.0",
"tailwind-merge": "^1.13.2",
"tailwindcss": "^3.4.1",
"tailwindcss-animate": "^1.0.6",
+1 -1
View File
@@ -77,7 +77,7 @@
"react-tooltip": "^4.2.17",
"reactflow": "^11.10.1",
"remark-gfm": "^3.0.1",
"sse.js": "^0.6.1",
"sse.js": "^2.2.0",
"tailwind-merge": "^1.13.2",
"tailwindcss": "^3.4.1",
"tailwindcss-animate": "^1.0.6",
@@ -198,7 +198,7 @@ export function useAiChat({
}
eventSource.addEventListener('error', handleError)
eventSource.addEventListener('message', (e) => {
eventSource.addEventListener('message', (e: MessageEvent) => {
try {
setIsLoading?.(false)
@@ -307,7 +307,7 @@ export function queryAi(messages: Message[], timeout = 0) {
let answer = ''
eventSource.addEventListener('error', handleError)
eventSource.addEventListener('message', (e) => {
eventSource.addEventListener('message', (e: MessageEvent) => {
try {
if (e.data === '[DONE]') {
if (timeoutId) {
-12
View File
@@ -1,12 +0,0 @@
declare module 'sse.js' {
export type SSEOptions = EventSourceInit & {
headers?: Record<string, string>
payload?: string
method?: string
}
export class SSE extends EventSource {
constructor(url: string | URL, sseOptions?: SSEOptions)
stream(): void
}
}