@@ -394,8 +394,8 @@ it('handles empty agent configs array', async () => {
394394 ) ;
395395} ) ;
396396
397- // New judge -related tests
398- describe ( 'judge method' , ( ) => {
397+ // New judgeConfig -related tests
398+ describe ( 'judgeConfig method' , ( ) => {
399399 it ( 'retrieves judge configuration successfully' , async ( ) => {
400400 const client = new LDAIClientImpl ( mockLdClient ) ;
401401 const key = 'test-judge' ;
@@ -421,7 +421,7 @@ describe('judge method', () => {
421421 const evaluateSpy = jest . spyOn ( client as any , '_evaluate' ) ;
422422 evaluateSpy . mockResolvedValue ( mockJudgeConfig ) ;
423423
424- const result = await client . judge ( key , testContext , defaultValue ) ;
424+ const result = await client . judgeConfig ( key , testContext , defaultValue ) ;
425425
426426 expect ( mockLdClient . track ) . toHaveBeenCalledWith (
427427 '$ld:ai:judge:function:single' ,
@@ -458,14 +458,14 @@ describe('judge method', () => {
458458 const evaluateSpy = jest . spyOn ( client as any , '_evaluate' ) ;
459459 evaluateSpy . mockResolvedValue ( mockJudgeConfig ) ;
460460
461- const result = await client . judge ( key , testContext , defaultValue , variables ) ;
461+ const result = await client . judgeConfig ( key , testContext , defaultValue , variables ) ;
462462
463463 expect ( evaluateSpy ) . toHaveBeenCalledWith ( key , testContext , defaultValue , 'judge' , variables ) ;
464464 expect ( result ) . toBe ( mockJudgeConfig ) ;
465465 } ) ;
466466} ) ;
467467
468- describe ( 'initJudge method' , ( ) => {
468+ describe ( 'createJudge method' , ( ) => {
469469 let mockProvider : jest . Mocked < any > ;
470470 let mockJudge : jest . Mocked < Judge > ;
471471
@@ -507,19 +507,22 @@ describe('initJudge method', () => {
507507 toVercelAISDK : jest . fn ( ) ,
508508 } ;
509509
510- // Mock the judge method
511- const judgeSpy = jest . spyOn ( client , 'judge ' ) ;
512- judgeSpy . mockResolvedValue ( mockJudgeConfig ) ;
510+ // Mock the judgeConfig method
511+ const judgeConfigSpy = jest . spyOn ( client , 'judgeConfig ' ) ;
512+ judgeConfigSpy . mockResolvedValue ( mockJudgeConfig ) ;
513513
514- const result = await client . initJudge ( key , testContext , defaultValue ) ;
514+ const result = await client . createJudge ( key , testContext , defaultValue ) ;
515515
516516 expect ( mockLdClient . track ) . toHaveBeenCalledWith (
517- '$ld:ai:judge:function:initJudge ' ,
517+ '$ld:ai:judge:function:createJudge ' ,
518518 testContext ,
519519 key ,
520520 1 ,
521521 ) ;
522- expect ( judgeSpy ) . toHaveBeenCalledWith ( key , testContext , defaultValue , undefined ) ;
522+ expect ( judgeConfigSpy ) . toHaveBeenCalledWith ( key , testContext , defaultValue , {
523+ message_history : '{{message_history}}' ,
524+ response_to_evaluate : '{{response_to_evaluate}}' ,
525+ } ) ;
523526 expect ( AIProviderFactory . create ) . toHaveBeenCalledWith ( mockJudgeConfig , undefined , undefined ) ;
524527 expect ( Judge ) . toHaveBeenCalledWith (
525528 mockJudgeConfig ,
@@ -551,10 +554,10 @@ describe('initJudge method', () => {
551554 toVercelAISDK : jest . fn ( ) ,
552555 } ;
553556
554- const judgeSpy = jest . spyOn ( client , 'judge ' ) ;
555- judgeSpy . mockResolvedValue ( mockJudgeConfig ) ;
557+ const judgeConfigSpy = jest . spyOn ( client , 'judgeConfig ' ) ;
558+ judgeConfigSpy . mockResolvedValue ( mockJudgeConfig ) ;
556559
557- const result = await client . initJudge ( key , testContext , defaultValue ) ;
560+ const result = await client . createJudge ( key , testContext , defaultValue ) ;
558561
559562 expect ( result ) . toBeUndefined ( ) ;
560563 expect ( AIProviderFactory . create ) . not . toHaveBeenCalled ( ) ;
@@ -582,12 +585,12 @@ describe('initJudge method', () => {
582585 toVercelAISDK : jest . fn ( ) ,
583586 } ;
584587
585- const judgeSpy = jest . spyOn ( client , 'judge ' ) ;
586- judgeSpy . mockResolvedValue ( mockJudgeConfig ) ;
588+ const judgeConfigSpy = jest . spyOn ( client , 'judgeConfig ' ) ;
589+ judgeConfigSpy . mockResolvedValue ( mockJudgeConfig ) ;
587590
588591 ( AIProviderFactory . create as jest . Mock ) . mockResolvedValue ( undefined ) ;
589592
590- const result = await client . initJudge ( key , testContext , defaultValue ) ;
593+ const result = await client . createJudge ( key , testContext , defaultValue ) ;
591594
592595 expect ( result ) . toBeUndefined ( ) ;
593596 expect ( AIProviderFactory . create ) . toHaveBeenCalledWith ( mockJudgeConfig , undefined , undefined ) ;
@@ -606,10 +609,10 @@ describe('initJudge method', () => {
606609 } ;
607610
608611 const error = new Error ( 'Judge configuration error' ) ;
609- const judgeSpy = jest . spyOn ( client , 'judge ' ) ;
610- judgeSpy . mockRejectedValue ( error ) ;
612+ const judgeConfigSpy = jest . spyOn ( client , 'judgeConfig ' ) ;
613+ judgeConfigSpy . mockRejectedValue ( error ) ;
611614
612- const result = await client . initJudge ( key , testContext , defaultValue ) ;
615+ const result = await client . createJudge ( key , testContext , defaultValue ) ;
613616
614617 expect ( result ) . toBeUndefined ( ) ;
615618 } ) ;
0 commit comments