File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
tests/api-resources/responses Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -132,10 +132,18 @@ export class Responses extends APIResource {
132
132
query : ResponseRetrieveParams | undefined = { } ,
133
133
options ?: RequestOptions ,
134
134
) : APIPromise < Response > | APIPromise < Stream < ResponseStreamEvent > > {
135
- return this . _client . get ( path `/responses/${ responseID } ` , {
136
- query,
137
- ...options ,
138
- stream : query ?. stream ?? false ,
135
+ return (
136
+ this . _client . get ( path `/responses/${ responseID } ` , {
137
+ query,
138
+ ...options ,
139
+ stream : query ?. stream ?? false ,
140
+ } ) as APIPromise < Response > | APIPromise < Stream < ResponseStreamEvent > >
141
+ ) . _thenUnwrap ( ( rsp ) => {
142
+ if ( 'object' in rsp && rsp . object === 'response' ) {
143
+ addOutputText ( rsp as Response ) ;
144
+ }
145
+
146
+ return rsp ;
139
147
} ) as APIPromise < Response > | APIPromise < Stream < ResponseStreamEvent > > ;
140
148
}
141
149
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ describe('resource responses', () => {
17
17
const dataAndResponse = await responsePromise . withResponse ( ) ;
18
18
expect ( dataAndResponse . data ) . toBe ( response ) ;
19
19
expect ( dataAndResponse . response ) . toBe ( rawResponse ) ;
20
+
21
+ expect ( response ) . toHaveProperty ( 'output_text' ) ;
22
+ expect ( typeof response . output_text ) . toBe ( 'string' ) ;
20
23
} ) ;
21
24
22
25
test ( 'retrieve' , async ( ) => {
@@ -28,6 +31,9 @@ describe('resource responses', () => {
28
31
const dataAndResponse = await responsePromise . withResponse ( ) ;
29
32
expect ( dataAndResponse . data ) . toBe ( response ) ;
30
33
expect ( dataAndResponse . response ) . toBe ( rawResponse ) ;
34
+
35
+ expect ( response ) . toHaveProperty ( 'output_text' ) ;
36
+ expect ( typeof response . output_text ) . toBe ( 'string' ) ;
31
37
} ) ;
32
38
33
39
test ( 'retrieve: request options and params are passed correctly' , async ( ) => {
You can’t perform that action at this time.
0 commit comments