1- import type { StreamTextOptions , StreamTextResponse } from '@xsai/stream-text'
1+ import type { StreamTextOptions , ChunkResult as XSAIChunkResult } from '@xsai/stream-text'
22import { streamText } from '@xsai/stream-text'
33
4- export interface StreamChunk extends StreamTextResponse {
4+ export interface ChunkResult extends XSAIChunkResult {
55 textPart : ( ) => string
66}
77
@@ -30,13 +30,13 @@ export interface StreamResponse {
3030 *
3131 * @returns The completion response as a stream of chunks.
3232 */
33- chunkStream : ( ) => AsyncGenerator < StreamChunk , void , unknown >
33+ chunkStream : ( ) => AsyncGenerator < ChunkResult , void , unknown >
3434 /**
3535 * Get the completion response as a stream of chunks.
3636 *
3737 * @returns The completion response as a stream of chunks.
3838 */
39- chunks : ( ) => Promise < StreamChunk [ ] >
39+ chunks : ( ) => Promise < ChunkResult [ ] >
4040}
4141
4242interface PipeHook < F , T > {
@@ -85,9 +85,9 @@ export async function stream(params: StreamTextOptions): Promise<StreamResponse>
8585 } )
8686 } )
8787
88- const chunkStreamHooks : PipeHook < StreamTextResponse , StreamChunk > [ ] = [ ]
89- const accumulatedChunks = new Promise < StreamChunk [ ] > ( ( resolve ) => {
90- const chunks : StreamChunk [ ] = [ ]
88+ const chunkStreamHooks : PipeHook < XSAIChunkResult , ChunkResult > [ ] = [ ]
89+ const accumulatedChunks = new Promise < ChunkResult [ ] > ( ( resolve ) => {
90+ const chunks : ChunkResult [ ] = [ ]
9191 chunkStreamHooks . push ( {
9292 onChunk : ( chunk ) => { chunks . push ( chunk ) } ,
9393 onDone : ( ) => { resolve ( chunks ) } ,
@@ -105,7 +105,7 @@ export async function stream(params: StreamTextOptions): Promise<StreamResponse>
105105 ) ,
106106 chunkStream : ( ) => asyncIteratorFromReadableStream (
107107 res . chunkStream ,
108- async ( value : StreamTextResponse ) : Promise < StreamChunk > => {
108+ async ( value : XSAIChunkResult ) : Promise < ChunkResult > => {
109109 return {
110110 ...value ,
111111 textPart : ( ) => {
0 commit comments