Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 92 additions & 1 deletion langfuse/api/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -4482,7 +4482,7 @@ client.organizations.get_organization_api_keys()
<dl>
<dd>

Get Project associated with API key
Get Project associated with API key (requires project-scoped API key). You can use GET /api/public/organizations/projects to get all projects with an organization-scoped key.
</dd>
</dl>
</dd>
Expand Down Expand Up @@ -5461,6 +5461,97 @@ client.prompts.create(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.prompts.<a href="src/langfuse/resources/prompts/client.py">delete</a>(...)</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

Delete prompt versions. If neither version nor label is specified, all versions of the prompt are deleted.
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```python
from langfuse.client import FernLangfuse

client = FernLangfuse(
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
username="YOUR_USERNAME",
password="YOUR_PASSWORD",
base_url="https://yourhost.com/path/to/api",
)
client.prompts.delete(
prompt_name="promptName",
)

```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**prompt_name:** `str` — The name of the prompt

</dd>
</dl>

<dl>
<dd>

**label:** `typing.Optional[str]` — Optional label to filter deletion. If specified, deletes all prompt versions that have this label.

</dd>
</dl>

<dl>
<dd>

**version:** `typing.Optional[int]` — Optional version to filter deletion. If specified, deletes only this specific version of the prompt.

</dd>
</dl>

<dl>
<dd>

**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
4 changes: 2 additions & 2 deletions langfuse/api/resources/projects/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> Projects:
"""
Get Project associated with API key
Get Project associated with API key (requires project-scoped API key). You can use GET /api/public/organizations/projects to get all projects with an organization-scoped key.

Parameters
----------
Expand Down Expand Up @@ -545,7 +545,7 @@ async def get(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> Projects:
"""
Get Project associated with API key
Get Project associated with API key (requires project-scoped API key). You can use GET /api/public/organizations/projects to get all projects with an organization-scoped key.

Parameters
----------
Expand Down
162 changes: 162 additions & 0 deletions langfuse/api/resources/prompts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,83 @@ def create(
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def delete(
self,
prompt_name: str,
*,
label: typing.Optional[str] = None,
version: typing.Optional[int] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> None:
"""
Delete prompt versions. If neither version nor label is specified, all versions of the prompt are deleted.

Parameters
----------
prompt_name : str
The name of the prompt

label : typing.Optional[str]
Optional label to filter deletion. If specified, deletes all prompt versions that have this label.

version : typing.Optional[int]
Optional version to filter deletion. If specified, deletes only this specific version of the prompt.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
None

Examples
--------
from langfuse.client import FernLangfuse

client = FernLangfuse(
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
username="YOUR_USERNAME",
password="YOUR_PASSWORD",
base_url="https://yourhost.com/path/to/api",
)
client.prompts.delete(
prompt_name="promptName",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}",
method="DELETE",
params={"label": label, "version": version},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return
if _response.status_code == 400:
raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
if _response.status_code == 401:
raise UnauthorizedError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
if _response.status_code == 403:
raise AccessDeniedError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
if _response.status_code == 405:
raise MethodNotAllowedError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
if _response.status_code == 404:
raise NotFoundError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)


class AsyncPromptsClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
Expand Down Expand Up @@ -585,3 +662,88 @@ async def main() -> None:
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def delete(
self,
prompt_name: str,
*,
label: typing.Optional[str] = None,
version: typing.Optional[int] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> None:
"""
Delete prompt versions. If neither version nor label is specified, all versions of the prompt are deleted.

Parameters
----------
prompt_name : str
The name of the prompt

label : typing.Optional[str]
Optional label to filter deletion. If specified, deletes all prompt versions that have this label.

version : typing.Optional[int]
Optional version to filter deletion. If specified, deletes only this specific version of the prompt.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
None

Examples
--------
import asyncio

from langfuse.client import AsyncFernLangfuse

client = AsyncFernLangfuse(
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
username="YOUR_USERNAME",
password="YOUR_PASSWORD",
base_url="https://yourhost.com/path/to/api",
)


async def main() -> None:
await client.prompts.delete(
prompt_name="promptName",
)


asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}",
method="DELETE",
params={"label": label, "version": version},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return
if _response.status_code == 400:
raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
if _response.status_code == 401:
raise UnauthorizedError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
if _response.status_code == 403:
raise AccessDeniedError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
if _response.status_code == 405:
raise MethodNotAllowedError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
if _response.status_code == 404:
raise NotFoundError(
pydantic_v1.parse_obj_as(typing.Any, _response.json())
) # type: ignore
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)
Loading