Skip to content

Commit d2733a9

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

File tree

7 files changed

+30
-18
lines changed

7 files changed

+30
-18
lines changed

src/isaacus/_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/isaacus/resources/classifications/universal.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 List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal
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 maybe_transform, async_maybe_transform
1212
from ..._compat import cached_property
1313
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -49,7 +49,7 @@ def create(
4949
*,
5050
model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
5151
query: str,
52-
texts: List[str],
52+
texts: SequenceNotStr[str],
5353
chunking_options: Optional[universal_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
5454
is_iql: bool | NotGiven = NOT_GIVEN,
5555
scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,
@@ -150,7 +150,7 @@ async def create(
150150
*,
151151
model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
152152
query: str,
153-
texts: List[str],
153+
texts: SequenceNotStr[str],
154154
chunking_options: Optional[universal_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
155155
is_iql: bool | NotGiven = NOT_GIVEN,
156156
scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,

src/isaacus/resources/extractions/qa.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 List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal
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 maybe_transform, async_maybe_transform
1212
from ..._compat import cached_property
1313
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -49,7 +49,7 @@ def create(
4949
*,
5050
model: Literal["kanon-answer-extractor", "kanon-answer-extractor-mini"],
5151
query: str,
52-
texts: List[str],
52+
texts: SequenceNotStr[str],
5353
chunking_options: Optional[qa_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
5454
ignore_inextractability: bool | NotGiven = NOT_GIVEN,
5555
top_k: int | NotGiven = NOT_GIVEN,
@@ -148,7 +148,7 @@ async def create(
148148
*,
149149
model: Literal["kanon-answer-extractor", "kanon-answer-extractor-mini"],
150150
query: str,
151-
texts: List[str],
151+
texts: SequenceNotStr[str],
152152
chunking_options: Optional[qa_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
153153
ignore_inextractability: bool | NotGiven = NOT_GIVEN,
154154
top_k: int | NotGiven = NOT_GIVEN,

src/isaacus/resources/rerankings.py

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

33
from __future__ import annotations
44

5-
from typing import List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal
77

88
import httpx
99

1010
from ..types import reranking_create_params
11-
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1212
from .._utils import maybe_transform, async_maybe_transform
1313
from .._compat import cached_property
1414
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -49,7 +49,7 @@ def create(
4949
*,
5050
model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
5151
query: str,
52-
texts: List[str],
52+
texts: SequenceNotStr[str],
5353
chunking_options: Optional[reranking_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
5454
is_iql: bool | NotGiven = NOT_GIVEN,
5555
scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,
@@ -160,7 +160,7 @@ async def create(
160160
*,
161161
model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
162162
query: str,
163-
texts: List[str],
163+
texts: SequenceNotStr[str],
164164
chunking_options: Optional[reranking_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
165165
is_iql: bool | NotGiven = NOT_GIVEN,
166166
scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,

src/isaacus/types/classifications/universal_create_params.py

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

33
from __future__ import annotations
44

5-
from typing import List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8+
from ..._types import SequenceNotStr
9+
810
__all__ = ["UniversalCreateParams", "ChunkingOptions"]
911

1012

@@ -26,7 +28,7 @@ class UniversalCreateParams(TypedDict, total=False):
2628
the maximum input length of the universal classifier.
2729
"""
2830

29-
texts: Required[List[str]]
31+
texts: Required[SequenceNotStr[str]]
3032
"""The texts to classify.
3133
3234
Each text must contain at least one non-whitespace character.

src/isaacus/types/extractions/qa_create_params.py

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

33
from __future__ import annotations
44

5-
from typing import List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8+
from ..._types import SequenceNotStr
9+
810
__all__ = ["QaCreateParams", "ChunkingOptions"]
911

1012

@@ -24,7 +26,7 @@ class QaCreateParams(TypedDict, total=False):
2426
long that it exceeds the maximum input length of the model.
2527
"""
2628

27-
texts: Required[List[str]]
29+
texts: Required[SequenceNotStr[str]]
2830
"""The texts to search for the answer in and extract the answer from.
2931
3032
There must be at least one text.

src/isaacus/types/reranking_create_params.py

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

33
from __future__ import annotations
44

5-
from typing import List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8+
from .._types import SequenceNotStr
9+
810
__all__ = ["RerankingCreateParams", "ChunkingOptions"]
911

1012

@@ -24,7 +26,7 @@ class RerankingCreateParams(TypedDict, total=False):
2426
maximum input length of the reranker.
2527
"""
2628

27-
texts: Required[List[str]]
29+
texts: Required[SequenceNotStr[str]]
2830
"""The texts to rerank.
2931
3032
There must be at least one text.

0 commit comments

Comments
 (0)