Skip to content

Commit 5a6aa92

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 85bc8eb commit 5a6aa92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+255
-232
lines changed

src/gradient/_utils/_transform.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
lru_cache,
1717
is_mapping,
1818
is_iterable,
19+
is_sequence,
1920
)
2021
from .._files import is_base64_file_input
2122
from ._typing import (
@@ -24,6 +25,7 @@
2425
extract_type_arg,
2526
is_iterable_type,
2627
is_required_type,
28+
is_sequence_type,
2729
is_annotated_type,
2830
strip_annotated_type,
2931
)
@@ -184,6 +186,8 @@ def _transform_recursive(
184186
(is_list_type(stripped_type) and is_list(data))
185187
# Iterable[T]
186188
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
189+
# Sequence[T]
190+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
187191
):
188192
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
189193
# intended as an iterable, so we don't transform it.
@@ -346,6 +350,8 @@ async def _async_transform_recursive(
346350
(is_list_type(stripped_type) and is_list(data))
347351
# Iterable[T]
348352
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
353+
# Sequence[T]
354+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
349355
):
350356
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
351357
# intended as an iterable, so we don't transform it.

src/gradient/resources/agents/agents.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import annotations
44

5-
from typing import List
6-
75
import httpx
86

97
from .routes import (
@@ -22,7 +20,7 @@
2220
agent_update_params,
2321
agent_update_status_params,
2422
)
25-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
23+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
2624
from ..._utils import maybe_transform, async_maybe_transform
2725
from .api_keys import (
2826
APIKeysResource,
@@ -183,13 +181,13 @@ def create(
183181
anthropic_key_uuid: str | NotGiven = NOT_GIVEN,
184182
description: str | NotGiven = NOT_GIVEN,
185183
instruction: str | NotGiven = NOT_GIVEN,
186-
knowledge_base_uuid: List[str] | NotGiven = NOT_GIVEN,
184+
knowledge_base_uuid: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
187185
model_uuid: str | NotGiven = NOT_GIVEN,
188186
name: str | NotGiven = NOT_GIVEN,
189187
openai_key_uuid: str | NotGiven = NOT_GIVEN,
190188
project_id: str | NotGiven = NOT_GIVEN,
191189
region: str | NotGiven = NOT_GIVEN,
192-
tags: List[str] | NotGiven = NOT_GIVEN,
190+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
193191
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
194192
# The extra values given here take precedence over values defined on the client or passed to this method.
195193
extra_headers: Headers | None = None,
@@ -313,7 +311,7 @@ def update(
313311
project_id: str | NotGiven = NOT_GIVEN,
314312
provide_citations: bool | NotGiven = NOT_GIVEN,
315313
retrieval_method: APIRetrievalMethod | NotGiven = NOT_GIVEN,
316-
tags: List[str] | NotGiven = NOT_GIVEN,
314+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
317315
temperature: float | NotGiven = NOT_GIVEN,
318316
top_p: float | NotGiven = NOT_GIVEN,
319317
body_uuid: str | NotGiven = NOT_GIVEN,
@@ -626,13 +624,13 @@ async def create(
626624
anthropic_key_uuid: str | NotGiven = NOT_GIVEN,
627625
description: str | NotGiven = NOT_GIVEN,
628626
instruction: str | NotGiven = NOT_GIVEN,
629-
knowledge_base_uuid: List[str] | NotGiven = NOT_GIVEN,
627+
knowledge_base_uuid: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
630628
model_uuid: str | NotGiven = NOT_GIVEN,
631629
name: str | NotGiven = NOT_GIVEN,
632630
openai_key_uuid: str | NotGiven = NOT_GIVEN,
633631
project_id: str | NotGiven = NOT_GIVEN,
634632
region: str | NotGiven = NOT_GIVEN,
635-
tags: List[str] | NotGiven = NOT_GIVEN,
633+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
636634
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
637635
# The extra values given here take precedence over values defined on the client or passed to this method.
638636
extra_headers: Headers | None = None,
@@ -756,7 +754,7 @@ async def update(
756754
project_id: str | NotGiven = NOT_GIVEN,
757755
provide_citations: bool | NotGiven = NOT_GIVEN,
758756
retrieval_method: APIRetrievalMethod | NotGiven = NOT_GIVEN,
759-
tags: List[str] | NotGiven = NOT_GIVEN,
757+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
760758
temperature: float | NotGiven = NOT_GIVEN,
761759
top_p: float | NotGiven = NOT_GIVEN,
762760
body_uuid: str | NotGiven = NOT_GIVEN,

src/gradient/resources/agents/chat/completions.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List, Union, Iterable, Optional
5+
from typing import Dict, Union, Iterable, Optional
66
from typing_extensions import Literal, overload
77

88
import httpx
99

10-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1111
from ...._utils import required_args, maybe_transform, async_maybe_transform
1212
from ...._compat import cached_property
1313
from ...._resource import SyncAPIResource, AsyncAPIResource
@@ -60,7 +60,7 @@ def create(
6060
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
6161
n: Optional[int] | NotGiven = NOT_GIVEN,
6262
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
63-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
63+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
6464
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
6565
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
6666
temperature: Optional[float] | NotGiven = NOT_GIVEN,
@@ -189,8 +189,8 @@ def create(
189189
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
190190
n: Optional[int] | NotGiven = NOT_GIVEN,
191191
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
192-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
193-
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
192+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
193+
stream_options: Optional[completion_create_params.StreamOptions] | NotGiven = NOT_GIVEN,
194194
temperature: Optional[float] | NotGiven = NOT_GIVEN,
195195
tool_choice: completion_create_params.ToolChoice | NotGiven = NOT_GIVEN,
196196
tools: Iterable[completion_create_params.Tool] | NotGiven = NOT_GIVEN,
@@ -317,8 +317,8 @@ def create(
317317
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
318318
n: Optional[int] | NotGiven = NOT_GIVEN,
319319
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
320-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
321-
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
320+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
321+
stream_options: Optional[completion_create_params.StreamOptions] | NotGiven = NOT_GIVEN,
322322
temperature: Optional[float] | NotGiven = NOT_GIVEN,
323323
tool_choice: completion_create_params.ToolChoice | NotGiven = NOT_GIVEN,
324324
tools: Iterable[completion_create_params.Tool] | NotGiven = NOT_GIVEN,
@@ -447,7 +447,7 @@ def create(
447447
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
448448
n: Optional[int] | NotGiven = NOT_GIVEN,
449449
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
450-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
450+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
451451
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
452452
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
453453
temperature: Optional[float] | NotGiven = NOT_GIVEN,
@@ -549,7 +549,7 @@ async def create(
549549
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
550550
n: Optional[int] | NotGiven = NOT_GIVEN,
551551
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
552-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
552+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
553553
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
554554
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
555555
temperature: Optional[float] | NotGiven = NOT_GIVEN,
@@ -678,8 +678,8 @@ async def create(
678678
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
679679
n: Optional[int] | NotGiven = NOT_GIVEN,
680680
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
681-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
682-
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
681+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
682+
stream_options: Optional[completion_create_params.StreamOptions] | NotGiven = NOT_GIVEN,
683683
temperature: Optional[float] | NotGiven = NOT_GIVEN,
684684
tool_choice: completion_create_params.ToolChoice | NotGiven = NOT_GIVEN,
685685
tools: Iterable[completion_create_params.Tool] | NotGiven = NOT_GIVEN,
@@ -806,8 +806,8 @@ async def create(
806806
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
807807
n: Optional[int] | NotGiven = NOT_GIVEN,
808808
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
809-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
810-
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
809+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
810+
stream_options: Optional[completion_create_params.StreamOptions] | NotGiven = NOT_GIVEN,
811811
temperature: Optional[float] | NotGiven = NOT_GIVEN,
812812
tool_choice: completion_create_params.ToolChoice | NotGiven = NOT_GIVEN,
813813
tools: Iterable[completion_create_params.Tool] | NotGiven = NOT_GIVEN,
@@ -933,7 +933,7 @@ async def create(
933933
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
934934
n: Optional[int] | NotGiven = NOT_GIVEN,
935935
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
936-
stop: Union[Optional[str], List[str], None] | NotGiven = NOT_GIVEN,
936+
stop: Union[Optional[str], SequenceNotStr[str], None] | NotGiven = NOT_GIVEN,
937937
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
938938
stream_options: (Optional[completion_create_params.StreamOptions] | NotGiven) = NOT_GIVEN,
939939
temperature: Optional[float] | NotGiven = NOT_GIVEN,

src/gradient/resources/agents/evaluation_metrics/workspaces/agents.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
from __future__ import annotations
44

5-
from typing import List
6-
75
import httpx
86

9-
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
7+
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
108
from ....._utils import maybe_transform, async_maybe_transform
119
from ....._compat import cached_property
1210
from ....._resource import SyncAPIResource, AsyncAPIResource
@@ -104,7 +102,7 @@ def move(
104102
self,
105103
path_workspace_uuid: str,
106104
*,
107-
agent_uuids: List[str] | NotGiven = NOT_GIVEN,
105+
agent_uuids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
108106
body_workspace_uuid: str | NotGiven = NOT_GIVEN,
109107
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
110108
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -232,7 +230,7 @@ async def move(
232230
self,
233231
path_workspace_uuid: str,
234232
*,
235-
agent_uuids: List[str] | NotGiven = NOT_GIVEN,
233+
agent_uuids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
236234
body_workspace_uuid: str | NotGiven = NOT_GIVEN,
237235
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
238236
# The extra values given here take precedence over values defined on the client or passed to this method.

src/gradient/resources/agents/evaluation_metrics/workspaces/workspaces.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import annotations
44

5-
from typing import List
6-
75
import httpx
86

97
from .agents import (
@@ -14,7 +12,7 @@
1412
AgentsResourceWithStreamingResponse,
1513
AsyncAgentsResourceWithStreamingResponse,
1614
)
17-
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
15+
from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1816
from ....._utils import maybe_transform, async_maybe_transform
1917
from ....._compat import cached_property
2018
from ....._resource import SyncAPIResource, AsyncAPIResource
@@ -65,7 +63,7 @@ def with_streaming_response(self) -> WorkspacesResourceWithStreamingResponse:
6563
def create(
6664
self,
6765
*,
68-
agent_uuids: List[str] | NotGiven = NOT_GIVEN,
66+
agent_uuids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
6967
description: str | NotGiven = NOT_GIVEN,
7068
name: str | NotGiven = NOT_GIVEN,
7169
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -327,7 +325,7 @@ def with_streaming_response(self) -> AsyncWorkspacesResourceWithStreamingRespons
327325
async def create(
328326
self,
329327
*,
330-
agent_uuids: List[str] | NotGiven = NOT_GIVEN,
328+
agent_uuids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
331329
description: str | NotGiven = NOT_GIVEN,
332330
name: str | NotGiven = NOT_GIVEN,
333331
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

src/gradient/resources/agents/evaluation_runs.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
from __future__ import annotations
44

5-
from typing import List
6-
75
import httpx
86

9-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
7+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
108
from ..._utils import maybe_transform, async_maybe_transform
119
from ..._compat import cached_property
1210
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -49,7 +47,7 @@ def with_streaming_response(self) -> EvaluationRunsResourceWithStreamingResponse
4947
def create(
5048
self,
5149
*,
52-
agent_uuids: List[str] | NotGiven = NOT_GIVEN,
50+
agent_uuids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
5351
run_name: str | NotGiven = NOT_GIVEN,
5452
test_case_uuid: str | NotGiven = NOT_GIVEN,
5553
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -251,7 +249,7 @@ def with_streaming_response(self) -> AsyncEvaluationRunsResourceWithStreamingRes
251249
async def create(
252250
self,
253251
*,
254-
agent_uuids: List[str] | NotGiven = NOT_GIVEN,
252+
agent_uuids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
255253
run_name: str | NotGiven = NOT_GIVEN,
256254
test_case_uuid: str | NotGiven = NOT_GIVEN,
257255
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

src/gradient/resources/agents/evaluation_test_cases.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
from __future__ import annotations
44

5-
from typing import List
6-
75
import httpx
86

9-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
7+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
108
from ..._utils import maybe_transform, async_maybe_transform
119
from ..._compat import cached_property
1210
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -60,7 +58,7 @@ def create(
6058
*,
6159
dataset_uuid: str | NotGiven = NOT_GIVEN,
6260
description: str | NotGiven = NOT_GIVEN,
63-
metrics: List[str] | NotGiven = NOT_GIVEN,
61+
metrics: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
6462
name: str | NotGiven = NOT_GIVEN,
6563
star_metric: APIStarMetricParam | NotGiven = NOT_GIVEN,
6664
workspace_uuid: str | NotGiven = NOT_GIVEN,
@@ -322,7 +320,7 @@ async def create(
322320
*,
323321
dataset_uuid: str | NotGiven = NOT_GIVEN,
324322
description: str | NotGiven = NOT_GIVEN,
325-
metrics: List[str] | NotGiven = NOT_GIVEN,
323+
metrics: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
326324
name: str | NotGiven = NOT_GIVEN,
327325
star_metric: APIStarMetricParam | NotGiven = NOT_GIVEN,
328326
workspace_uuid: str | NotGiven = NOT_GIVEN,

0 commit comments

Comments
 (0)