Add string example mapper (#9086)

Now that we accept any runnable or arbitrary function to evaluate, we
don't always look up the input keys. If an evaluator requires
references, we should try to infer if there's one key present. We only
have delayed validation here but it's better than nothing
This commit is contained in:
William FH 2023-08-10 17:07:02 -07:00 committed by GitHub
parent 5fc07fa524
commit 57dd4daa9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -375,7 +375,11 @@ class StringRunEvaluatorChain(Chain, RunEvaluator):
)
# Configure how example rows are fed as a reference string to the evaluator
if reference_key is not None or data_type in (DataType.llm, DataType.chat):
if (
reference_key is not None
or data_type in (DataType.llm, DataType.chat)
or evaluator.requires_reference
):
example_mapper = StringExampleMapper(reference_key=reference_key)
elif evaluator.requires_reference:
raise ValueError(