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 {
132132 query : ResponseRetrieveParams | undefined = { } ,
133133 options ?: RequestOptions ,
134134 ) : 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 ;
139147 } ) as APIPromise < Response > | APIPromise < Stream < ResponseStreamEvent > > ;
140148 }
141149
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ describe('resource responses', () => {
1717 const dataAndResponse = await responsePromise . withResponse ( ) ;
1818 expect ( dataAndResponse . data ) . toBe ( response ) ;
1919 expect ( dataAndResponse . response ) . toBe ( rawResponse ) ;
20+
21+ expect ( response ) . toHaveProperty ( 'output_text' ) ;
22+ expect ( typeof response . output_text ) . toBe ( 'string' ) ;
2023 } ) ;
2124
2225 test ( 'retrieve' , async ( ) => {
@@ -28,6 +31,9 @@ describe('resource responses', () => {
2831 const dataAndResponse = await responsePromise . withResponse ( ) ;
2932 expect ( dataAndResponse . data ) . toBe ( response ) ;
3033 expect ( dataAndResponse . response ) . toBe ( rawResponse ) ;
34+
35+ expect ( response ) . toHaveProperty ( 'output_text' ) ;
36+ expect ( typeof response . output_text ) . toBe ( 'string' ) ;
3137 } ) ;
3238
3339 test ( 'retrieve: request options and params are passed correctly' , async ( ) => {
You can’t perform that action at this time.
0 commit comments