From 701784b030431bf1de72a08d3bba014af96daf4c Mon Sep 17 00:00:00 2001 From: Shahules786 Date: Sat, 21 Sep 2024 16:25:24 +0530 Subject: [PATCH] add assert --- src/ragas/experimental/metrics/component.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ragas/experimental/metrics/component.py b/src/ragas/experimental/metrics/component.py index 563fc4a20..749be31ef 100644 --- a/src/ragas/experimental/metrics/component.py +++ b/src/ragas/experimental/metrics/component.py @@ -167,7 +167,11 @@ async def apply( for i in range(0, len(prompt_input_list), self.batch_size): prompt_input_list_batch = prompt_input_list[i : i + self.batch_size] response = self.hf_pipeline(prompt_input_list_batch, **self.model_kwargs) - response = [item[0]["label"] == self.label for item in response] + assert isinstance(response, list), "Response should be a list" + assert all( + isinstance(item, dict) for item in response + ), "Items in response should be dictionaries" + response = [item[0].get("label") == self.label for item in response] # type: ignore scores.extend(response) return scores