File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -663,5 +663,34 @@ describe('inference.ts', () => {
663663 expect ( mockCreate . mock . calls [ 0 ] [ 0 ] ) . toHaveProperty ( 'max_tokens' , 100 )
664664 expect ( mockCreate . mock . calls [ 0 ] [ 0 ] ) . not . toHaveProperty ( 'max_completion_tokens' )
665665 } )
666+
667+ it ( 'sends neither token param when both are undefined' , async ( ) => {
668+ const requestWithNoTokens = {
669+ ...mockRequest ,
670+ maxCompletionTokens : undefined ,
671+ maxTokens : undefined ,
672+ }
673+
674+ const mockResponse = {
675+ choices : [
676+ {
677+ message : {
678+ content : 'No token limit response' ,
679+ } ,
680+ } ,
681+ ] ,
682+ }
683+
684+ mockCreate . mockResolvedValueOnce ( mockResponse )
685+
686+ const result = await simpleInference ( requestWithNoTokens )
687+
688+ expect ( result ) . toBe ( 'No token limit response' )
689+ expect ( mockCreate ) . toHaveBeenCalledTimes ( 1 )
690+
691+ const params = mockCreate . mock . calls [ 0 ] [ 0 ]
692+ expect ( params ) . not . toHaveProperty ( 'max_tokens' )
693+ expect ( params ) . not . toHaveProperty ( 'max_completion_tokens' )
694+ } )
666695 } )
667696} )
You can’t perform that action at this time.
0 commit comments