33from mellea .stdlib .base import CBlock , ModelOutputThunk , ChatContext
44from mellea .backends .openai import OpenAIBackend
55from mellea .backends .aloras .openai .granite_aloras import add_granite_aloras
6- from mellea .stdlib .requirement import Requirement , ALoraRequirement , LLMaJRequirement
6+ from mellea .stdlib .requirement import Requirement , ALoraRequirement , LLMaJRequirement , req
77from mellea .backends .formatter import TemplateFormatter
88from mellea .backends .types import ModelOption
99
@@ -168,12 +168,11 @@ def test_constraint_lora_with_requirement(self):
168168 "Corporate wants you to find the difference between these two strings: aaaaaaaaaa aaaaabaaaa"
169169 )
170170 validation_outputs = self .m .validate (
171- "The answer should mention that there is a b in the middle of one of the strings but not the other." ,
172- return_full_validation_results = True ,
171+ ALoraRequirement ("The answer should mention that there is a b in the middle of one of the strings but not the other." ),
173172 )
174173 assert len (validation_outputs ) == 1
175- alora_output , valuation_boolean = validation_outputs [0 ]
176- assert str (alora_output ) in ["Y" , "N" ]
174+ val_result = validation_outputs [0 ]
175+ assert str (val_result . reason ) in ["Y" , "N" ]
177176 self .m .reset ()
178177
179178 def test_constraint_lora_override (self ):
@@ -183,12 +182,11 @@ def test_constraint_lora_override(self):
183182 "Corporate wants you to find the difference between these two strings: aaaaaaaaaa aaaaabaaaa"
184183 )
185184 validation_outputs = self .m .validate (
186- "The answer should mention that there is a b in the middle of one of the strings but not the other." ,
187- return_full_validation_results = True ,
185+ LLMaJRequirement ("The answer should mention that there is a b in the middle of one of the strings but not the other." ),
188186 )
189187 assert len (validation_outputs ) == 1
190- non_alora_output , _ = validation_outputs [0 ]
191- assert str (non_alora_output ) not in ["Y" , "N" ]
188+ val_result = validation_outputs [0 ]
189+ assert str (val_result . reason ) not in ["Y" , "N" ]
192190 self .backend .default_to_constraint_checking_alora = True
193191 self .m .reset ()
194192
@@ -202,11 +200,10 @@ def test_constraint_lora_override_does_not_override_alora(self):
202200 ALoraRequirement (
203201 "The answer should mention that there is a b in the middle of one of the strings but not the other."
204202 ),
205- return_full_validation_results = True ,
206203 )
207204 assert len (validation_outputs ) == 1
208- non_alora_output , _ = validation_outputs [0 ]
209- assert str (non_alora_output ) in ["Y" , "N" ]
205+ non_alora_output = validation_outputs [0 ]
206+ assert str (non_alora_output . reason ) in ["Y" , "N" ]
210207 self .backend .default_to_constraint_checking_alora = True
211208 self .m .reset ()
212209
@@ -220,11 +217,10 @@ def test_llmaj_req_does_not_use_alora(self):
220217 LLMaJRequirement (
221218 "The answer should mention that there is a b in the middle of one of the strings but not the other."
222219 ),
223- return_full_validation_results = True ,
224220 )
225221 assert len (validation_outputs ) == 1
226- non_alora_output , _ = validation_outputs [0 ]
227- assert str (non_alora_output ) not in ["Y" , "N" ]
222+ non_alora_output = validation_outputs [0 ]
223+ assert str (non_alora_output . reason ) not in ["Y" , "N" ]
228224 self .m .reset ()
229225
230226 def test_instruct (self ):
0 commit comments