-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInferenceParameters.java
More file actions
133 lines (119 loc) · 3.32 KB
/
InferenceParameters.java
File metadata and controls
133 lines (119 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.mindee;
import java.util.Objects;
import lombok.Data;
import lombok.Getter;
/**
* Options to pass when calling methods using the API V2.
*/
@Getter
@Data
public final class InferenceParameters {
/**
* ID of the model (required).
*/
private final String modelId;
/**
* Enhance extraction accuracy with Retrieval-Augmented Generation.
*/
private final Boolean rag;
/**
* Extract the full text content from the document as strings.
*/
private final Boolean rawText;
/**
* Calculate bounding box polygons for all fields.
*/
private final Boolean polygon;
/**
* Boost the precision and accuracy of all extractions.
* Calculate confidence scores for all fields.
*/
private final Boolean confidence;
/**
* Optional alias for the file.
*/
private final String alias;
/**
* IDs of webhooks to propagate the API response to (may be empty).
*/
private final String[] webhookIds;
/**
* Polling options. Set only if having timeout issues.
*/
private final AsyncPollingOptions pollingOptions;
/**
* Create a new builder.
*
* @param modelId the mandatory model identifier
* @return a fresh {@link Builder}
*/
public static Builder builder(String modelId) {
return new Builder(modelId);
}
/**
* Fluent builder for {@link InferenceParameters}.
*/
public static final class Builder {
private final String modelId;
private Boolean rag = null;
private Boolean rawText = null;
private Boolean polygon = null;
private Boolean confidence = null;
private String alias;
private String[] webhookIds = new String[]{};
private AsyncPollingOptions pollingOptions = AsyncPollingOptions.builder().build();
private Builder(String modelId) {
this.modelId = Objects.requireNonNull(modelId, "modelId must not be null");
}
/** Enhance extraction accuracy with Retrieval-Augmented Generation. */
public Builder rag(Boolean rag) {
this.rag = rag;
return this;
}
/** Extract the full text content from the document as strings. */
public Builder rawText(Boolean rawText) {
this.rawText = rawText;
return this;
}
/** Calculate bounding box polygons for all fields. */
public Builder polygon(Boolean polygon) {
this.polygon = polygon;
return this;
}
/**
* Boost the precision and accuracy of all extractions.
* Calculate confidence scores for all fields.
*/
public Builder confidence(Boolean confidence) {
this.confidence = confidence;
return this;
}
/** Set an alias for the uploaded document. */
public Builder alias(String alias) {
this.alias = alias;
return this;
}
/** Provide IDs of webhooks to forward the API response to. */
public Builder webhookIds(String[] webhookIds) {
this.webhookIds = webhookIds;
return this;
}
public Builder pollingOptions(AsyncPollingOptions pollingOptions) {
this.pollingOptions = pollingOptions;
return this;
}
/** Build an immutable {@link InferenceParameters} instance. */
public InferenceParameters build() {
return new InferenceParameters(
modelId,
rag,
rawText,
polygon,
confidence,
alias,
webhookIds,
pollingOptions
);
}
}
}