mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-15 11:22:23 +08:00
feat: stop generating answers
This commit is contained in:
@@ -3,9 +3,13 @@ import { streamAsyncIterable } from './stream-async-iterable'
|
||||
|
||||
export async function fetchSSE(resource, options) {
|
||||
const { onMessage, onStart, onEnd, onError, ...fetchOptions } = options
|
||||
const resp = await fetch(resource, fetchOptions)
|
||||
const resp = await fetch(resource, fetchOptions).catch(async (err) => {
|
||||
await onError(err)
|
||||
})
|
||||
if (!resp) return
|
||||
if (!resp.ok) {
|
||||
await onError(resp)
|
||||
return
|
||||
}
|
||||
const parser = createParser((event) => {
|
||||
if (event.type === 'event') {
|
||||
|
||||
Reference in New Issue
Block a user