Skip to content

Commit c048966

Browse files
langfuse-botlangfuse-bot
andauthored
feat(api): update API spec from langfuse/langfuse fc04a50 (#1467)
Co-authored-by: langfuse-bot <langfuse-bot@langfuse.com>
1 parent f3eedca commit c048966

File tree

3 files changed

+256
-3
lines changed

3 files changed

+256
-3
lines changed

langfuse/api/reference.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4482,7 +4482,7 @@ client.organizations.get_organization_api_keys()
44824482
<dl>
44834483
<dd>
44844484

4485-
Get Project associated with API key
4485+
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.
44864486
</dd>
44874487
</dl>
44884488
</dd>
@@ -5461,6 +5461,97 @@ client.prompts.create(
54615461
</dl>
54625462

54635463

5464+
</dd>
5465+
</dl>
5466+
</details>
5467+
5468+
<details><summary><code>client.prompts.<a href="src/langfuse/resources/prompts/client.py">delete</a>(...)</code></summary>
5469+
<dl>
5470+
<dd>
5471+
5472+
#### 📝 Description
5473+
5474+
<dl>
5475+
<dd>
5476+
5477+
<dl>
5478+
<dd>
5479+
5480+
Delete prompt versions. If neither version nor label is specified, all versions of the prompt are deleted.
5481+
</dd>
5482+
</dl>
5483+
</dd>
5484+
</dl>
5485+
5486+
#### 🔌 Usage
5487+
5488+
<dl>
5489+
<dd>
5490+
5491+
<dl>
5492+
<dd>
5493+
5494+
```python
5495+
from langfuse.client import FernLangfuse
5496+
5497+
client = FernLangfuse(
5498+
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
5499+
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
5500+
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
5501+
username="YOUR_USERNAME",
5502+
password="YOUR_PASSWORD",
5503+
base_url="https://yourhost.com/path/to/api",
5504+
)
5505+
client.prompts.delete(
5506+
prompt_name="promptName",
5507+
)
5508+
5509+
```
5510+
</dd>
5511+
</dl>
5512+
</dd>
5513+
</dl>
5514+
5515+
#### ⚙️ Parameters
5516+
5517+
<dl>
5518+
<dd>
5519+
5520+
<dl>
5521+
<dd>
5522+
5523+
**prompt_name:** `str` — The name of the prompt
5524+
5525+
</dd>
5526+
</dl>
5527+
5528+
<dl>
5529+
<dd>
5530+
5531+
**label:** `typing.Optional[str]` — Optional label to filter deletion. If specified, deletes all prompt versions that have this label.
5532+
5533+
</dd>
5534+
</dl>
5535+
5536+
<dl>
5537+
<dd>
5538+
5539+
**version:** `typing.Optional[int]` — Optional version to filter deletion. If specified, deletes only this specific version of the prompt.
5540+
5541+
</dd>
5542+
</dl>
5543+
5544+
<dl>
5545+
<dd>
5546+
5547+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
5548+
5549+
</dd>
5550+
</dl>
5551+
</dd>
5552+
</dl>
5553+
5554+
54645555
</dd>
54655556
</dl>
54665557
</details>

langfuse/api/resources/projects/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def get(
3232
self, *, request_options: typing.Optional[RequestOptions] = None
3333
) -> Projects:
3434
"""
35-
Get Project associated with API key
35+
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.
3636
3737
Parameters
3838
----------
@@ -545,7 +545,7 @@ async def get(
545545
self, *, request_options: typing.Optional[RequestOptions] = None
546546
) -> Projects:
547547
"""
548-
Get Project associated with API key
548+
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.
549549
550550
Parameters
551551
----------

langfuse/api/resources/prompts/client.py

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,83 @@ def create(
292292
raise ApiError(status_code=_response.status_code, body=_response.text)
293293
raise ApiError(status_code=_response.status_code, body=_response_json)
294294

295+
def delete(
296+
self,
297+
prompt_name: str,
298+
*,
299+
label: typing.Optional[str] = None,
300+
version: typing.Optional[int] = None,
301+
request_options: typing.Optional[RequestOptions] = None,
302+
) -> None:
303+
"""
304+
Delete prompt versions. If neither version nor label is specified, all versions of the prompt are deleted.
305+
306+
Parameters
307+
----------
308+
prompt_name : str
309+
The name of the prompt
310+
311+
label : typing.Optional[str]
312+
Optional label to filter deletion. If specified, deletes all prompt versions that have this label.
313+
314+
version : typing.Optional[int]
315+
Optional version to filter deletion. If specified, deletes only this specific version of the prompt.
316+
317+
request_options : typing.Optional[RequestOptions]
318+
Request-specific configuration.
319+
320+
Returns
321+
-------
322+
None
323+
324+
Examples
325+
--------
326+
from langfuse.client import FernLangfuse
327+
328+
client = FernLangfuse(
329+
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
330+
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
331+
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
332+
username="YOUR_USERNAME",
333+
password="YOUR_PASSWORD",
334+
base_url="https://yourhost.com/path/to/api",
335+
)
336+
client.prompts.delete(
337+
prompt_name="promptName",
338+
)
339+
"""
340+
_response = self._client_wrapper.httpx_client.request(
341+
f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}",
342+
method="DELETE",
343+
params={"label": label, "version": version},
344+
request_options=request_options,
345+
)
346+
try:
347+
if 200 <= _response.status_code < 300:
348+
return
349+
if _response.status_code == 400:
350+
raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
351+
if _response.status_code == 401:
352+
raise UnauthorizedError(
353+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
354+
) # type: ignore
355+
if _response.status_code == 403:
356+
raise AccessDeniedError(
357+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
358+
) # type: ignore
359+
if _response.status_code == 405:
360+
raise MethodNotAllowedError(
361+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
362+
) # type: ignore
363+
if _response.status_code == 404:
364+
raise NotFoundError(
365+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
366+
) # type: ignore
367+
_response_json = _response.json()
368+
except JSONDecodeError:
369+
raise ApiError(status_code=_response.status_code, body=_response.text)
370+
raise ApiError(status_code=_response.status_code, body=_response_json)
371+
295372

296373
class AsyncPromptsClient:
297374
def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -585,3 +662,88 @@ async def main() -> None:
585662
except JSONDecodeError:
586663
raise ApiError(status_code=_response.status_code, body=_response.text)
587664
raise ApiError(status_code=_response.status_code, body=_response_json)
665+
666+
async def delete(
667+
self,
668+
prompt_name: str,
669+
*,
670+
label: typing.Optional[str] = None,
671+
version: typing.Optional[int] = None,
672+
request_options: typing.Optional[RequestOptions] = None,
673+
) -> None:
674+
"""
675+
Delete prompt versions. If neither version nor label is specified, all versions of the prompt are deleted.
676+
677+
Parameters
678+
----------
679+
prompt_name : str
680+
The name of the prompt
681+
682+
label : typing.Optional[str]
683+
Optional label to filter deletion. If specified, deletes all prompt versions that have this label.
684+
685+
version : typing.Optional[int]
686+
Optional version to filter deletion. If specified, deletes only this specific version of the prompt.
687+
688+
request_options : typing.Optional[RequestOptions]
689+
Request-specific configuration.
690+
691+
Returns
692+
-------
693+
None
694+
695+
Examples
696+
--------
697+
import asyncio
698+
699+
from langfuse.client import AsyncFernLangfuse
700+
701+
client = AsyncFernLangfuse(
702+
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
703+
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
704+
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
705+
username="YOUR_USERNAME",
706+
password="YOUR_PASSWORD",
707+
base_url="https://yourhost.com/path/to/api",
708+
)
709+
710+
711+
async def main() -> None:
712+
await client.prompts.delete(
713+
prompt_name="promptName",
714+
)
715+
716+
717+
asyncio.run(main())
718+
"""
719+
_response = await self._client_wrapper.httpx_client.request(
720+
f"api/public/v2/prompts/{jsonable_encoder(prompt_name)}",
721+
method="DELETE",
722+
params={"label": label, "version": version},
723+
request_options=request_options,
724+
)
725+
try:
726+
if 200 <= _response.status_code < 300:
727+
return
728+
if _response.status_code == 400:
729+
raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
730+
if _response.status_code == 401:
731+
raise UnauthorizedError(
732+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
733+
) # type: ignore
734+
if _response.status_code == 403:
735+
raise AccessDeniedError(
736+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
737+
) # type: ignore
738+
if _response.status_code == 405:
739+
raise MethodNotAllowedError(
740+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
741+
) # type: ignore
742+
if _response.status_code == 404:
743+
raise NotFoundError(
744+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
745+
) # type: ignore
746+
_response_json = _response.json()
747+
except JSONDecodeError:
748+
raise ApiError(status_code=_response.status_code, body=_response.text)
749+
raise ApiError(status_code=_response.status_code, body=_response_json)

0 commit comments

Comments
 (0)