Skip to content

Commit f55f4b7

Browse files
feat(api): api update
1 parent b956ce0 commit f55f4b7

File tree

7 files changed

+89
-19
lines changed

7 files changed

+89
-19
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
configured_endpoints: 55
2-
openapi_spec_hash: b3a1a58600b52a20671bef2b25f5dbc4
2+
openapi_spec_hash: 1e86d5a7384400f4c3ddfb824fb31d84
33
config_hash: 8f6e5c3b064cbb77569a6bf654954a56

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Methods:
192192

193193
- <code title="post /api/projects/{project_id}/evals">client.projects.evals.<a href="./src/codex/resources/projects/evals.py">create</a>(project_id, \*\*<a href="src/codex/types/projects/eval_create_params.py">params</a>) -> <a href="./src/codex/types/project_return_schema.py">ProjectReturnSchema</a></code>
194194
- <code title="put /api/projects/{project_id}/evals/{eval_key}">client.projects.evals.<a href="./src/codex/resources/projects/evals.py">update</a>(path_eval_key, \*, project_id, \*\*<a href="src/codex/types/projects/eval_update_params.py">params</a>) -> <a href="./src/codex/types/project_return_schema.py">ProjectReturnSchema</a></code>
195-
- <code title="get /api/projects/{project_id}/evals">client.projects.evals.<a href="./src/codex/resources/projects/evals.py">list</a>(project_id) -> <a href="./src/codex/types/projects/eval_list_response.py">EvalListResponse</a></code>
195+
- <code title="get /api/projects/{project_id}/evals">client.projects.evals.<a href="./src/codex/resources/projects/evals.py">list</a>(project_id, \*\*<a href="src/codex/types/projects/eval_list_params.py">params</a>) -> <a href="./src/codex/types/projects/eval_list_response.py">EvalListResponse</a></code>
196196
- <code title="delete /api/projects/{project_id}/evals/{eval_key}">client.projects.evals.<a href="./src/codex/resources/projects/evals.py">delete</a>(eval_key, \*, project_id) -> <a href="./src/codex/types/project_return_schema.py">ProjectReturnSchema</a></code>
197197

198198
## QueryLogs

src/codex/resources/projects/evals.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
async_to_streamed_response_wrapper,
1919
)
2020
from ..._base_client import make_request_options
21-
from ...types.projects import eval_create_params, eval_update_params
21+
from ...types.projects import eval_list_params, eval_create_params, eval_update_params
2222
from ...types.project_return_schema import ProjectReturnSchema
2323
from ...types.projects.eval_list_response import EvalListResponse
2424

