|
15 | 15 | from ..commons.errors.method_not_allowed_error import MethodNotAllowedError |
16 | 16 | from ..commons.errors.not_found_error import NotFoundError |
17 | 17 | from ..commons.errors.unauthorized_error import UnauthorizedError |
| 18 | +from ..scim.types.empty_response import EmptyResponse |
18 | 19 | from .types.create_prompt_request import CreatePromptRequest |
19 | 20 | from .types.prompt import Prompt |
20 | 21 | from .types.prompt_meta_list_response import PromptMetaListResponse |
@@ -292,6 +293,83 @@ def create( |
292 | 293 | raise ApiError(status_code=_response.status_code, body=_response.text) |
293 | 294 | raise ApiError(status_code=_response.status_code, body=_response_json) |
294 | 295 |
|
| 296 | + def delete( |
| 297 | + self, |
| 298 | + prompt_name: str, |
| 299 | + *, |
| 300 | + label: typing.Optional[str] = None, |
| 301 | + version: typing.Optional[int] = None, |
| 302 | + request_options: typing.Optional[RequestOptions] = None, |
| 303 | + ) -> EmptyResponse: |
| 304 | + """ |
| 305 | + Delete a prompt or specific versions |
| 306 | +
|
| 307 | + Parameters |
| 308 | + ---------- |
| 309 | + prompt_name : str |
| 310 | + The name of the prompt |
| 311 | +
|
| 312 | + label : typing.Optional[str] |
| 313 | + Optional label of the prompt to delete |
| 314 | +
|
| 315 | + version : typing.Optional[int] |
| 316 | + Optional version of the prompt to delete |
| 317 | +
|
| 318 | + request_options : typing.Optional[RequestOptions] |
| 319 | + Request-specific configuration. |
| 320 | +
|
| 321 | + Returns |
| 322 | + ------- |
| 323 | + EmptyResponse |
| 324 | +
|
| 325 | + Examples |
| 326 | + -------- |
| 327 | + from langfuse.client import FernLangfuse |
| 328 | +
|
| 329 | + client = FernLangfuse( |
| 330 | + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", |
| 331 | + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", |
| 332 | + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", |
| 333 | + username="YOUR_USERNAME", |
| 334 | + password="YOUR_PASSWORD", |
| 335 | + base_url="https://yourhost.com/path/to/api", |
| 336 | + ) |
| 337 | + client.prompts.delete( |
| 338 | + prompt_name="promptName", |
| 339 | + ) |
| 340 | + """ |
| 341 | + _response = self._client_wrapper.httpx_client.request( |
| 342 | + f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}", |
| 343 | + method="DELETE", |
| 344 | + params={"label": label, "version": version}, |
| 345 | + request_options=request_options, |
| 346 | + ) |
| 347 | + try: |
| 348 | + if 200 <= _response.status_code < 300: |
| 349 | + return pydantic_v1.parse_obj_as(EmptyResponse, _response.json()) # type: ignore |
| 350 | + if _response.status_code == 400: |
| 351 | + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore |
| 352 | + if _response.status_code == 401: |
| 353 | + raise UnauthorizedError( |
| 354 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 355 | + ) # type: ignore |
| 356 | + if _response.status_code == 403: |
| 357 | + raise AccessDeniedError( |
| 358 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 359 | + ) # type: ignore |
| 360 | + if _response.status_code == 405: |
| 361 | + raise MethodNotAllowedError( |
| 362 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 363 | + ) # type: ignore |
| 364 | + if _response.status_code == 404: |
| 365 | + raise NotFoundError( |
| 366 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 367 | + ) # type: ignore |
| 368 | + _response_json = _response.json() |
| 369 | + except JSONDecodeError: |
| 370 | + raise ApiError(status_code=_response.status_code, body=_response.text) |
| 371 | + raise ApiError(status_code=_response.status_code, body=_response_json) |
| 372 | + |
295 | 373 |
|
296 | 374 | class AsyncPromptsClient: |
297 | 375 | def __init__(self, *, client_wrapper: AsyncClientWrapper): |
@@ -585,3 +663,88 @@ async def main() -> None: |
585 | 663 | except JSONDecodeError: |
586 | 664 | raise ApiError(status_code=_response.status_code, body=_response.text) |
587 | 665 | raise ApiError(status_code=_response.status_code, body=_response_json) |
| 666 | + |
| 667 | + async def delete( |
| 668 | + self, |
| 669 | + prompt_name: str, |
| 670 | + *, |
| 671 | + label: typing.Optional[str] = None, |
| 672 | + version: typing.Optional[int] = None, |
| 673 | + request_options: typing.Optional[RequestOptions] = None, |
| 674 | + ) -> EmptyResponse: |
| 675 | + """ |
| 676 | + Delete a prompt or specific versions |
| 677 | +
|
| 678 | + Parameters |
| 679 | + ---------- |
| 680 | + prompt_name : str |
| 681 | + The name of the prompt |
| 682 | +
|
| 683 | + label : typing.Optional[str] |
| 684 | + Optional label of the prompt to delete |
| 685 | +
|
| 686 | + version : typing.Optional[int] |
| 687 | + Optional version of the prompt to delete |
| 688 | +
|
| 689 | + request_options : typing.Optional[RequestOptions] |
| 690 | + Request-specific configuration. |
| 691 | +
|
| 692 | + Returns |
| 693 | + ------- |
| 694 | + EmptyResponse |
| 695 | +
|
| 696 | + Examples |
| 697 | + -------- |
| 698 | + import asyncio |
| 699 | +
|
| 700 | + from langfuse.client import AsyncFernLangfuse |
| 701 | +
|
| 702 | + client = AsyncFernLangfuse( |
| 703 | + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", |
| 704 | + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", |
| 705 | + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", |
| 706 | + username="YOUR_USERNAME", |
| 707 | + password="YOUR_PASSWORD", |
| 708 | + base_url="https://yourhost.com/path/to/api", |
| 709 | + ) |
| 710 | +
|
| 711 | +
|
| 712 | + async def main() -> None: |
| 713 | + await client.prompts.delete( |
| 714 | + prompt_name="promptName", |
| 715 | + ) |
| 716 | +
|
| 717 | +
|
| 718 | + asyncio.run(main()) |
| 719 | + """ |
| 720 | + _response = await self._client_wrapper.httpx_client.request( |
| 721 | + f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}", |
| 722 | + method="DELETE", |
| 723 | + params={"label": label, "version": version}, |
| 724 | + request_options=request_options, |
| 725 | + ) |
| 726 | + try: |
| 727 | + if 200 <= _response.status_code < 300: |
| 728 | + return pydantic_v1.parse_obj_as(EmptyResponse, _response.json()) # type: ignore |
| 729 | + if _response.status_code == 400: |
| 730 | + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore |
| 731 | + if _response.status_code == 401: |
| 732 | + raise UnauthorizedError( |
| 733 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 734 | + ) # type: ignore |
| 735 | + if _response.status_code == 403: |
| 736 | + raise AccessDeniedError( |
| 737 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 738 | + ) # type: ignore |
| 739 | + if _response.status_code == 405: |
| 740 | + raise MethodNotAllowedError( |
| 741 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 742 | + ) # type: ignore |
| 743 | + if _response.status_code == 404: |
| 744 | + raise NotFoundError( |
| 745 | + pydantic_v1.parse_obj_as(typing.Any, _response.json()) |
| 746 | + ) # type: ignore |
| 747 | + _response_json = _response.json() |
| 748 | + except JSONDecodeError: |
| 749 | + raise ApiError(status_code=_response.status_code, body=_response.text) |
| 750 | + raise ApiError(status_code=_response.status_code, body=_response_json) |
0 commit comments