Skip to content

Commit

Permalink
add assert
Browse files Browse the repository at this point in the history
  • Loading branch information
shahules786 committed Sep 21, 2024
1 parent 579fff4 commit 701784b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ragas/experimental/metrics/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 701784b

Please sign in to comment.