@@ -142,6 +142,48 @@ def __init__(
142142 super ().__init__ (kwargs )
143143
144144
145+ class ChunkingSettings (AttrDict [Any ]):
146+ """
147+ :arg strategy: (required) The chunking strategy: `sentence` or `word`.
148+ Defaults to `sentence` if omitted.
149+ :arg max_chunk_size: (required) The maximum size of a chunk in words.
150+ This value cannot be higher than `300` or lower than `20` (for
151+ `sentence` strategy) or `10` (for `word` strategy). Defaults to
152+ `250` if omitted.
153+ :arg overlap: The number of overlapping words for chunks. It is
154+ applicable only to a `word` chunking strategy. This value cannot
155+ be higher than half the `max_chunk_size` value. Defaults to `100`
156+ if omitted.
157+ :arg sentence_overlap: The number of overlapping sentences for chunks.
158+ It is applicable only for a `sentence` chunking strategy. It can
159+ be either `1` or `0`. Defaults to `1` if omitted.
160+ """
161+
162+ strategy : Union [str , DefaultType ]
163+ max_chunk_size : Union [int , DefaultType ]
164+ overlap : Union [int , DefaultType ]
165+ sentence_overlap : Union [int , DefaultType ]
166+
167+ def __init__ (
168+ self ,
169+ * ,
170+ strategy : Union [str , DefaultType ] = DEFAULT ,
171+ max_chunk_size : Union [int , DefaultType ] = DEFAULT ,
172+ overlap : Union [int , DefaultType ] = DEFAULT ,
173+ sentence_overlap : Union [int , DefaultType ] = DEFAULT ,
174+ ** kwargs : Any ,
175+ ):
176+ if strategy is not DEFAULT :
177+ kwargs ["strategy" ] = strategy
178+ if max_chunk_size is not DEFAULT :
179+ kwargs ["max_chunk_size" ] = max_chunk_size
180+ if overlap is not DEFAULT :
181+ kwargs ["overlap" ] = overlap
182+ if sentence_overlap is not DEFAULT :
183+ kwargs ["sentence_overlap" ] = sentence_overlap
184+ super ().__init__ (kwargs )
185+
186+
145187class ClassificationInferenceOptions (AttrDict [Any ]):
146188 """
147189 :arg num_top_classes: Specifies the number of top class predictions to
@@ -1561,11 +1603,7 @@ class InnerHits(AttrDict[Any]):
15611603 DefaultType ,
15621604 ]
15631605 seq_no_primary_term : Union [bool , DefaultType ]
1564- fields : Union [
1565- Union [str , InstrumentedField ],
1566- Sequence [Union [str , InstrumentedField ]],
1567- DefaultType ,
1568- ]
1606+ fields : Union [Sequence [Union [str , InstrumentedField ]], DefaultType ]
15691607 sort : Union [
15701608 Union [Union [str , InstrumentedField ], "SortOptions" ],
15711609 Sequence [Union [Union [str , InstrumentedField ], "SortOptions" ]],
@@ -1600,11 +1638,7 @@ def __init__(
16001638 DefaultType ,
16011639 ] = DEFAULT ,
16021640 seq_no_primary_term : Union [bool , DefaultType ] = DEFAULT ,
1603- fields : Union [
1604- Union [str , InstrumentedField ],
1605- Sequence [Union [str , InstrumentedField ]],
1606- DefaultType ,
1607- ] = DEFAULT ,
1641+ fields : Union [Sequence [Union [str , InstrumentedField ]], DefaultType ] = DEFAULT ,
16081642 sort : Union [
16091643 Union [Union [str , InstrumentedField ], "SortOptions" ],
16101644 Sequence [Union [Union [str , InstrumentedField ], "SortOptions" ]],
0 commit comments