@@ -324,6 +324,9 @@ def list(
324324
self,
325325
project_id: str,
326326
*,
327+
guardrails_only: bool | NotGiven = NOT_GIVEN,
328+
limit: Optional[int] | NotGiven = NOT_GIVEN,
329+
offset: int | NotGiven = NOT_GIVEN,
327330
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
328331
# The extra values given here take precedence over values defined on the client or passed to this method.
329332
extra_headers: Headers | None = None,
@@ -332,7 +335,7 @@ def list(
332335
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
333336
) -> EvalListResponse:
334337
"""
335-
Get the evaluations config for a project.
338+
Get the evaluations config for a project with optional pagination.
336339
337340
Args:
338341
extra_headers: Send extra headers
@@ -348,7 +351,18 @@ def list(
348351
return self._get(
349352
f"/api/projects/{project_id}/evals",
350353
options=make_request_options(
351-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
354+
extra_headers=extra_headers,
355+
extra_query=extra_query,
356+
extra_body=extra_body,
357+
timeout=timeout,
358+
query=maybe_transform(
359+
{
360+
"guardrails_only": guardrails_only,
361+
"limit": limit,
362+
"offset": offset,
363+
},
364+
eval_list_params.EvalListParams,
365+
),
352366
),
353367
cast_to=EvalListResponse,
354368
)
@@ -689,6 +703,9 @@ async def list(
689703
self,
690704
project_id: str,
691705
*,
706+
guardrails_only: bool | NotGiven = NOT_GIVEN,
707+
limit: Optional[int] | NotGiven = NOT_GIVEN,
708+
offset: int | NotGiven = NOT_GIVEN,
692709
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
693710
# The extra values given here take precedence over values defined on the client or passed to this method.
694711
extra_headers: Headers | None = None,
@@ -697,7 +714,7 @@ async def list(
697714
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
698715
) -> EvalListResponse:
699716
"""
700-
Get the evaluations config for a project.
717+
Get the evaluations config for a project with optional pagination.
701718
702719
Args:
703720
extra_headers: Send extra headers
@@ -713,7 +730,18 @@ async def list(
713730
return await self._get(
714731
f"/api/projects/{project_id}/evals",
715732
options=make_request_options(
716-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
733+
extra_headers=extra_headers,
734+
extra_query=extra_query,
735+
extra_body=extra_body,
736+
timeout=timeout,
737+
query=await async_maybe_transform(
738+
{
739+
"guardrails_only": guardrails_only,
740+
"limit": limit,
741+
"offset": offset,
742+
},
743+
eval_list_params.EvalListParams,
744+
),
717745
),
718746
cast_to=EvalListResponse,
719747
)

src/codex/types/projects/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from .eval_list_params import EvalListParams as EvalListParams
56
from .access_key_schema import AccessKeySchema as AccessKeySchema
67
from .eval_create_params import EvalCreateParams as EvalCreateParams
78
from .eval_list_response import EvalListResponse as EvalListResponse
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import TypedDict
7+
8+
__all__ = ["EvalListParams"]
9+
10+
11+
class EvalListParams(TypedDict, total=False):
12+
guardrails_only: bool
13+
14+
limit: Optional[int]
15+
16+
offset: int

src/codex/types/projects/eval_list_response.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
from typing import List, Optional
4-
from typing_extensions import Literal, TypeAlias
4+
from typing_extensions import Literal
55

66
from ..._models import BaseModel
77

8-
__all__ = ["EvalListResponse", "EvalListResponseItem"]
8+
__all__ = ["EvalListResponse", "Eval"]
99

1010

11-
class EvalListResponseItem(BaseModel):
11+
class Eval(BaseModel):
1212
criteria: str
1313
"""
1414
The evaluation criteria text that describes what aspect is being evaluated and
@@ -69,4 +69,7 @@ class EvalListResponseItem(BaseModel):
6969
"""Whether the evaluation fails when score is above or below the threshold"""
7070

7171

72-
EvalListResponse: TypeAlias = List[EvalListResponseItem]
72+
class EvalListResponse(BaseModel):
73+
evals: List[Eval]
74+
75+
total_count: int

tests/api_resources/projects/test_evals.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,26 @@ def test_path_params_update_overload_2(self, client: Codex) -> None:
259259
@parametrize
260260
def test_method_list(self, client: Codex) -> None:
261261
eval = client.projects.evals.list(
262-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
262+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
263+
)
264+
assert_matches_type(EvalListResponse, eval, path=["response"])
265+
266+
@pytest.mark.skip()
267+
@parametrize
268+
def test_method_list_with_all_params(self, client: Codex) -> None:
269+
eval = client.projects.evals.list(
270+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
271+
guardrails_only=True,
272+
limit=1,
273+
offset=0,
263274
)
264275
assert_matches_type(EvalListResponse, eval, path=["response"])
265276

266277
@pytest.mark.skip()
267278
@parametrize
268279
def test_raw_response_list(self, client: Codex) -> None:
269280
response = client.projects.evals.with_raw_response.list(
270-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
281+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
271282
)
272283

273284
assert response.is_closed is True
@@ -279,7 +290,7 @@ def test_raw_response_list(self, client: Codex) -> None:
279290
@parametrize
280291
def test_streaming_response_list(self, client: Codex) -> None:
281292
with client.projects.evals.with_streaming_response.list(
282-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
293+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
283294
) as response:
284295
assert not response.is_closed
285296
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -294,7 +305,7 @@ def test_streaming_response_list(self, client: Codex) -> None:
294305
def test_path_params_list(self, client: Codex) -> None:
295306
with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
296307
client.projects.evals.with_raw_response.list(
297-
"",
308+
project_id="",
298309
)
299310

300311
@pytest.mark.skip()
@@ -596,15 +607,26 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCodex) ->
596607
@parametrize
597608
async def test_method_list(self, async_client: AsyncCodex) -> None:
598609
eval = await async_client.projects.evals.list(
599-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
610+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
611+
)
612+
assert_matches_type(EvalListResponse, eval, path=["response"])
613+
614+
@pytest.mark.skip()
615+
@parametrize
616+
async def test_method_list_with_all_params(self, async_client: AsyncCodex) -> None:
617+
eval = await async_client.projects.evals.list(
618+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
619+
guardrails_only=True,
620+
limit=1,
621+
offset=0,
600622
)
601623
assert_matches_type(EvalListResponse, eval, path=["response"])
602624

603625
@pytest.mark.skip()
604626
@parametrize
605627
async def test_raw_response_list(self, async_client: AsyncCodex) -> None:
606628
response = await async_client.projects.evals.with_raw_response.list(
607-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
629+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
608630
)
609631

610632
assert response.is_closed is True
@@ -616,7 +638,7 @@ async def test_raw_response_list(self, async_client: AsyncCodex) -> None:
616638
@parametrize
617639
async def test_streaming_response_list(self, async_client: AsyncCodex) -> None:
618640
async with async_client.projects.evals.with_streaming_response.list(
619-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
641+
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
620642
) as response:
621643
assert not response.is_closed
622644
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -631,7 +653,7 @@ async def test_streaming_response_list(self, async_client: AsyncCodex) -> None:
631653
async def test_path_params_list(self, async_client: AsyncCodex) -> None:
632654
with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
633655
await async_client.projects.evals.with_raw_response.list(
634-
"",
656+
project_id="",
635657
)
636658

637659
@pytest.mark.skip()

0 commit comments

Comments
 (0)