From 5e1bbecdffb3c3314fdb568049fb0d243e9982ff Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:07:01 -0700 Subject: [PATCH] improve error message --- .../langchain/smith/evaluation/runner_utils.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/smith/evaluation/runner_utils.py b/libs/langchain/langchain/smith/evaluation/runner_utils.py index 9e06fcd65f4..b9c95168ac1 100644 --- a/libs/langchain/langchain/smith/evaluation/runner_utils.py +++ b/libs/langchain/langchain/smith/evaluation/runner_utils.py @@ -404,6 +404,17 @@ def _setup_evaluation( return run_evaluators, examples +def _format_eval_config_error(key_name: str, option: str) -> str: + """Format the eval config for a key.""" + return f""" + +For example: +RunEvalConfig( + evaluators=[...], + {key_name}="{option}", +)""" + + def _determine_input_key( config: RunEvalConfig, run_inputs: Optional[List[str]], @@ -417,7 +428,9 @@ def _determine_input_key( input_key = run_inputs[0] elif run_inputs is not None and len(run_inputs) > 1: raise ValueError( - f"Must specify input key for model with multiple inputs: {run_inputs}" + "Must specify input key for model with" + f" multiple inputs: {run_inputs}" + f"{_format_eval_config_error('input_key', run_inputs[0])}" ) return input_key @@ -432,7 +445,7 @@ def _determine_prediction_key( prediction_key = config.prediction_key if run_outputs and prediction_key not in run_outputs: raise ValueError( - f"Prediction key {prediction_key} not in run outputs {run_outputs}" + f"Prediction key {prediction_key} not in \n outputs {run_outputs}" ) elif run_outputs and len(run_outputs) == 1: prediction_key = run_outputs[0] @@ -440,6 +453,7 @@ def _determine_prediction_key( raise ValueError( f"Must specify prediction key for model" f" with multiple outputs: {run_outputs}" + f"{_format_eval_config_error('prediction_key', run_outputs[0])}" ) return prediction_key