From 7a4ff424fc178c12e85c2bafdf3b63b0fed178ed Mon Sep 17 00:00:00 2001 From: Zander Chase <130414180+vowelparrot@users.noreply.github.com> Date: Wed, 21 Jun 2023 08:01:42 -0700 Subject: [PATCH] Relax string input mapper check (#6544) for run evaluator. It could be that an evalutor doesn't need the output --- langchain/evaluation/run_evaluators/implementations.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/langchain/evaluation/run_evaluators/implementations.py b/langchain/evaluation/run_evaluators/implementations.py index 8aea8e9d..d9d6290e 100644 --- a/langchain/evaluation/run_evaluators/implementations.py +++ b/langchain/evaluation/run_evaluators/implementations.py @@ -42,14 +42,12 @@ class StringRunEvaluatorInputMapper(RunEvaluatorInputMapper, BaseModel): answer_map: Optional[Dict[str, str]] = None """Map from example outputs to the evaluation inputs.""" - def map(self, run: Run, example: Optional[Example] = None) -> Dict[str, str]: + def map(self, run: Run, example: Optional[Example] = None) -> Dict[str, Any]: """Maps the Run and Optional[Example] to a dictionary""" - if run.outputs is None: + if run.outputs is None and self.prediction_map: raise ValueError(f"Run {run.id} has no outputs.") - - data = { - value: run.outputs.get(key) for key, value in self.prediction_map.items() - } + outputs = run.outputs or {} + data = {value: outputs.get(key) for key, value in self.prediction_map.items()} data.update( {value: run.inputs.get(key) for key, value in self.input_map.items()} )