Skip to content

Commit 317a2d8

Browse files
authored
fix: added types so you can pass langchain llms and embeddings too (#652)
1 parent 2a3c3ab commit 317a2d8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/ragas/embeddings/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
BaseRagasEmbeddings,
33
HuggingfaceEmbeddings,
44
LangchainEmbeddingsWrapper,
5+
embedding_factory,
56
)
67

78
__all__ = [
89
"HuggingfaceEmbeddings",
910
"BaseRagasEmbeddings",
1011
"LangchainEmbeddingsWrapper",
12+
"embedding_factory",
1113
]

src/ragas/evaluation.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
from ragas._analytics import EvaluationEvent, track
1212
from ragas.callbacks import new_group
13-
from ragas.embeddings.base import BaseRagasEmbeddings, LangchainEmbeddingsWrapper, embedding_factory
13+
from ragas.embeddings.base import (
14+
BaseRagasEmbeddings,
15+
LangchainEmbeddingsWrapper,
16+
embedding_factory,
17+
)
1418
from ragas.llms import llm_factory
1519
from ragas.exceptions import ExceptionInRunner
1620
from ragas.executor import Executor
@@ -36,8 +40,8 @@
3640
def evaluate(
3741
dataset: Dataset,
3842
metrics: list[Metric] | None = None,
39-
llm: t.Optional[BaseRagasLLM] = None,
40-
embeddings: t.Optional[BaseRagasEmbeddings] = None,
43+
llm: t.Optional[BaseRagasLLM | LangchainLLM] = None,
44+
embeddings: t.Optional[BaseRagasEmbeddings | LangchainEmbeddings] = None,
4145
callbacks: Callbacks = [],
4246
is_async: bool = False,
4347
max_workers: t.Optional[int] = None,
@@ -79,7 +83,7 @@ def evaluate(
7983
run_config: RunConfig, optional
8084
Configuration for runtime settings like timeout and retries. If not provided,
8185
default values are used.
82-
raise_exceptions: bool, optional
86+
raise_exceptions: True
8387
Whether to raise exceptions or not. If set to True then the evaluation will
8488
raise an exception if any of the metrics fail. If set to False then the
8589
evaluation will return `np.nan` for the row that failed. Default is True.

0 commit comments

Comments
 (0)