@@ -170,6 +170,48 @@ def __init__(
170170 super ().__init__ (kwargs )
171171
172172
173+ class ChunkingSettings (AttrDict [Any ]):
174+ """
175+ :arg strategy: (required) The chunking strategy: `sentence` or `word`.
176+ Defaults to `sentence` if omitted.
177+ :arg max_chunk_size: (required) The maximum size of a chunk in words.
178+ This value cannot be higher than `300` or lower than `20` (for
179+ `sentence` strategy) or `10` (for `word` strategy). Defaults to
180+ `250` if omitted.
181+ :arg overlap: The number of overlapping words for chunks. It is
182+ applicable only to a `word` chunking strategy. This value cannot
183+ be higher than half the `max_chunk_size` value. Defaults to `100`
184+ if omitted.
185+ :arg sentence_overlap: The number of overlapping sentences for chunks.
186+ It is applicable only for a `sentence` chunking strategy. It can
187+ be either `1` or `0`. Defaults to `1` if omitted.
188+ """
189+
190+ strategy : Union [str , DefaultType ]
191+ max_chunk_size : Union [int , DefaultType ]
192+ overlap : Union [int , DefaultType ]
193+ sentence_overlap : Union [int , DefaultType ]
194+
195+ def __init__ (
196+ self ,
197+ * ,
198+ strategy : Union [str , DefaultType ] = DEFAULT ,
199+ max_chunk_size : Union [int , DefaultType ] = DEFAULT ,
200+ overlap : Union [int , DefaultType ] = DEFAULT ,
201+ sentence_overlap : Union [int , DefaultType ] = DEFAULT ,
202+ ** kwargs : Any ,
203+ ):
204+ if strategy is not DEFAULT :
205+ kwargs ["strategy" ] = strategy
206+ if max_chunk_size is not DEFAULT :
207+ kwargs ["max_chunk_size" ] = max_chunk_size
208+ if overlap is not DEFAULT :
209+ kwargs ["overlap" ] = overlap
210+ if sentence_overlap is not DEFAULT :
211+ kwargs ["sentence_overlap" ] = sentence_overlap
212+ super ().__init__ (kwargs )
213+
214+
173215class ClassificationInferenceOptions (AttrDict [Any ]):
174216 """
175217 :arg num_top_classes: Specifies the number of top class predictions to
@@ -1617,11 +1659,7 @@ class InnerHits(AttrDict[Any]):
16171659 DefaultType ,
16181660 ]
16191661 seq_no_primary_term : Union [bool , DefaultType ]
1620- fields : Union [
1621- Union [str , InstrumentedField ],
1622- Sequence [Union [str , InstrumentedField ]],
1623- DefaultType ,
1624- ]
1662+ fields : Union [Sequence [Union [str , InstrumentedField ]], DefaultType ]
16251663 sort : Union [
16261664 Union [Union [str , InstrumentedField ], "SortOptions" ],
16271665 Sequence [Union [Union [str , InstrumentedField ], "SortOptions" ]],
@@ -1656,11 +1694,7 @@ def __init__(
16561694 DefaultType ,
16571695 ] = DEFAULT ,
16581696 seq_no_primary_term : Union [bool , DefaultType ] = DEFAULT ,
1659- fields : Union [
1660- Union [str , InstrumentedField ],
1661- Sequence [Union [str , InstrumentedField ]],
1662- DefaultType ,
1663- ] = DEFAULT ,
1697+ fields : Union [Sequence [Union [str , InstrumentedField ]], DefaultType ] = DEFAULT ,
16641698 sort : Union [
16651699 Union [Union [str , InstrumentedField ], "SortOptions" ],
16661700 Sequence [Union [Union [str , InstrumentedField ], "SortOptions" ]],
0 commit comments