@@ -116,7 +116,6 @@ describe('InferenceGatewayClient', () => {
116116 { role : MessageRole . system , content : 'You are a helpful assistant' } ,
117117 { role : MessageRole . user , content : 'Hello' } ,
118118 ] ,
119- stream : false ,
120119 } ;
121120
122121 const mockResponse : SchemaCreateChatCompletionResponse = {
@@ -152,7 +151,7 @@ describe('InferenceGatewayClient', () => {
152151 'http://localhost:8080/v1/chat/completions' ,
153152 expect . objectContaining ( {
154153 method : 'POST' ,
155- body : JSON . stringify ( mockRequest ) ,
154+ body : JSON . stringify ( { ... mockRequest , stream : false } ) ,
156155 } )
157156 ) ;
158157 } ) ;
@@ -161,7 +160,6 @@ describe('InferenceGatewayClient', () => {
161160 const mockRequest = {
162161 model : 'claude-3-opus-20240229' ,
163162 messages : [ { role : MessageRole . user , content : 'Hello' } ] ,
164- stream : false ,
165163 } ;
166164
167165 const mockResponse : SchemaCreateChatCompletionResponse = {
@@ -200,7 +198,7 @@ describe('InferenceGatewayClient', () => {
200198 'http://localhost:8080/v1/chat/completions?provider=anthropic' ,
201199 expect . objectContaining ( {
202200 method : 'POST' ,
203- body : JSON . stringify ( mockRequest ) ,
201+ body : JSON . stringify ( { ... mockRequest , stream : false } ) ,
204202 } )
205203 ) ;
206204 } ) ;
@@ -211,7 +209,6 @@ describe('InferenceGatewayClient', () => {
211209 const mockRequest = {
212210 model : 'gpt-4o' ,
213211 messages : [ { role : MessageRole . user , content : 'Hello' } ] ,
214- stream : true ,
215212 } ;
216213
217214 const mockStream = new TransformStream ( ) ;
@@ -258,6 +255,9 @@ describe('InferenceGatewayClient', () => {
258255 body : JSON . stringify ( {
259256 ...mockRequest ,
260257 stream : true ,
258+ stream_options : {
259+ include_usage : true ,
260+ } ,
261261 } ) ,
262262 } )
263263 ) ;
@@ -267,7 +267,6 @@ describe('InferenceGatewayClient', () => {
267267 const mockRequest = {
268268 model : 'gpt-4o' ,
269269 messages : [ { role : MessageRole . user , content : 'Hello' } ] ,
270- stream : true ,
271270 } ;
272271 const mockStream = new TransformStream ( ) ;
273272 const writer = mockStream . writable . getWriter ( ) ;
@@ -318,6 +317,9 @@ describe('InferenceGatewayClient', () => {
318317 body : JSON . stringify ( {
319318 ...mockRequest ,
320319 stream : true ,
320+ stream_options : {
321+ include_usage : true ,
322+ } ,
321323 } ) ,
322324 } )
323325 ) ;
@@ -341,7 +343,6 @@ describe('InferenceGatewayClient', () => {
341343 } ,
342344 } ,
343345 ] ,
344- stream : true ,
345346 } ;
346347
347348 const mockStream = new TransformStream ( ) ;
@@ -390,13 +391,25 @@ describe('InferenceGatewayClient', () => {
390391 } ,
391392 } ) ;
392393 expect ( callbacks . onFinish ) . toHaveBeenCalledTimes ( 1 ) ;
394+ expect ( mockFetch ) . toHaveBeenCalledWith (
395+ 'http://localhost:8080/v1/chat/completions' ,
396+ expect . objectContaining ( {
397+ method : 'POST' ,
398+ body : JSON . stringify ( {
399+ ...mockRequest ,
400+ stream : true ,
401+ stream_options : {
402+ include_usage : true ,
403+ } ,
404+ } ) ,
405+ } )
406+ ) ;
393407 } ) ;
394408
395409 it ( 'should handle errors in streaming chat completions' , async ( ) => {
396410 const mockRequest = {
397411 model : 'gpt-4o' ,
398412 messages : [ { role : MessageRole . user , content : 'Hello' } ] ,
399- stream : true ,
400413 } ;
401414
402415 mockFetch . mockResolvedValueOnce ( {
@@ -420,10 +433,6 @@ describe('InferenceGatewayClient', () => {
420433 const mockRequest = {
421434 model : 'gpt-4o' ,
422435 messages : [ { role : MessageRole . user , content : 'Hello' } ] ,
423- stream : true ,
424- stream_options : {
425- include_usage : true ,
426- } ,
427436 } ;
428437
429438 const mockStream = new TransformStream ( ) ;
@@ -478,6 +487,9 @@ describe('InferenceGatewayClient', () => {
478487 body : JSON . stringify ( {
479488 ...mockRequest ,
480489 stream : true ,
490+ stream_options : {
491+ include_usage : true ,
492+ } ,
481493 } ) ,
482494 } )
483495 ) ;
0 commit comments