@@ -97,4 +97,87 @@ describe('index', () => {
9797 expect ( body . topic_scoping_target ) . toBe ( 'input' ) ;
9898 } ) ;
9999 } ) ;
100+
101+ describe ( 'policy_include_tools field' , ( ) => {
102+ it ( 'should pass policy_include_tools in the API request (direct mode)' , async ( ) => {
103+ const capturedBodies : Record < string , unknown > [ ] = [ ] ;
104+ global . fetch = jest
105+ . fn ( )
106+ . mockImplementation ( ( _url : string , options : { body : string } ) => {
107+ capturedBodies . push (
108+ JSON . parse ( options . body ) as Record < string , unknown >
109+ ) ;
110+ return Promise . resolve ( {
111+ ok : true ,
112+ json : ( ) =>
113+ Promise . resolve ( {
114+ status : 'passed' ,
115+ score : 100 ,
116+ evaluationResults : [ ] ,
117+ } ) ,
118+ } ) ;
119+ } ) as typeof fetch ;
120+
121+ const client = new qualifire . Qualifire ( { apiKey : 'test-key' } ) ;
122+ await client . evaluate ( {
123+ input : 'What is AI?' ,
124+ output : 'Artificial Intelligence' ,
125+ groundingCheck : true ,
126+ policyIncludeTools : true ,
127+ } ) ;
128+
129+ expect ( capturedBodies ) . toHaveLength ( 1 ) ;
130+ const body = capturedBodies [ 0 ] ;
131+ expect ( body . policy_include_tools ) . toBe ( true ) ;
132+ } ) ;
133+
134+ it ( 'should pass policy_include_tools in the API request (framework mode)' , async ( ) => {
135+ const capturedBodies : Record < string , unknown > [ ] = [ ] ;
136+ global . fetch = jest
137+ . fn ( )
138+ . mockImplementation ( ( _url : string , options : { body : string } ) => {
139+ capturedBodies . push (
140+ JSON . parse ( options . body ) as Record < string , unknown >
141+ ) ;
142+ return Promise . resolve ( {
143+ ok : true ,
144+ json : ( ) =>
145+ Promise . resolve ( {
146+ status : 'passed' ,
147+ score : 100 ,
148+ evaluationResults : [ ] ,
149+ } ) ,
150+ } ) ;
151+ } ) as typeof fetch ;
152+
153+ const client = new qualifire . Qualifire ( { apiKey : 'test-key' } ) ;
154+ await client . evaluate ( {
155+ framework : 'openai' ,
156+ request : {
157+ model : 'gpt-4o' ,
158+ messages : [ { role : 'user' , content : 'Hello' } ] ,
159+ } ,
160+ response : {
161+ id : 'test' ,
162+ object : 'chat.completion' ,
163+ created : 123 ,
164+ model : 'gpt-4o' ,
165+ choices : [
166+ {
167+ index : 0 ,
168+ message : { role : 'assistant' , content : 'Hi' } ,
169+ finish_reason : 'stop' ,
170+ } ,
171+ ] ,
172+ usage : { prompt_tokens : 1 , completion_tokens : 1 , total_tokens : 2 } ,
173+ } ,
174+ groundingCheck : true ,
175+ policyIncludeTools : true ,
176+ } ) ;
177+
178+ expect ( capturedBodies ) . toHaveLength ( 1 ) ;
179+ const body = capturedBodies [ 0 ] ;
180+ expect ( body . policy_include_tools ) . toBe ( true ) ;
181+ } ) ;
182+ } ) ;
100183} ) ;
0 commit comments