Skip to content

Commit dda635f

Browse files
feat(api): api update (#526)
1 parent a313de7 commit dda635f

20 files changed

Lines changed: 1386 additions & 4 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-ad83f8f9f6d60b6ef468111bde705c475948948951ff9ec80c54c2df76ff5596.yml
1+
configured_endpoints: 73
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-00234fd425f75dd0ac33cdfd2b9e806a7fa29638ffc4ed4b91d5042a17ff5cfd.yml

api.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,28 @@ Methods:
274274
- <code title="post /v1/scenarios/runs/{id}/complete">client.scenarios.runs.<a href="./src/runloop_api_client/resources/scenarios/runs.py">complete</a>(id) -> <a href="./src/runloop_api_client/types/scenario_run_view.py">ScenarioRunView</a></code>
275275
- <code title="post /v1/scenarios/runs/{id}/score">client.scenarios.runs.<a href="./src/runloop_api_client/resources/scenarios/runs.py">score</a>(id) -> <a href="./src/runloop_api_client/types/scenario_run_view.py">ScenarioRunView</a></code>
276276

277+
## Scorers
278+
279+
Types:
280+
281+
```python
282+
from runloop_api_client.types.scenarios import (
283+
ScorerCreateResponse,
284+
ScorerRetrieveResponse,
285+
ScorerUpdateResponse,
286+
ScorerListResponse,
287+
ScorerValidateResponse,
288+
)
289+
```
290+
291+
Methods:
292+
293+
- <code title="post /v1/scenarios/scorers">client.scenarios.scorers.<a href="./src/runloop_api_client/resources/scenarios/scorers.py">create</a>(\*\*<a href="src/runloop_api_client/types/scenarios/scorer_create_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenarios/scorer_create_response.py">ScorerCreateResponse</a></code>
294+
- <code title="get /v1/scenarios/scorers/{id}">client.scenarios.scorers.<a href="./src/runloop_api_client/resources/scenarios/scorers.py">retrieve</a>(id) -> <a href="./src/runloop_api_client/types/scenarios/scorer_retrieve_response.py">ScorerRetrieveResponse</a></code>
295+
- <code title="post /v1/scenarios/scorers/{id}">client.scenarios.scorers.<a href="./src/runloop_api_client/resources/scenarios/scorers.py">update</a>(id, \*\*<a href="src/runloop_api_client/types/scenarios/scorer_update_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenarios/scorer_update_response.py">ScorerUpdateResponse</a></code>
296+
- <code title="get /v1/scenarios/scorers">client.scenarios.scorers.<a href="./src/runloop_api_client/resources/scenarios/scorers.py">list</a>(\*\*<a href="src/runloop_api_client/types/scenarios/scorer_list_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenarios/scorer_list_response.py">SyncScenarioScorersCursorIDPage[ScorerListResponse]</a></code>
297+
- <code title="post /v1/scenarios/scorers/{id}/validate">client.scenarios.scorers.<a href="./src/runloop_api_client/resources/scenarios/scorers.py">validate</a>(id, \*\*<a href="src/runloop_api_client/types/scenarios/scorer_validate_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenarios/scorer_validate_response.py">ScorerValidateResponse</a></code>
298+
277299
# Repositories
278300

279301
Types:

src/runloop_api_client/pagination.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
"AsyncScenariosCursorIDPage",
2323
"SyncScenarioRunsCursorIDPage",
2424
"AsyncScenarioRunsCursorIDPage",
25+
"SyncScenarioScorersCursorIDPage",
26+
"AsyncScenarioScorersCursorIDPage",
2527
]
2628

2729
_T = TypeVar("_T")
@@ -67,6 +69,11 @@ class ScenarioRunsCursorIDPageItem(Protocol):
6769
id: str
6870

6971

72+
@runtime_checkable
73+
class ScenarioScorersCursorIDPageItem(Protocol):
74+
id: str
75+
76+
7077
class SyncBlueprintsCursorIDPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
7178
blueprints: List[_T]
7279
has_more: Optional[bool] = None
@@ -481,3 +488,55 @@ def next_page_info(self) -> Optional[PageInfo]:
481488
return None
482489

483490
return PageInfo(params={"starting_after": item.id})
491+
492+
493+
class SyncScenarioScorersCursorIDPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
494+
scorers: List[_T]
495+
has_more: Optional[bool] = None
496+
total_count: Optional[int] = None
497+
498+
@override
499+
def _get_page_items(self) -> List[_T]:
500+
scorers = self.scorers
501+
if not scorers:
502+
return []
503+
return scorers
504+
505+
@override
506+
def next_page_info(self) -> Optional[PageInfo]:
507+
scorers = self.scorers
508+
if not scorers:
509+
return None
510+
511+
item = cast(Any, scorers[-1])
512+
if not isinstance(item, ScenarioScorersCursorIDPageItem) or item.id is None: # pyright: ignore[reportUnnecessaryComparison]
513+
# TODO emit warning log
514+
return None
515+
516+
return PageInfo(params={"starting_after": item.id})
517+
518+
519+
class AsyncScenarioScorersCursorIDPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
520+
scorers: List[_T]
521+
has_more: Optional[bool] = None
522+
total_count: Optional[int] = None
523+
524+
@override
525+
def _get_page_items(self) -> List[_T]:
526+
scorers = self.scorers
527+
if not scorers:
528+
return []
529+
return scorers
530+
531+
@override
532+
def next_page_info(self) -> Optional[PageInfo]:
533+
scorers = self.scorers
534+
if not scorers:
535+
return None
536+
537+
item = cast(Any, scorers[-1])
538+
if not isinstance(item, ScenarioScorersCursorIDPageItem) or item.id is None: # pyright: ignore[reportUnnecessaryComparison]
539+
# TODO emit warning log
540+
return None
541+
542+
return PageInfo(params={"starting_after": item.id})

src/runloop_api_client/resources/scenarios/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
RunsResourceWithStreamingResponse,
99
AsyncRunsResourceWithStreamingResponse,
1010
)
11+
from .scorers import (
12+
ScorersResource,
13+
AsyncScorersResource,
14+
ScorersResourceWithRawResponse,
15+
AsyncScorersResourceWithRawResponse,
16+
ScorersResourceWithStreamingResponse,
17+
AsyncScorersResourceWithStreamingResponse,
18+
)
1119
from .scenarios import (
1220
ScenariosResource,
1321
AsyncScenariosResource,
@@ -24,6 +32,12 @@
2432
"AsyncRunsResourceWithRawResponse",
2533
"RunsResourceWithStreamingResponse",
2634
"AsyncRunsResourceWithStreamingResponse",
35+
"ScorersResource",
36+
"AsyncScorersResource",
37+
"ScorersResourceWithRawResponse",
38+
"AsyncScorersResourceWithRawResponse",
39+
"ScorersResourceWithStreamingResponse",
40+
"AsyncScorersResourceWithStreamingResponse",
2741
"ScenariosResource",
2842
"AsyncScenariosResource",
2943
"ScenariosResourceWithRawResponse",

src/runloop_api_client/resources/scenarios/scenarios.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
scenario_start_run_params,
2121
scenario_list_public_params,
2222
)
23+
from .scorers import (
24+
ScorersResource,
25+
AsyncScorersResource,
26+
ScorersResourceWithRawResponse,
27+
AsyncScorersResourceWithRawResponse,
28+
ScorersResourceWithStreamingResponse,
29+
AsyncScorersResourceWithStreamingResponse,
30+
)
2331
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
2432
from ..._utils import (
2533
maybe_transform,
@@ -50,6 +58,10 @@ class ScenariosResource(SyncAPIResource):
5058
def runs(self) -> RunsResource:
5159
return RunsResource(self._client)
5260

61+
@cached_property
62+
def scorers(self) -> ScorersResource:
63+
return ScorersResource(self._client)
64+
5365
@cached_property
5466
def with_raw_response(self) -> ScenariosResourceWithRawResponse:
5567
"""
@@ -381,6 +393,10 @@ class AsyncScenariosResource(AsyncAPIResource):
381393
def runs(self) -> AsyncRunsResource:
382394
return AsyncRunsResource(self._client)
383395

396+
@cached_property
397+
def scorers(self) -> AsyncScorersResource:
398+
return AsyncScorersResource(self._client)
399+
384400
@cached_property
385401
def with_raw_response(self) -> AsyncScenariosResourceWithRawResponse:
386402
"""
@@ -708,6 +724,10 @@ def __init__(self, scenarios: ScenariosResource) -> None:
708724
def runs(self) -> RunsResourceWithRawResponse:
709725
return RunsResourceWithRawResponse(self._scenarios.runs)
710726

727+
@cached_property
728+
def scorers(self) -> ScorersResourceWithRawResponse:
729+
return ScorersResourceWithRawResponse(self._scenarios.scorers)
730+
711731

712732
class AsyncScenariosResourceWithRawResponse:
713733
def __init__(self, scenarios: AsyncScenariosResource) -> None:
@@ -733,6 +753,10 @@ def __init__(self, scenarios: AsyncScenariosResource) -> None:
733753
def runs(self) -> AsyncRunsResourceWithRawResponse:
734754
return AsyncRunsResourceWithRawResponse(self._scenarios.runs)
735755

756+
@cached_property
757+
def scorers(self) -> AsyncScorersResourceWithRawResponse:
758+
return AsyncScorersResourceWithRawResponse(self._scenarios.scorers)
759+
736760

737761
class ScenariosResourceWithStreamingResponse:
738762
def __init__(self, scenarios: ScenariosResource) -> None:
@@ -758,6 +782,10 @@ def __init__(self, scenarios: ScenariosResource) -> None:
758782
def runs(self) -> RunsResourceWithStreamingResponse:
759783
return RunsResourceWithStreamingResponse(self._scenarios.runs)
760784

785+
@cached_property
786+
def scorers(self) -> ScorersResourceWithStreamingResponse:
787+
return ScorersResourceWithStreamingResponse(self._scenarios.scorers)
788+
761789

762790
class AsyncScenariosResourceWithStreamingResponse:
763791
def __init__(self, scenarios: AsyncScenariosResource) -> None:
@@ -782,3 +810,7 @@ def __init__(self, scenarios: AsyncScenariosResource) -> None:
782810
@cached_property
783811
def runs(self) -> AsyncRunsResourceWithStreamingResponse:
784812
return AsyncRunsResourceWithStreamingResponse(self._scenarios.runs)
813+
814+
@cached_property
815+
def scorers(self) -> AsyncScorersResourceWithStreamingResponse:
816+
return AsyncScorersResourceWithStreamingResponse(self._scenarios.scorers)

0 commit comments

Comments
 (0)