File tree 4 files changed +3
-36
lines changed
4 files changed +3
-36
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ async function main() {
56
56
stream: true ,
57
57
});
58
58
for await (const part of stream ) {
59
- process .stdout .write (part .choices [0 ]?.text || ' ' );
59
+ process .stdout .write (part .choices [0 ]?.delta ?. content || ' ' );
60
60
}
61
61
}
62
62
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " openai" ,
3
- "version" : " 4.0.0-beta.9 " ,
3
+ "version" : " 4.0.0-beta.10 " ,
4
4
"description" : " Client library for the OpenAI API" ,
5
5
"author" : " OpenAI <support@openai.com>" ,
6
6
"types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 1
1
import type { Response } from 'openai/_shims/fetch' ;
2
- import { ReadableStream } from 'openai/_shims/ReadableStream' ;
3
2
4
3
type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined ;
5
4
@@ -68,38 +67,6 @@ export class Stream<Item> implements AsyncIterable<Item> {
68
67
if ( ! done ) this . controller . abort ( ) ;
69
68
}
70
69
}
71
-
72
- toReadableStream ( ) : ReadableStream {
73
- const self = this ;
74
- let iter : AsyncIterator < Item > ;
75
- const encoder = new TextEncoder ( ) ;
76
-
77
- return new ReadableStream ( {
78
- async start ( ) {
79
- iter = self [ Symbol . asyncIterator ] ( ) ;
80
- } ,
81
- async pull ( ctrl ) {
82
- try {
83
- const { value, done } = await iter . next ( ) ;
84
- if ( done ) return ctrl . close ( ) ;
85
-
86
- const str =
87
- typeof value === 'string' ? value : (
88
- // Add a newline after JSON to make it easier to parse newline-separated JSON on the frontend.
89
- JSON . stringify ( value ) + '\n'
90
- ) ;
91
- const bytes = encoder . encode ( str ) ;
92
-
93
- ctrl . enqueue ( bytes ) ;
94
- } catch ( err ) {
95
- ctrl . error ( err ) ;
96
- }
97
- } ,
98
- async cancel ( ) {
99
- await iter . return ?.( ) ;
100
- } ,
101
- } ) ;
102
- }
103
70
}
104
71
105
72
class SSEDecoder {
Original file line number Diff line number Diff line change 1
- export const VERSION = '4.0.0-beta.9 ' ;
1
+ export const VERSION = '4.0.0-beta.10 ' ;
You can’t perform that action at this time.
0 commit comments