6262 */
6363@ JsonpDeserializable
6464public class ChunkRescorerChunkingSettings implements JsonpSerializable {
65+ private final int maxChunkSize ;
66+
6567 @ Nullable
66- private final String strategy ;
68+ private final Integer overlap ;
69+
70+ @ Nullable
71+ private final Integer sentenceOverlap ;
6772
6873 @ Nullable
6974 private final String separatorGroup ;
7075
7176 private final List <String > separators ;
7277
73- private final int maxChunkSize ;
74-
75- @ Nullable
76- private final Integer overlap ;
77-
7878 @ Nullable
79- private final Integer sentenceOverlap ;
79+ private final String strategy ;
8080
8181 // ---------------------------------------------------------------------------------------------
8282
8383 private ChunkRescorerChunkingSettings (Builder builder ) {
8484
85- this .strategy = builder .strategy ;
86- this .separatorGroup = builder .separatorGroup ;
87- this .separators = ApiTypeHelper .unmodifiable (builder .separators );
8885 this .maxChunkSize = ApiTypeHelper .requireNonNull (builder .maxChunkSize , this , "maxChunkSize" , 0 );
8986 this .overlap = builder .overlap ;
9087 this .sentenceOverlap = builder .sentenceOverlap ;
88+ this .separatorGroup = builder .separatorGroup ;
89+ this .separators = ApiTypeHelper .unmodifiable (builder .separators );
90+ this .strategy = builder .strategy ;
9191
9292 }
9393
@@ -96,24 +96,39 @@ public static ChunkRescorerChunkingSettings of(Function<Builder, ObjectBuilder<C
9696 }
9797
9898 /**
99- * The chunking strategy: <code>sentence</code>, <code>word</code>,
100- * <code>none</code> or <code>recursive</code>.
101- * <ul>
102- * <li>If <code>strategy</code> is set to <code>recursive</code>, you must also
103- * specify:</li>
104- * </ul>
105- * <ul>
106- * <li><code>max_chunk_size</code></li>
107- * <li>either <code>separators</code> or<code>separator_group</code></li>
108- * </ul>
99+ * Required - The maximum size of a chunk in words. This value cannot be lower
100+ * than <code>20</code> (for <code>sentence</code> strategy) or <code>10</code>
101+ * (for <code>word</code> strategy). This value should not exceed the window
102+ * size for the associated model.
109103 * <p>
110- * Learn more about different chunking strategies in the linked documentation.
104+ * API name: {@code max_chunk_size}
105+ */
106+ public final int maxChunkSize () {
107+ return this .maxChunkSize ;
108+ }
109+
110+ /**
111+ * The number of overlapping words for chunks. It is applicable only to a
112+ * <code>word</code> chunking strategy. This value cannot be higher than half
113+ * the <code>max_chunk_size</code> value.
111114 * <p>
112- * API name: {@code strategy }
115+ * API name: {@code overlap }
113116 */
114117 @ Nullable
115- public final String strategy () {
116- return this .strategy ;
118+ public final Integer overlap () {
119+ return this .overlap ;
120+ }
121+
122+ /**
123+ * The number of overlapping sentences for chunks. It is applicable only for a
124+ * <code>sentence</code> chunking strategy. It can be either <code>1</code> or
125+ * <code>0</code>.
126+ * <p>
127+ * API name: {@code sentence_overlap}
128+ */
129+ @ Nullable
130+ public final Integer sentenceOverlap () {
131+ return this .sentenceOverlap ;
117132 }
118133
119134 /**
@@ -155,39 +170,24 @@ public final List<String> separators() {
155170 }
156171
157172 /**
158- * Required - The maximum size of a chunk in words. This value cannot be lower
159- * than <code>20</code> (for <code>sentence</code> strategy) or <code>10</code>
160- * (for <code>word</code> strategy). This value should not exceed the window
161- * size for the associated model.
162- * <p>
163- * API name: {@code max_chunk_size}
164- */
165- public final int maxChunkSize () {
166- return this .maxChunkSize ;
167- }
168-
169- /**
170- * The number of overlapping words for chunks. It is applicable only to a
171- * <code>word</code> chunking strategy. This value cannot be higher than half
172- * the <code>max_chunk_size</code> value.
173+ * The chunking strategy: <code>sentence</code>, <code>word</code>,
174+ * <code>none</code> or <code>recursive</code>.
175+ * <ul>
176+ * <li>If <code>strategy</code> is set to <code>recursive</code>, you must also
177+ * specify:</li>
178+ * </ul>
179+ * <ul>
180+ * <li><code>max_chunk_size</code></li>
181+ * <li>either <code>separators</code> or<code>separator_group</code></li>
182+ * </ul>
173183 * <p>
174- * API name: {@code overlap}
175- */
176- @ Nullable
177- public final Integer overlap () {
178- return this .overlap ;
179- }
180-
181- /**
182- * The number of overlapping sentences for chunks. It is applicable only for a
183- * <code>sentence</code> chunking strategy. It can be either <code>1</code> or
184- * <code>0</code>.
184+ * Learn more about different chunking strategies in the linked documentation.
185185 * <p>
186- * API name: {@code sentence_overlap }
186+ * API name: {@code strategy }
187187 */
188188 @ Nullable
189- public final Integer sentenceOverlap () {
190- return this .sentenceOverlap ;
189+ public final String strategy () {
190+ return this .strategy ;
191191 }
192192
193193 /**
@@ -201,9 +201,17 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
201201
202202 protected void serializeInternal (JsonGenerator generator , JsonpMapper mapper ) {
203203
204- if (this .strategy != null ) {
205- generator .writeKey ("strategy" );
206- generator .write (this .strategy );
204+ generator .writeKey ("max_chunk_size" );
205+ generator .write (this .maxChunkSize );
206+
207+ if (this .overlap != null ) {
208+ generator .writeKey ("overlap" );
209+ generator .write (this .overlap );
210+
211+ }
212+ if (this .sentenceOverlap != null ) {
213+ generator .writeKey ("sentence_overlap" );
214+ generator .write (this .sentenceOverlap );
207215
208216 }
209217 if (this .separatorGroup != null ) {
@@ -221,17 +229,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
221229 generator .writeEnd ();
222230
223231 }
224- generator .writeKey ("max_chunk_size" );
225- generator .write (this .maxChunkSize );
226-
227- if (this .overlap != null ) {
228- generator .writeKey ("overlap" );
229- generator .write (this .overlap );
230-
231- }
232- if (this .sentenceOverlap != null ) {
233- generator .writeKey ("sentence_overlap" );
234- generator .write (this .sentenceOverlap );
232+ if (this .strategy != null ) {
233+ generator .writeKey ("strategy" );
234+ generator .write (this .strategy );
235235
236236 }
237237
@@ -251,52 +251,68 @@ public String toString() {
251251 public static class Builder extends WithJsonObjectBuilderBase <Builder >
252252 implements
253253 ObjectBuilder <ChunkRescorerChunkingSettings > {
254- @ Nullable
255- private String strategy ;
254+ private Integer maxChunkSize ;
256255
257256 @ Nullable
258- private String separatorGroup ;
257+ private Integer overlap ;
259258
260259 @ Nullable
261- private List < String > separators ;
260+ private Integer sentenceOverlap ;
262261
263- private Integer maxChunkSize ;
262+ @ Nullable
263+ private String separatorGroup ;
264264
265265 @ Nullable
266- private Integer overlap ;
266+ private List < String > separators ;
267267
268268 @ Nullable
269- private Integer sentenceOverlap ;
269+ private String strategy ;
270270
271271 public Builder () {
272272 }
273273 private Builder (ChunkRescorerChunkingSettings instance ) {
274- this .strategy = instance .strategy ;
275- this .separatorGroup = instance .separatorGroup ;
276- this .separators = instance .separators ;
277274 this .maxChunkSize = instance .maxChunkSize ;
278275 this .overlap = instance .overlap ;
279276 this .sentenceOverlap = instance .sentenceOverlap ;
277+ this .separatorGroup = instance .separatorGroup ;
278+ this .separators = instance .separators ;
279+ this .strategy = instance .strategy ;
280280
281281 }
282282 /**
283- * The chunking strategy: <code>sentence</code>, <code>word</code>,
284- * <code>none</code> or <code>recursive</code>.
285- * <ul>
286- * <li>If <code>strategy</code> is set to <code>recursive</code>, you must also
287- * specify:</li>
288- * </ul>
289- * <ul>
290- * <li><code>max_chunk_size</code></li>
291- * <li>either <code>separators</code> or<code>separator_group</code></li>
292- * </ul>
283+ * Required - The maximum size of a chunk in words. This value cannot be lower
284+ * than <code>20</code> (for <code>sentence</code> strategy) or <code>10</code>
285+ * (for <code>word</code> strategy). This value should not exceed the window
286+ * size for the associated model.
293287 * <p>
294- * Learn more about different chunking strategies in the linked documentation.
288+ * API name: {@code max_chunk_size}
289+ */
290+ public final Builder maxChunkSize (int value ) {
291+ this .maxChunkSize = value ;
292+ return this ;
293+ }
294+
295+ /**
296+ * The number of overlapping words for chunks. It is applicable only to a
297+ * <code>word</code> chunking strategy. This value cannot be higher than half
298+ * the <code>max_chunk_size</code> value.
295299 * <p>
296- * API name: {@code strategy }
300+ * API name: {@code overlap }
297301 */
298- public final Builder strategy (@ Nullable String value ) {
299- this .strategy = value ;
302+ public final Builder overlap (@ Nullable Integer value ) {
303+ this .overlap = value ;
304+ return this ;
305+ }
306+
307+ /**
308+ * The number of overlapping sentences for chunks. It is applicable only for a
309+ * <code>sentence</code> chunking strategy. It can be either <code>1</code> or
310+ * <code>0</code>.
311+ * <p>
312+ * API name: {@code sentence_overlap}
313+ */
314+ public final Builder sentenceOverlap (@ Nullable Integer value ) {
315+ this .sentenceOverlap = value ;
300316 return this ;
301317 }
302318
@@ -365,39 +381,23 @@ public final Builder separators(String value, String... values) {
365381 }
366382
367383 /**
368- * Required - The maximum size of a chunk in words. This value cannot be lower
369- * than <code>20</code> (for <code>sentence</code> strategy) or <code>10</code>
370- * (for <code>word</code> strategy). This value should not exceed the window
371- * size for the associated model.
372- * <p>
373- * API name: {@code max_chunk_size}
374- */
375- public final Builder maxChunkSize (int value ) {
376- this .maxChunkSize = value ;
377- return this ;
378- }
379-
380- /**
381- * The number of overlapping words for chunks. It is applicable only to a
382- * <code>word</code> chunking strategy. This value cannot be higher than half
383- * the <code>max_chunk_size</code> value.
384+ * The chunking strategy: <code>sentence</code>, <code>word</code>,
385+ * <code>none</code> or <code>recursive</code>.
386+ * <ul>
387+ * <li>If <code>strategy</code> is set to <code>recursive</code>, you must also
388+ * specify:</li>
389+ * </ul>
390+ * <ul>
391+ * <li><code>max_chunk_size</code></li>
392+ * <li>either <code>separators</code> or<code>separator_group</code></li>
393+ * </ul>
384394 * <p>
385- * API name: {@code overlap}
386- */
387- public final Builder overlap (@ Nullable Integer value ) {
388- this .overlap = value ;
389- return this ;
390- }
391-
392- /**
393- * The number of overlapping sentences for chunks. It is applicable only for a
394- * <code>sentence</code> chunking strategy. It can be either <code>1</code> or
395- * <code>0</code>.
395+ * Learn more about different chunking strategies in the linked documentation.
396396 * <p>
397- * API name: {@code sentence_overlap }
397+ * API name: {@code strategy }
398398 */
399- public final Builder sentenceOverlap (@ Nullable Integer value ) {
400- this .sentenceOverlap = value ;
399+ public final Builder strategy (@ Nullable String value ) {
400+ this .strategy = value ;
401401 return this ;
402402 }
403403
@@ -436,13 +436,13 @@ public Builder rebuild() {
436436 protected static void setupChunkRescorerChunkingSettingsDeserializer (
437437 ObjectDeserializer <ChunkRescorerChunkingSettings .Builder > op ) {
438438
439- op .add (Builder ::strategy , JsonpDeserializer .stringDeserializer (), "strategy" );
440- op .add (Builder ::separatorGroup , JsonpDeserializer .stringDeserializer (), "separator_group" );
441- op .add (Builder ::separators , JsonpDeserializer .arrayDeserializer (JsonpDeserializer .stringDeserializer ()),
442- "separators" );
443439 op .add (Builder ::maxChunkSize , JsonpDeserializer .integerDeserializer (), "max_chunk_size" );
444440 op .add (Builder ::overlap , JsonpDeserializer .integerDeserializer (), "overlap" );
445441 op .add (Builder ::sentenceOverlap , JsonpDeserializer .integerDeserializer (), "sentence_overlap" );
442+ op .add (Builder ::separatorGroup , JsonpDeserializer .stringDeserializer (), "separator_group" );
443+ op .add (Builder ::separators , JsonpDeserializer .arrayDeserializer (JsonpDeserializer .stringDeserializer ()),
444+ "separators" );
445+ op .add (Builder ::strategy , JsonpDeserializer .stringDeserializer (), "strategy" );
446446
447447 }
448448
0 commit comments