Skip to content

Commit 60748e8

Browse files
authored
feat(api): update API spec from langfuse/langfuse 9b8868a (#1384)
1 parent 140d192 commit 60748e8

File tree

7 files changed

+337
-4
lines changed

7 files changed

+337
-4
lines changed

langfuse/api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
UpdateGenerationBody,
201201
UpdateGenerationEvent,
202202
UpdateObservationEvent,
203+
UpdateScoreConfigRequest,
203204
UpdateSpanBody,
204205
UpdateSpanEvent,
205206
UpsertLlmConnectionRequest,
@@ -433,6 +434,7 @@
433434
"UpdateGenerationBody",
434435
"UpdateGenerationEvent",
435436
"UpdateObservationEvent",
437+
"UpdateScoreConfigRequest",
436438
"UpdateSpanBody",
437439
"UpdateSpanEvent",
438440
"UpsertLlmConnectionRequest",

langfuse/api/reference.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5904,6 +5904,91 @@ client.score_configs.get_by_id(
59045904
</dl>
59055905

59065906

5907+
</dd>
5908+
</dl>
5909+
</details>
5910+
5911+
<details><summary><code>client.score_configs.<a href="src/langfuse/resources/score_configs/client.py">update</a>(...)</code></summary>
5912+
<dl>
5913+
<dd>
5914+
5915+
#### 📝 Description
5916+
5917+
<dl>
5918+
<dd>
5919+
5920+
<dl>
5921+
<dd>
5922+
5923+
Update a score config
5924+
</dd>
5925+
</dl>
5926+
</dd>
5927+
</dl>
5928+
5929+
#### 🔌 Usage
5930+
5931+
<dl>
5932+
<dd>
5933+
5934+
<dl>
5935+
<dd>
5936+
5937+
```python
5938+
from langfuse import UpdateScoreConfigRequest
5939+
from langfuse.client import FernLangfuse
5940+
5941+
client = FernLangfuse(
5942+
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
5943+
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
5944+
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
5945+
username="YOUR_USERNAME",
5946+
password="YOUR_PASSWORD",
5947+
base_url="https://yourhost.com/path/to/api",
5948+
)
5949+
client.score_configs.update(
5950+
config_id="configId",
5951+
request=UpdateScoreConfigRequest(),
5952+
)
5953+
5954+
```
5955+
</dd>
5956+
</dl>
5957+
</dd>
5958+
</dl>
5959+
5960+
#### ⚙️ Parameters
5961+
5962+
<dl>
5963+
<dd>
5964+
5965+
<dl>
5966+
<dd>
5967+
5968+
**config_id:** `str` — The unique langfuse identifier of a score config
5969+
5970+
</dd>
5971+
</dl>
5972+
5973+
<dl>
5974+
<dd>
5975+
5976+
**request:** `UpdateScoreConfigRequest`
5977+
5978+
</dd>
5979+
</dl>
5980+
5981+
<dl>
5982+
<dd>
5983+
5984+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
5985+
5986+
</dd>
5987+
</dl>
5988+
</dd>
5989+
</dl>
5990+
5991+
59075992
</dd>
59085993
</dl>
59095994
</details>

langfuse/api/resources/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@
234234
UserMeta,
235235
)
236236
from .score import CreateScoreRequest, CreateScoreResponse
237-
from .score_configs import CreateScoreConfigRequest, ScoreConfigs
237+
from .score_configs import (
238+
CreateScoreConfigRequest,
239+
ScoreConfigs,
240+
UpdateScoreConfigRequest,
241+
)
238242
from .score_v_2 import (
239243
GetScoresResponse,
240244
GetScoresResponseData,
@@ -449,6 +453,7 @@
449453
"UpdateGenerationBody",
450454
"UpdateGenerationEvent",
451455
"UpdateObservationEvent",
456+
"UpdateScoreConfigRequest",
452457
"UpdateSpanBody",
453458
"UpdateSpanEvent",
454459
"UpsertLlmConnectionRequest",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file was auto-generated by Fern from our API Definition.
22

3-
from .types import CreateScoreConfigRequest, ScoreConfigs
3+
from .types import CreateScoreConfigRequest, ScoreConfigs, UpdateScoreConfigRequest
44

5-
__all__ = ["CreateScoreConfigRequest", "ScoreConfigs"]
5+
__all__ = ["CreateScoreConfigRequest", "ScoreConfigs", "UpdateScoreConfigRequest"]

langfuse/api/resources/score_configs/client.py

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from ..commons.types.score_config import ScoreConfig
1717
from .types.create_score_config_request import CreateScoreConfigRequest
1818
from .types.score_configs import ScoreConfigs
19+
from .types.update_score_config_request import UpdateScoreConfigRequest
1920

2021
# this is used as the default value for optional parameters
2122
OMIT = typing.cast(typing.Any, ...)
@@ -234,6 +235,81 @@ def get_by_id(
234235
raise ApiError(status_code=_response.status_code, body=_response.text)
235236
raise ApiError(status_code=_response.status_code, body=_response_json)
236237

238+
def update(
239+
self,
240+
config_id: str,
241+
*,
242+
request: UpdateScoreConfigRequest,
243+
request_options: typing.Optional[RequestOptions] = None,
244+
) -> ScoreConfig:
245+
"""
246+
Update a score config
247+
248+
Parameters
249+
----------
250+
config_id : str
251+
The unique langfuse identifier of a score config
252+
253+
request : UpdateScoreConfigRequest
254+
255+
request_options : typing.Optional[RequestOptions]
256+
Request-specific configuration.
257+
258+
Returns
259+
-------
260+
ScoreConfig
261+
262+
Examples
263+
--------
264+
from langfuse import UpdateScoreConfigRequest
265+
from langfuse.client import FernLangfuse
266+
267+
client = FernLangfuse(
268+
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
269+
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
270+
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
271+
username="YOUR_USERNAME",
272+
password="YOUR_PASSWORD",
273+
base_url="https://yourhost.com/path/to/api",
274+
)
275+
client.score_configs.update(
276+
config_id="configId",
277+
request=UpdateScoreConfigRequest(),
278+
)
279+
"""
280+
_response = self._client_wrapper.httpx_client.request(
281+
f"api/public/score-configs/{jsonable_encoder(config_id)}",
282+
method="PATCH",
283+
json=request,
284+
request_options=request_options,
285+
omit=OMIT,
286+
)
287+
try:
288+
if 200 <= _response.status_code < 300:
289+
return pydantic_v1.parse_obj_as(ScoreConfig, _response.json()) # type: ignore
290+
if _response.status_code == 400:
291+
raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
292+
if _response.status_code == 401:
293+
raise UnauthorizedError(
294+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
295+
) # type: ignore
296+
if _response.status_code == 403:
297+
raise AccessDeniedError(
298+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
299+
) # type: ignore
300+
if _response.status_code == 405:
301+
raise MethodNotAllowedError(
302+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
303+
) # type: ignore
304+
if _response.status_code == 404:
305+
raise NotFoundError(
306+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
307+
) # type: ignore
308+
_response_json = _response.json()
309+
except JSONDecodeError:
310+
raise ApiError(status_code=_response.status_code, body=_response.text)
311+
raise ApiError(status_code=_response.status_code, body=_response_json)
312+
237313

238314
class AsyncScoreConfigsClient:
239315
def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -471,3 +547,86 @@ async def main() -> None:
471547
except JSONDecodeError:
472548
raise ApiError(status_code=_response.status_code, body=_response.text)
473549
raise ApiError(status_code=_response.status_code, body=_response_json)
550+
551+
async def update(
552+
self,
553+
config_id: str,
554+
*,
555+
request: UpdateScoreConfigRequest,
556+
request_options: typing.Optional[RequestOptions] = None,
557+
) -> ScoreConfig:
558+
"""
559+
Update a score config
560+
561+
Parameters
562+
----------
563+
config_id : str
564+
The unique langfuse identifier of a score config
565+
566+
request : UpdateScoreConfigRequest
567+
568+
request_options : typing.Optional[RequestOptions]
569+
Request-specific configuration.
570+
571+
Returns
572+
-------
573+
ScoreConfig
574+
575+
Examples
576+
--------
577+
import asyncio
578+
579+
from langfuse import UpdateScoreConfigRequest
580+
from langfuse.client import AsyncFernLangfuse
581+
582+
client = AsyncFernLangfuse(
583+
x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
584+
x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
585+
x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
586+
username="YOUR_USERNAME",
587+
password="YOUR_PASSWORD",
588+
base_url="https://yourhost.com/path/to/api",
589+
)
590+
591+
592+
async def main() -> None:
593+
await client.score_configs.update(
594+
config_id="configId",
595+
request=UpdateScoreConfigRequest(),
596+
)
597+
598+
599+
asyncio.run(main())
600+
"""
601+
_response = await self._client_wrapper.httpx_client.request(
602+
f"api/public/score-configs/{jsonable_encoder(config_id)}",
603+
method="PATCH",
604+
json=request,
605+
request_options=request_options,
606+
omit=OMIT,
607+
)
608+
try:
609+
if 200 <= _response.status_code < 300:
610+
return pydantic_v1.parse_obj_as(ScoreConfig, _response.json()) # type: ignore
611+
if _response.status_code == 400:
612+
raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore
613+
if _response.status_code == 401:
614+
raise UnauthorizedError(
615+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
616+
) # type: ignore
617+
if _response.status_code == 403:
618+
raise AccessDeniedError(
619+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
620+
) # type: ignore
621+
if _response.status_code == 405:
622+
raise MethodNotAllowedError(
623+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
624+
) # type: ignore
625+
if _response.status_code == 404:
626+
raise NotFoundError(
627+
pydantic_v1.parse_obj_as(typing.Any, _response.json())
628+
) # type: ignore
629+
_response_json = _response.json()
630+
except JSONDecodeError:
631+
raise ApiError(status_code=_response.status_code, body=_response.text)
632+
raise ApiError(status_code=_response.status_code, body=_response_json)

langfuse/api/resources/score_configs/types/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
from .create_score_config_request import CreateScoreConfigRequest
44
from .score_configs import ScoreConfigs
5+
from .update_score_config_request import UpdateScoreConfigRequest
56

6-
__all__ = ["CreateScoreConfigRequest", "ScoreConfigs"]
7+
__all__ = ["CreateScoreConfigRequest", "ScoreConfigs", "UpdateScoreConfigRequest"]

0 commit comments

Comments
 (0)