From 5f74db4500d7ffa0fcb31b1f1a4ef07c8cf63aed Mon Sep 17 00:00:00 2001 From: Zander Chase <130414180+vowelparrot@users.noreply.github.com> Date: Thu, 8 Jun 2023 10:44:36 -0700 Subject: [PATCH] Update run eval imports in init (#5858) --- langchain/evaluation/run_evaluators/__init__.py | 14 ++++++++------ langchain/evaluation/run_evaluators/base.py | 4 ++-- .../evaluation/run_evaluators/implementations.py | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/langchain/evaluation/run_evaluators/__init__.py b/langchain/evaluation/run_evaluators/__init__.py index b6a6f57c..35a0f44b 100644 --- a/langchain/evaluation/run_evaluators/__init__.py +++ b/langchain/evaluation/run_evaluators/__init__.py @@ -1,20 +1,22 @@ """Evaluation classes that interface with traced runs and datasets.""" - - from langchain.evaluation.run_evaluators.base import ( - RunEvalInputMapper, - RunEvaluator, + RunEvaluatorChain, + RunEvaluatorInputMapper, RunEvaluatorOutputParser, ) from langchain.evaluation.run_evaluators.implementations import ( + ChoicesOutputParser, + StringRunEvaluatorInputMapper, get_criteria_evaluator, get_qa_evaluator, ) __all__ = [ - "RunEvaluator", - "RunEvalInputMapper", + "RunEvaluatorChain", + "RunEvaluatorInputMapper", "RunEvaluatorOutputParser", "get_qa_evaluator", "get_criteria_evaluator", + "StringRunEvaluatorInputMapper", + "ChoicesOutputParser", ] diff --git a/langchain/evaluation/run_evaluators/base.py b/langchain/evaluation/run_evaluators/base.py index 31aa047c..aa465548 100644 --- a/langchain/evaluation/run_evaluators/base.py +++ b/langchain/evaluation/run_evaluators/base.py @@ -15,7 +15,7 @@ from langchain.chains.llm import LLMChain from langchain.schema import RUN_KEY, BaseOutputParser -class RunEvalInputMapper: +class RunEvaluatorInputMapper: """Map the inputs of a run to the inputs of an evaluation.""" @abstractmethod @@ -37,7 +37,7 @@ class RunEvaluatorOutputParser(BaseOutputParser[EvaluationResult]): class RunEvaluatorChain(Chain, RunEvaluator): """Evaluate Run and optional examples.""" - input_mapper: RunEvalInputMapper + input_mapper: RunEvaluatorInputMapper """Maps the Run and Optional example to a dictionary for the eval chain.""" eval_chain: LLMChain """The evaluation chain.""" diff --git a/langchain/evaluation/run_evaluators/implementations.py b/langchain/evaluation/run_evaluators/implementations.py index a202d89d..a086a23b 100644 --- a/langchain/evaluation/run_evaluators/implementations.py +++ b/langchain/evaluation/run_evaluators/implementations.py @@ -10,8 +10,8 @@ from langchain.evaluation.qa.eval_chain import QAEvalChain from langchain.evaluation.qa.eval_prompt import PROMPT as QA_DEFAULT_PROMPT from langchain.evaluation.qa.eval_prompt import SQL_PROMPT from langchain.evaluation.run_evaluators.base import ( - RunEvalInputMapper, RunEvaluatorChain, + RunEvaluatorInputMapper, RunEvaluatorOutputParser, ) from langchain.evaluation.run_evaluators.criteria_prompt import ( @@ -25,7 +25,7 @@ _QA_PROMPTS = { } -class StringRunEvalInputMapper(RunEvalInputMapper, BaseModel): +class StringRunEvaluatorInputMapper(RunEvaluatorInputMapper, BaseModel): """Maps the Run and Optional[Example] to a dictionary.""" prediction_map: Mapping[str, str] @@ -97,7 +97,7 @@ def get_qa_evaluator( eval_chain = QAEvalChain.from_llm(llm=llm, prompt=prompt, **kwargs) input_mapper = kwargs.pop( "input_mapper", - StringRunEvalInputMapper( + StringRunEvaluatorInputMapper( input_map={input_key: "query"}, prediction_map={prediction_key: "result"}, answer_map={answer_key: "answer"}, @@ -179,7 +179,7 @@ def get_criteria_evaluator( prompt_ = prompt.partial(criteria=criteria_str) input_mapper = kwargs.pop( "input_mapper", - StringRunEvalInputMapper( + StringRunEvaluatorInputMapper( input_map={input_key: "input"}, prediction_map={prediction_key: "output"}, ),