@@ -48,14 +48,14 @@ def __init__(self, metric: Metric, **kwargs: t.Any):
48
48
t .cast (MetricWithLLM , self .metric ).llm = LangchainLLMWrapper (llm )
49
49
if isinstance (self .metric , MetricWithEmbeddings ):
50
50
embeddings = get_or_init (kwargs , "embeddings" , OpenAIEmbeddings )
51
- t .cast (MetricWithEmbeddings , self . metric ). embeddings = (
52
- LangchainEmbeddingsWrapper ( embeddings )
53
- )
51
+ t .cast (
52
+ MetricWithEmbeddings , self . metric
53
+ ). embeddings = LangchainEmbeddingsWrapper ( embeddings )
54
54
self .metric .init (run_config )
55
55
56
- assert isinstance (
57
- self . metric , SingleTurnMetric
58
- ), "Metric must be SingleTurnMetric"
56
+ assert isinstance (self . metric , SingleTurnMetric ), (
57
+ "Metric must be SingleTurnMetric"
58
+ )
59
59
60
60
@property
61
61
def input_keys (self ) -> list [str ]:
@@ -87,9 +87,9 @@ def _call(
87
87
_run_manager = run_manager or CallbackManagerForChainRun .get_noop_manager ()
88
88
callbacks = _run_manager .get_child ()
89
89
90
- assert isinstance (
91
- self . metric , SingleTurnMetric
92
- ), "Metric must be SingleTurnMetric"
90
+ assert isinstance (self . metric , SingleTurnMetric ), (
91
+ "Metric must be SingleTurnMetric"
92
+ )
93
93
score = self .metric .single_turn_score (
94
94
inputs ,
95
95
callbacks = callbacks ,
@@ -119,9 +119,9 @@ async def _acall(
119
119
_run_manager = run_manager or AsyncCallbackManagerForChainRun .get_noop_manager ()
120
120
# TODO: currently AsyncCallbacks are not supported in ragas
121
121
_run_manager .get_child ()
122
- assert isinstance (
123
- self . metric , SingleTurnMetric
124
- ), "Metric must be SingleTurnMetric"
122
+ assert isinstance (self . metric , SingleTurnMetric ), (
123
+ "Metric must be SingleTurnMetric"
124
+ )
125
125
score = await self .metric .single_turn_ascore (
126
126
inputs ,
127
127
callbacks = [],
@@ -160,9 +160,9 @@ def _validate_langsmith_eval(self, run: Run, example: t.Optional[Example]) -> No
160
160
"Expected 'question' and 'ground_truth' in example."
161
161
f"Got: { [k for k in example .inputs .keys ()]} "
162
162
)
163
- assert (
164
- run . outputs is not None
165
- ), "the current run has no outputs. The chain should output 'answer' and 'contexts' keys."
163
+ assert run . outputs is not None , (
164
+ "the current run has no outputs. The chain should output 'answer' and 'contexts' keys."
165
+ )
166
166
output_keys = get_required_columns_v1 (self .metric )
167
167
output_keys = [
168
168
key for key in output_keys if key not in ["question" , "ground_truth" ]
0 commit comments