File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/ragas/metrics/collections Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,14 @@ def __init__(
7676 name : str = "context_recall" ,
7777 ** kwargs ,
7878 ):
79- """Initialize ContextRecall metric with required components."""
79+ """
80+ Initialize ContextRecall metric with required components.
81+
82+ Args:
83+ llm: Modern instructor-based LLM for classification
84+ name: The metric name (default: "context_recall")
85+ **kwargs: Additional arguments passed to BaseMetric
86+ """
8087 # Set attributes explicitly before calling super()
8188 self .llm = llm
8289
@@ -102,6 +109,14 @@ async def ascore(
102109 Returns:
103110 MetricResult with recall score (0.0-1.0)
104111 """
112+ # Input validation
113+ if not user_input :
114+ raise ValueError ("user_input cannot be empty" )
115+ if not reference :
116+ raise ValueError ("reference cannot be empty" )
117+ if not retrieved_contexts :
118+ raise ValueError ("retrieved_contexts cannot be empty" )
119+
105120 # Combine contexts into a single string
106121 context = "\n " .join (retrieved_contexts ) if retrieved_contexts else ""
107122
You can’t perform that action at this time.
0 commit comments