diff --git a/src/ragas/metrics/_answer_relevance.py b/src/ragas/metrics/_answer_relevance.py index f4cc2b10e..03b6ea4f9 100644 --- a/src/ragas/metrics/_answer_relevance.py +++ b/src/ragas/metrics/_answer_relevance.py @@ -95,7 +95,9 @@ class ResponseRelevancy(MetricWithLLM, MetricWithEmbeddings, SingleTurnMetric): strictness: int = 3 def calculate_similarity(self, question: str, generated_questions: list[str]): - assert self.embeddings is not None + assert ( + self.embeddings is not None + ), f"Error: '{self.name}' requires embeddings to be set." question_vec = np.asarray(self.embeddings.embed_query(question)).reshape(1, -1) gen_question_vec = np.asarray( self.embeddings.embed_documents(generated_questions) diff --git a/src/ragas/metrics/_answer_similarity.py b/src/ragas/metrics/_answer_similarity.py index 67bd2c546..061c221ec 100644 --- a/src/ragas/metrics/_answer_similarity.py +++ b/src/ragas/metrics/_answer_similarity.py @@ -65,7 +65,9 @@ async def _single_turn_ascore( return await self._ascore(row, callbacks) async def _ascore(self, row: t.Dict, callbacks: Callbacks) -> float: - assert self.embeddings is not None, "embeddings must be set" + assert ( + self.embeddings is not None + ), f"Error: '{self.name}' requires embeddings to be set." ground_truth = t.cast(str, row["reference"]) answer = t.cast(str, row["response"])