@@ -301,6 +301,14 @@ def evaluate(
301
301
if "instructions" in record and "instruction_adherence" in config :
302
302
# Only pass instructions if instruction_adherence is specified in the config
303
303
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
+
304
312
payload ["config" ] = config
305
313
results .append (EvaluateResponse (record ['output' ], client .analyze .create (body = [payload ])))
306
314
@@ -447,6 +455,14 @@ def _run_eval(self, func, args, kwargs):
447
455
if "instructions" in record and "instruction_adherence" in self .config :
448
456
# Only pass instructions if instruction_adherence is specified in the config
449
457
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
+
450
466
payload ["config" ] = self .config
451
467
results .append ((result , self .client .analyze .create (body = [payload ])))
452
468
return results
@@ -489,6 +505,11 @@ def __init__(self, application, model, values_returned, api_key=None, config=Non
489
505
if "instruction_adherence" in self .config and "instructions" not in self .values_returned :
490
506
raise ValueError (
491
507
"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
+
492
513
if "instructions" in self .values_returned and "instruction_adherence" not in self .config :
493
514
raise ValueError (
494
515
"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):
522
543
aimon_payload ['instructions' ] = result_dict ['instructions' ]
523
544
if 'actual_request_timestamp' in result_dict :
524
545
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' ]
525
548
526
549
aimon_payload ['config' ] = self .config
527
550
aimon_response = self .client .analyze .create (body = [aimon_payload ])
0 commit comments