Skip to content

Commit 2c0cdd1

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 54fd160 commit 2c0cdd1

40 files changed

+207
-169
lines changed

src/llama_stack_client/_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/llama_stack_client/resources/agents/session.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, NoneType, NotGiven
7+
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, SequenceNotStr
108
from ..._utils import maybe_transform, async_maybe_transform
119
from ..._compat import cached_property
1210
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -87,7 +85,7 @@ def retrieve(
8785
session_id: str,
8886
*,
8987
agent_id: str,
90-
turn_ids: List[str] | NotGiven = NOT_GIVEN,
88+
turn_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
9189
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
9290
# The extra values given here take precedence over values defined on the client or passed to this method.
9391
extra_headers: Headers | None = None,
@@ -274,7 +272,7 @@ async def retrieve(
274272
session_id: str,
275273
*,
276274
agent_id: str,
277-
turn_ids: List[str] | NotGiven = NOT_GIVEN,
275+
turn_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
278276
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
279277
# The extra values given here take precedence over values defined on the client or passed to this method.
280278
extra_headers: Headers | None = None,

src/llama_stack_client/resources/agents/turn.py

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

33
from __future__ import annotations
44

5-
from typing import List, Iterable
5+
from typing import Iterable
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
@@ -57,7 +57,7 @@ def create(
5757
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
5858
stream: Literal[False] | NotGiven = NOT_GIVEN,
5959
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
60-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
60+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
6161
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6262
# The extra values given here take precedence over values defined on the client or passed to this method.
6363
extra_headers: Headers | None = None,
@@ -102,7 +102,7 @@ def create(
102102
stream: Literal[True],
103103
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
104104
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
105-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
105+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
106106
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
107107
# The extra values given here take precedence over values defined on the client or passed to this method.
108108
extra_headers: Headers | None = None,
@@ -147,7 +147,7 @@ def create(
147147
stream: bool,
148148
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
149149
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
150-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
150+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
151151
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
152152
# The extra values given here take precedence over values defined on the client or passed to this method.
153153
extra_headers: Headers | None = None,
@@ -192,7 +192,7 @@ def create(
192192
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
193193
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
194194
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
195-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
195+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
196196
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
197197
# The extra values given here take precedence over values defined on the client or passed to this method.
198198
extra_headers: Headers | None = None,
@@ -451,7 +451,7 @@ async def create(
451451
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
452452
stream: Literal[False] | NotGiven = NOT_GIVEN,
453453
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
454-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
454+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
455455
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
456456
# The extra values given here take precedence over values defined on the client or passed to this method.
457457
extra_headers: Headers | None = None,
@@ -496,7 +496,7 @@ async def create(
496496
stream: Literal[True],
497497
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
498498
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
499-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
499+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
500500
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
501501
# The extra values given here take precedence over values defined on the client or passed to this method.
502502
extra_headers: Headers | None = None,
@@ -541,7 +541,7 @@ async def create(
541541
stream: bool,
542542
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
543543
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
544-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
544+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
545545
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
546546
# The extra values given here take precedence over values defined on the client or passed to this method.
547547
extra_headers: Headers | None = None,
@@ -586,7 +586,7 @@ async def create(
586586
documents: Iterable[turn_create_params.Document] | NotGiven = NOT_GIVEN,
587587
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
588588
tool_config: turn_create_params.ToolConfig | NotGiven = NOT_GIVEN,
589-
toolgroups: List[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
589+
toolgroups: SequenceNotStr[turn_create_params.Toolgroup] | NotGiven = NOT_GIVEN,
590590
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
591591
# The extra values given here take precedence over values defined on the client or passed to this method.
592592
extra_headers: Headers | None = None,

src/llama_stack_client/resources/benchmarks.py

Lines changed: 4 additions & 4 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, Type, Union, Iterable, cast
5+
from typing import Dict, Type, Union, Iterable, cast
66

77
import httpx
88

99
from ..types import benchmark_register_params
10-
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
10+
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, SequenceNotStr
1111
from .._utils import maybe_transform, async_maybe_transform
1212
from .._compat import cached_property
1313
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -106,7 +106,7 @@ def register(
106106
*,
107107
benchmark_id: str,
108108
dataset_id: str,
109-
scoring_functions: List[str],
109+
scoring_functions: SequenceNotStr[str],
110110
metadata: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
111111
provider_benchmark_id: str | NotGiven = NOT_GIVEN,
112112
provider_id: str | NotGiven = NOT_GIVEN,
@@ -243,7 +243,7 @@ async def register(
243243
*,
244244
benchmark_id: str,
245245
dataset_id: str,
246-
scoring_functions: List[str],
246+
scoring_functions: SequenceNotStr[str],
247247
metadata: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
248248
provider_benchmark_id: str | NotGiven = NOT_GIVEN,
249249
provider_id: str | NotGiven = NOT_GIVEN,

src/llama_stack_client/resources/chat/completions.py

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

33
from __future__ import annotations
44

5-
from typing import Any, Dict, List, Union, Iterable, cast
5+
from typing import Any, Dict, Union, Iterable, cast
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
@@ -68,7 +68,7 @@ def create(
6868
presence_penalty: float | NotGiven = NOT_GIVEN,
6969
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
7070
seed: int | NotGiven = NOT_GIVEN,
71-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
71+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
7272
stream: Literal[False] | NotGiven = NOT_GIVEN,
7373
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
7474
temperature: float | NotGiven = NOT_GIVEN,
@@ -167,7 +167,7 @@ def create(
167167
presence_penalty: float | NotGiven = NOT_GIVEN,
168168
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
169169
seed: int | NotGiven = NOT_GIVEN,
170-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
170+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
171171
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
172172
temperature: float | NotGiven = NOT_GIVEN,
173173
tool_choice: Union[str, Dict[str, Union[bool, float, str, Iterable[object], object, None]]]
@@ -265,7 +265,7 @@ def create(
265265
presence_penalty: float | NotGiven = NOT_GIVEN,
266266
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
267267
seed: int | NotGiven = NOT_GIVEN,
268-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
268+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
269269
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
270270
temperature: float | NotGiven = NOT_GIVEN,
271271
tool_choice: Union[str, Dict[str, Union[bool, float, str, Iterable[object], object, None]]]
@@ -362,7 +362,7 @@ def create(
362362
presence_penalty: float | NotGiven = NOT_GIVEN,
363363
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
364364
seed: int | NotGiven = NOT_GIVEN,
365-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
365+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
366366
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
367367
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
368368
temperature: float | NotGiven = NOT_GIVEN,
@@ -549,7 +549,7 @@ async def create(
549549
presence_penalty: float | NotGiven = NOT_GIVEN,
550550
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
551551
seed: int | NotGiven = NOT_GIVEN,
552-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
552+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
553553
stream: Literal[False] | NotGiven = NOT_GIVEN,
554554
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
555555
temperature: float | NotGiven = NOT_GIVEN,
@@ -648,7 +648,7 @@ async def create(
648648
presence_penalty: float | NotGiven = NOT_GIVEN,
649649
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
650650
seed: int | NotGiven = NOT_GIVEN,
651-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
651+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
652652
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
653653
temperature: float | NotGiven = NOT_GIVEN,
654654
tool_choice: Union[str, Dict[str, Union[bool, float, str, Iterable[object], object, None]]]
@@ -746,7 +746,7 @@ async def create(
746746
presence_penalty: float | NotGiven = NOT_GIVEN,
747747
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
748748
seed: int | NotGiven = NOT_GIVEN,
749-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
749+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
750750
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
751751
temperature: float | NotGiven = NOT_GIVEN,
752752
tool_choice: Union[str, Dict[str, Union[bool, float, str, Iterable[object], object, None]]]
@@ -843,7 +843,7 @@ async def create(
843843
presence_penalty: float | NotGiven = NOT_GIVEN,
844844
response_format: completion_create_params.ResponseFormat | NotGiven = NOT_GIVEN,
845845
seed: int | NotGiven = NOT_GIVEN,
846-
stop: Union[str, List[str]] | NotGiven = NOT_GIVEN,
846+
stop: Union[str, SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
847847
stream: Literal[False] | Literal[True] | NotGiven = NOT_GIVEN,
848848
stream_options: Dict[str, Union[bool, float, str, Iterable[object], object, None]] | NotGiven = NOT_GIVEN,
849849
temperature: float | NotGiven = NOT_GIVEN,

0 commit comments

Comments
 (0)