From 317a2d88c2917fecc24dd4804cb7e12d79a6bac5 Mon Sep 17 00:00:00 2001 From: Jithin James Date: Fri, 23 Feb 2024 01:20:56 -0800 Subject: [PATCH] fix: added types so you can pass langchain llms and embeddings too (#652) --- src/ragas/embeddings/__init__.py | 2 ++ src/ragas/evaluation.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ragas/embeddings/__init__.py b/src/ragas/embeddings/__init__.py index 72a02a3342..e78a95b99b 100644 --- a/src/ragas/embeddings/__init__.py +++ b/src/ragas/embeddings/__init__.py @@ -2,10 +2,12 @@ BaseRagasEmbeddings, HuggingfaceEmbeddings, LangchainEmbeddingsWrapper, + embedding_factory, ) __all__ = [ "HuggingfaceEmbeddings", "BaseRagasEmbeddings", "LangchainEmbeddingsWrapper", + "embedding_factory", ] diff --git a/src/ragas/evaluation.py b/src/ragas/evaluation.py index b518709f1e..1ef5588e95 100644 --- a/src/ragas/evaluation.py +++ b/src/ragas/evaluation.py @@ -10,7 +10,11 @@ from ragas._analytics import EvaluationEvent, track from ragas.callbacks import new_group -from ragas.embeddings.base import BaseRagasEmbeddings, LangchainEmbeddingsWrapper, embedding_factory +from ragas.embeddings.base import ( + BaseRagasEmbeddings, + LangchainEmbeddingsWrapper, + embedding_factory, +) from ragas.llms import llm_factory from ragas.exceptions import ExceptionInRunner from ragas.executor import Executor @@ -36,8 +40,8 @@ def evaluate( dataset: Dataset, metrics: list[Metric] | None = None, - llm: t.Optional[BaseRagasLLM] = None, - embeddings: t.Optional[BaseRagasEmbeddings] = None, + llm: t.Optional[BaseRagasLLM | LangchainLLM] = None, + embeddings: t.Optional[BaseRagasEmbeddings | LangchainEmbeddings] = None, callbacks: Callbacks = [], is_async: bool = False, max_workers: t.Optional[int] = None, @@ -79,7 +83,7 @@ def evaluate( run_config: RunConfig, optional Configuration for runtime settings like timeout and retries. If not provided, default values are used. - raise_exceptions: bool, optional + raise_exceptions: True Whether to raise exceptions or not. If set to True then the evaluation will raise an exception if any of the metrics fail. If set to False then the evaluation will return `np.nan` for the row that failed. Default is True.