@@ -32,12 +32,15 @@ def __call__(self, lm, lm_kwargs, signature, demos, inputs):
3232
3333 value = self .parse (signature , output )
3434
35- assert set (value .keys ()) == set (signature .output_fields .keys ()), \
36- f"Expected { signature .output_fields .keys ()} but got { value .keys ()} "
37-
35+ if set (value .keys ()) != set (signature .output_fields .keys ()):
36+ raise ValueError (
37+ "Parsed output fields do not match signature output fields. "
38+ f"Expected: { set (signature .output_fields .keys ())} , Got: { set (value .keys ())} "
39+ )
40+
3841 if output_logprobs is not None :
3942 value ["logprobs" ] = output_logprobs
40-
43+
4144 values .append (value )
4245
4346 return values
@@ -46,18 +49,19 @@ def __call__(self, lm, lm_kwargs, signature, demos, inputs):
4649 if isinstance (e , ContextWindowExceededError ):
4750 # On context window exceeded error, we don't want to retry with a different adapter.
4851 raise e
49- from .json_adapter import JSONAdapter
52+ from dspy .adapters .json_adapter import JSONAdapter
53+
5054 if not isinstance (self , JSONAdapter ):
5155 return JSONAdapter ()(lm , lm_kwargs , signature , demos , inputs )
5256 raise e
5357
5458 @abstractmethod
5559 def format (self , signature , demos , inputs ):
56- raise NotImplementedError
60+ raise NotImplementedError
5761
5862 @abstractmethod
5963 def parse (self , signature , completion ):
60- raise NotImplementedError
64+ raise NotImplementedError
6165
6266 def format_finetune_data (self , signature , demos , inputs , outputs ):
6367 raise NotImplementedError
0 commit comments