Skip to content
10 changes: 10 additions & 0 deletions src/ragas/metrics/_context_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
"Attributed": "1",
},
},
{
"question": """What is the primary fuel for the Sun?""",
"context": """NULL""",
"answer": """Hydrogen""",
"classification": {
"statement_1": "The Sun's primary fuel is hydrogen.",
"reason": "The context contains no information",
"Attributed": "0",
},
},
],
input_keys=["question", "context", "answer"],
output_key="classification",
Expand Down
2 changes: 1 addition & 1 deletion src/ragas/metrics/_faithfulness.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async def _ascore(
is_async=is_async,
)

assert isinstance(statements, dict), "Invalid JSON response"
statements = statements if isinstance(statements, dict) else {}
p = self._create_nli_prompt(row, statements.get("statements", []))
nli_result = await self.llm.generate(p, callbacks=callbacks, is_async=is_async)
json_output = await json_loader.safe_load(
Expand Down