|
20 | 20 | from ragas.metrics.validators import AllowedValuesType |
21 | 21 | from ragas.prompt import FewShotPydanticPrompt, PromptMixin |
22 | 22 | 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 |
24 | 24 |
|
25 | 25 | if t.TYPE_CHECKING: |
26 | 26 | from langchain_core.callbacks import Callbacks |
@@ -150,79 +150,6 @@ def init(self, run_config: RunConfig) -> None: |
150 | 150 | """ |
151 | 151 | ... |
152 | 152 |
|
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 | | - |
226 | 153 |
|
227 | 154 | @dataclass |
228 | 155 | class MetricWithLLM(Metric, PromptMixin): |
|
0 commit comments