xiongzhu 2 năm trước cách đây
mục cha
commit
53e2d816fb
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      src/chatapi/fetch-sse.ts

+ 3 - 0
src/chatapi/fetch-sse.ts

@@ -3,6 +3,7 @@ import { createParser } from 'eventsource-parser'
 import * as types from './types'
 import * as types from './types'
 import { fetch as globalFetch } from './fetch'
 import { fetch as globalFetch } from './fetch'
 import { streamAsyncIterable } from './stream-async-iterable'
 import { streamAsyncIterable } from './stream-async-iterable'
+import { Logger } from '@nestjs/common'
 
 
 export async function fetchSSE(
 export async function fetchSSE(
     url: string,
     url: string,
@@ -66,6 +67,7 @@ export async function fetchSSE(
     }
     }
 
 
     if (!res.body.getReader) {
     if (!res.body.getReader) {
+        Logger.log('fetchSSE: using polyfill', 'fetchSSE')
         // Vercel polyfills `fetch` with `node-fetch`, which doesn't conform to
         // Vercel polyfills `fetch` with `node-fetch`, which doesn't conform to
         // web standards, so this is a workaround...
         // web standards, so this is a workaround...
         const body: NodeJS.ReadableStream = res.body as any
         const body: NodeJS.ReadableStream = res.body as any
@@ -84,6 +86,7 @@ export async function fetchSSE(
             onMessage('[DONE]')
             onMessage('[DONE]')
         })
         })
     } else {
     } else {
+        Logger.log('fetchSSE: using native', 'fetchSSE')
         for await (const chunk of streamAsyncIterable(res.body)) {
         for await (const chunk of streamAsyncIterable(res.body)) {
             const str = new TextDecoder().decode(chunk)
             const str = new TextDecoder().decode(chunk)
             feed(str)
             feed(str)