|
16 | 16 | from ..commons.types.score_config import ScoreConfig
|
17 | 17 | from .types.create_score_config_request import CreateScoreConfigRequest
|
18 | 18 | from .types.score_configs import ScoreConfigs
|
| 19 | +from .types.update_score_config_request import UpdateScoreConfigRequest |
19 | 20 |
|
20 | 21 | # this is used as the default value for optional parameters
|
21 | 22 | OMIT = typing.cast(typing.Any, ...)
|
@@ -234,6 +235,81 @@ def get_by_id(
|
234 | 235 | raise ApiError(status_code=_response.status_code, body=_response.text)
|
235 | 236 | raise ApiError(status_code=_response.status_code, body=_response_json)
|
236 | 237 |
|
| 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 | + |
237 | 313 |
|
238 | 314 | class AsyncScoreConfigsClient:
|
239 | 315 | def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
@@ -471,3 +547,86 @@ async def main() -> None:
|
471 | 547 | except JSONDecodeError:
|
472 | 548 | raise ApiError(status_code=_response.status_code, body=_response.text)
|
473 | 549 | 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) |
0 commit comments