@@ -301,6 +301,14 @@ def evaluate(
301301 if "instructions" in record and "instruction_adherence" in config :
302302 # Only pass instructions if instruction_adherence is specified in the config
303303 payload ["instructions" ] = record ["instructions" ] or ""
304+
305+ if "retrieval_relevance" in config :
306+ if "task_definition" in record :
307+ payload ["task_definition" ] = record ["task_definition" ]
308+ else :
309+ raise ValueError ( "When retrieval_relevance is specified in the config, "
310+ "'task_definition' must be present in the dataset" )
311+
304312 payload ["config" ] = config
305313 results .append (EvaluateResponse (record ['output' ], client .analyze .create (body = [payload ])))
306314
@@ -447,6 +455,14 @@ def _run_eval(self, func, args, kwargs):
447455 if "instructions" in record and "instruction_adherence" in self .config :
448456 # Only pass instructions if instruction_adherence is specified in the config
449457 payload ["instructions" ] = record ["instructions" ] or ""
458+
459+ if "retrieval_relevance" in self .config :
460+ if "task_definition" in record :
461+ payload ["task_definition" ] = record ["task_definition" ]
462+ else :
463+ raise ValueError ( "When retrieval_relevance is specified in the config, "
464+ "'task_definition' must be present in the dataset" )
465+
450466 payload ["config" ] = self .config
451467 results .append ((result , self .client .analyze .create (body = [payload ])))
452468 return results
@@ -489,6 +505,11 @@ def __init__(self, application, model, values_returned, api_key=None, config=Non
489505 if "instruction_adherence" in self .config and "instructions" not in self .values_returned :
490506 raise ValueError (
491507 "When instruction_adherence is specified in the config, 'instructions' must be returned by the decorated function" )
508+
509+ if "retrieval_relevance" in self .config and "task_definition" not in self .values_returned :
510+ raise ValueError ( "When retrieval_relevance is specified in the config, "
511+ "'task_definition' must be returned by the decorated function" )
512+
492513 if "instructions" in self .values_returned and "instruction_adherence" not in self .config :
493514 raise ValueError (
494515 "instruction_adherence must be specified in the config for returning 'instructions' by the decorated function" )
@@ -522,6 +543,8 @@ def _run_production_analysis(self, func, args, kwargs):
522543 aimon_payload ['instructions' ] = result_dict ['instructions' ]
523544 if 'actual_request_timestamp' in result_dict :
524545 aimon_payload ["actual_request_timestamp" ] = result_dict ['actual_request_timestamp' ]
546+ if 'task_definition' in result_dict :
547+ aimon_payload ['task_definition' ] = result_dict ['task_definition' ]
525548
526549 aimon_payload ['config' ] = self .config
527550 aimon_response = self .client .analyze .create (body = [aimon_payload ])
0 commit comments