Skip to content

Commit c1338ad

Browse files
committed
chore: remove deprecated Metric.ascore() and Metric.score() methods marked for v0.3 removal
1 parent 8501a49 commit c1338ad

File tree

1 file changed

+1
-74
lines changed

1 file changed

+1
-74
lines changed

src/ragas/metrics/base.py

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ragas.metrics.validators import AllowedValuesType
2121
from ragas.prompt import FewShotPydanticPrompt, PromptMixin
2222
from ragas.run_config import RunConfig
23-
from ragas.utils import camel_to_snake, deprecated, get_metric_language
23+
from ragas.utils import camel_to_snake, get_metric_language
2424

2525
if t.TYPE_CHECKING:
2626
from langchain_core.callbacks import Callbacks
@@ -150,79 +150,6 @@ def init(self, run_config: RunConfig) -> None:
150150
"""
151151
...
152152

153-
@deprecated("0.2", removal="0.3", alternative="single_turn_ascore")
154-
def score(self, row: t.Dict, callbacks: Callbacks = None) -> float:
155-
"""
156-
Calculates the score for a single row of data.
157-
158-
Note
159-
----
160-
This method is deprecated and will be removed in 0.3. Please use `single_turn_ascore` or `multi_turn_ascore` instead.
161-
"""
162-
callbacks = callbacks or []
163-
rm, group_cm = new_group(
164-
self.name,
165-
inputs=row,
166-
callbacks=callbacks,
167-
metadata={"type": ChainType.METRIC},
168-
)
169-
170-
async def _async_wrapper():
171-
try:
172-
result = await self._ascore(row=row, callbacks=group_cm)
173-
except Exception as e:
174-
if not group_cm.ended:
175-
rm.on_chain_error(e)
176-
raise e
177-
else:
178-
if not group_cm.ended:
179-
rm.on_chain_end({"output": result})
180-
return result
181-
182-
# Apply nest_asyncio logic to ensure compatibility in notebook/Jupyter environments.
183-
apply_nest_asyncio()
184-
return run(_async_wrapper)
185-
186-
@deprecated("0.2", removal="0.3", alternative="single_turn_ascore")
187-
async def ascore(
188-
self,
189-
row: t.Dict,
190-
callbacks: Callbacks = None,
191-
timeout: t.Optional[float] = None,
192-
) -> float:
193-
"""
194-
Asynchronously calculates the score for a single row of data.
195-
196-
Note
197-
----
198-
This method is deprecated and will be removed in 0.3. Please use `single_turn_ascore` instead.
199-
"""
200-
callbacks = callbacks or []
201-
rm, group_cm = new_group(
202-
self.name,
203-
inputs=row,
204-
callbacks=callbacks,
205-
metadata={"type": ChainType.METRIC},
206-
)
207-
try:
208-
score = await asyncio.wait_for(
209-
self._ascore(row=row, callbacks=group_cm),
210-
timeout=timeout,
211-
)
212-
except Exception as e:
213-
if not group_cm.ended:
214-
rm.on_chain_error(e)
215-
raise e
216-
else:
217-
if not group_cm.ended:
218-
rm.on_chain_end({"output": score})
219-
return score
220-
221-
async def _ascore(self, row: t.Dict, callbacks: Callbacks) -> float:
222-
raise NotImplementedError(
223-
f"Metric '{self.name}' has no implementation for _ascore. score() is deprecated and will be removed in 0.3. Please use single_turn_ascore or multi_turn_ascore instead."
224-
)
225-
226153

227154
@dataclass
228155
class MetricWithLLM(Metric, PromptMixin):

0 commit comments

Comments
 (0)