Skip to content

Commit 20a3231

Browse files
feat(api): add chunking mode to enrichment
1 parent 233ae5c commit 20a3231

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 5
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-7eb7a36b7ad1dc6d3a183088ede90dfbef328d230641e38de953ccc8dd81d137.yml
3-
openapi_spec_hash: 9ef218f1e50c15715e174c95cb6d153c
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-46de7b353c33e2b6c139e564caeec9e0462ad714121690f65167a7943e325000.yml
3+
openapi_spec_hash: 6527287f9709a8741c9cc5b4181d7bb1
44
config_hash: 9040e7359f066240ad536041fb2c5185

src/isaacus/resources/enrichments.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def create(
4949
*,
5050
model: Literal["kanon-2-enricher"],
5151
texts: Union[SequenceNotStr[str], str],
52-
overflow_strategy: Optional[Literal["auto", "drop_end"]] | Omit = omit,
52+
overflow_strategy: Optional[Literal["auto", "drop_end", "chunk"]] | Omit = omit,
5353
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5454
# The extra values given here take precedence over values defined on the client or passed to this method.
5555
extra_headers: Headers | None = None,
@@ -71,9 +71,15 @@ def create(
7171
7272
overflow_strategy: The strategy for handling content exceeding the model's maximum input length.
7373
74-
`auto` currently behaves the same as `drop_end`, dropping excess tokens from the
75-
end of input. In the future, `auto` may implement more sophisticated strategies
76-
such as chunking and context-aware stitching.
74+
`auto`, which is the default and recommended setting, currently behaves the same
75+
as `chunk`, which intelligently breaks the input up into smaller chunks and then
76+
stitches the results back together into a single prediction. In the future
77+
`auto` may implement even more sophisticated strategies for handling long
78+
contexts such as leveraging chunk overlap and/or a specialized stitching model.
79+
80+
`chunk` breaks the input up into smaller chunks that fit within the model's
81+
context window and then intelligently merges the results into a single
82+
prediction at the cost of a minor accuracy drop.
7783
7884
`drop_end` drops tokens from the end of input exceeding the model's maximum
7985
input length.
@@ -131,7 +137,7 @@ async def create(
131137
*,
132138
model: Literal["kanon-2-enricher"],
133139
texts: Union[SequenceNotStr[str], str],
134-
overflow_strategy: Optional[Literal["auto", "drop_end"]] | Omit = omit,
140+
overflow_strategy: Optional[Literal["auto", "drop_end", "chunk"]] | Omit = omit,
135141
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
136142
# The extra values given here take precedence over values defined on the client or passed to this method.
137143
extra_headers: Headers | None = None,
@@ -153,9 +159,15 @@ async def create(
153159
154160
overflow_strategy: The strategy for handling content exceeding the model's maximum input length.
155161
156-
`auto` currently behaves the same as `drop_end`, dropping excess tokens from the
157-
end of input. In the future, `auto` may implement more sophisticated strategies
158-
such as chunking and context-aware stitching.
162+
`auto`, which is the default and recommended setting, currently behaves the same
163+
as `chunk`, which intelligently breaks the input up into smaller chunks and then
164+
stitches the results back together into a single prediction. In the future
165+
`auto` may implement even more sophisticated strategies for handling long
166+
contexts such as leveraging chunk overlap and/or a specialized stitching model.
167+
168+
`chunk` breaks the input up into smaller chunks that fit within the model's
169+
context window and then intelligently merges the results into a single
170+
prediction at the cost of a minor accuracy drop.
159171
160172
`drop_end` drops tokens from the end of input exceeding the model's maximum
161173
input length.

src/isaacus/types/enrichment_create_params.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ class EnrichmentCreateParams(TypedDict, total=False):
2525
No more than 8 texts can be enriched in a single request.
2626
"""
2727

28-
overflow_strategy: Optional[Literal["auto", "drop_end"]]
28+
overflow_strategy: Optional[Literal["auto", "drop_end", "chunk"]]
2929
"""The strategy for handling content exceeding the model's maximum input length.
3030
31-
`auto` currently behaves the same as `drop_end`, dropping excess tokens from the
32-
end of input. In the future, `auto` may implement more sophisticated strategies
33-
such as chunking and context-aware stitching.
31+
`auto`, which is the default and recommended setting, currently behaves the same
32+
as `chunk`, which intelligently breaks the input up into smaller chunks and then
33+
stitches the results back together into a single prediction. In the future
34+
`auto` may implement even more sophisticated strategies for handling long
35+
contexts such as leveraging chunk overlap and/or a specialized stitching model.
36+
37+
`chunk` breaks the input up into smaller chunks that fit within the model's
38+
context window and then intelligently merges the results into a single
39+
prediction at the cost of a minor accuracy drop.
3440
3541
`drop_end` drops tokens from the end of input exceeding the model's maximum
3642
input length.

0 commit comments

Comments
 (0)