|
6 | 6 | from ...core.request_options import RequestOptions |
7 | 7 | from .raw_client import AsyncRawEvaluatorsClient, RawEvaluatorsClient |
8 | 8 | from .types.create_evaluator_request import CreateEvaluatorRequest |
| 9 | +from .types.delete_evaluator_response import DeleteEvaluatorResponse |
9 | 10 | from .types.evaluator import Evaluator |
10 | 11 | from .types.evaluators import Evaluators |
11 | 12 |
|
@@ -211,6 +212,54 @@ def get( |
211 | 212 | _response = self._raw_client.get(evaluator_id, request_options=request_options) |
212 | 213 | return _response.data |
213 | 214 |
|
| 215 | + def delete( |
| 216 | + self, |
| 217 | + evaluator_id: str, |
| 218 | + *, |
| 219 | + request_options: typing.Optional[RequestOptions] = None, |
| 220 | + ) -> DeleteEvaluatorResponse: |
| 221 | + """ |
| 222 | + Delete an evaluator. |
| 223 | +
|
| 224 | + Important behavior: |
| 225 | + - This deletes the evaluator including all of its stored versions; `evaluatorId` may reference any version. |
| 226 | + - The API returns `409` while evaluation rules still reference the evaluator. Delete those evaluation rules first. |
| 227 | + - Langfuse-managed evaluators (`scope=managed`) cannot be deleted; the API returns `403`. |
| 228 | + - Scores already produced by the evaluator are not deleted. |
| 229 | +
|
| 230 | + Parameters |
| 231 | + ---------- |
| 232 | + evaluator_id : str |
| 233 | + Evaluator identifier returned by the evaluator endpoints. |
| 234 | +
|
| 235 | + request_options : typing.Optional[RequestOptions] |
| 236 | + Request-specific configuration. |
| 237 | +
|
| 238 | + Returns |
| 239 | + ------- |
| 240 | + DeleteEvaluatorResponse |
| 241 | +
|
| 242 | + Examples |
| 243 | + -------- |
| 244 | + from langfuse import LangfuseAPI |
| 245 | +
|
| 246 | + client = LangfuseAPI( |
| 247 | + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", |
| 248 | + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", |
| 249 | + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", |
| 250 | + username="YOUR_USERNAME", |
| 251 | + password="YOUR_PASSWORD", |
| 252 | + base_url="https://yourhost.com/path/to/api", |
| 253 | + ) |
| 254 | + client.unstable.evaluators.delete( |
| 255 | + evaluator_id="evaluatorId", |
| 256 | + ) |
| 257 | + """ |
| 258 | + _response = self._raw_client.delete( |
| 259 | + evaluator_id, request_options=request_options |
| 260 | + ) |
| 261 | + return _response.data |
| 262 | + |
214 | 263 |
|
215 | 264 | class AsyncEvaluatorsClient: |
216 | 265 | def __init__(self, *, client_wrapper: AsyncClientWrapper): |
@@ -435,3 +484,59 @@ async def main() -> None: |
435 | 484 | evaluator_id, request_options=request_options |
436 | 485 | ) |
437 | 486 | return _response.data |
| 487 | + |
| 488 | + async def delete( |
| 489 | + self, |
| 490 | + evaluator_id: str, |
| 491 | + *, |
| 492 | + request_options: typing.Optional[RequestOptions] = None, |
| 493 | + ) -> DeleteEvaluatorResponse: |
| 494 | + """ |
| 495 | + Delete an evaluator. |
| 496 | +
|
| 497 | + Important behavior: |
| 498 | + - This deletes the evaluator including all of its stored versions; `evaluatorId` may reference any version. |
| 499 | + - The API returns `409` while evaluation rules still reference the evaluator. Delete those evaluation rules first. |
| 500 | + - Langfuse-managed evaluators (`scope=managed`) cannot be deleted; the API returns `403`. |
| 501 | + - Scores already produced by the evaluator are not deleted. |
| 502 | +
|
| 503 | + Parameters |
| 504 | + ---------- |
| 505 | + evaluator_id : str |
| 506 | + Evaluator identifier returned by the evaluator endpoints. |
| 507 | +
|
| 508 | + request_options : typing.Optional[RequestOptions] |
| 509 | + Request-specific configuration. |
| 510 | +
|
| 511 | + Returns |
| 512 | + ------- |
| 513 | + DeleteEvaluatorResponse |
| 514 | +
|
| 515 | + Examples |
| 516 | + -------- |
| 517 | + import asyncio |
| 518 | +
|
| 519 | + from langfuse import AsyncLangfuseAPI |
| 520 | +
|
| 521 | + client = AsyncLangfuseAPI( |
| 522 | + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", |
| 523 | + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", |
| 524 | + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", |
| 525 | + username="YOUR_USERNAME", |
| 526 | + password="YOUR_PASSWORD", |
| 527 | + base_url="https://yourhost.com/path/to/api", |
| 528 | + ) |
| 529 | +
|
| 530 | +
|
| 531 | + async def main() -> None: |
| 532 | + await client.unstable.evaluators.delete( |
| 533 | + evaluator_id="evaluatorId", |
| 534 | + ) |
| 535 | +
|
| 536 | +
|
| 537 | + asyncio.run(main()) |
| 538 | + """ |
| 539 | + _response = await self._raw_client.delete( |
| 540 | + evaluator_id, request_options=request_options |
| 541 | + ) |
| 542 | + return _response.data |
0 commit comments