001package com.box.sdkgen.schemas.aiextractstructured;
002
003import com.box.sdkgen.internal.NullableFieldTracker;
004import com.box.sdkgen.internal.SerializableObject;
005import com.box.sdkgen.schemas.aiagentextractstructured.AiAgentExtractStructured;
006import com.box.sdkgen.schemas.aiagentreference.AiAgentReference;
007import com.box.sdkgen.schemas.aiextractstructuredagent.AiExtractStructuredAgent;
008import com.box.sdkgen.schemas.aiitembase.AiItemBase;
009import com.box.sdkgen.schemas.aitaxonomysource.AiTaxonomySource;
010import com.fasterxml.jackson.annotation.JsonFilter;
011import com.fasterxml.jackson.annotation.JsonProperty;
012import java.util.List;
013import java.util.Objects;
014
015/** AI Extract Structured Request object. */
016@JsonFilter("nullablePropertyFilter")
017public class AiExtractStructured extends SerializableObject {
018
019  /** The items to be processed by the LLM. Currently you can use files only. */
020  protected final List<AiItemBase> items;
021
022  /**
023   * The metadata template containing the fields to extract. For your request to work, you must
024   * provide either `metadata_template` or `fields`, but not both.
025   */
026  @JsonProperty("metadata_template")
027  protected AiExtractStructuredMetadataTemplateField metadataTemplate;
028
029  /**
030   * The fields to be extracted from the provided items. For your request to work, you must provide
031   * either `metadata_template` or `fields`, but not both.
032   */
033  protected List<AiExtractStructuredFieldsField> fields;
034
035  @JsonProperty("ai_agent")
036  protected AiExtractStructuredAgent aiAgent;
037
038  /** A flag to indicate whether confidence scores for every extracted field should be returned. */
039  @JsonProperty("include_confidence_score")
040  protected Boolean includeConfidenceScore;
041
042  /** A flag to indicate whether references for every extracted field should be returned. */
043  @JsonProperty("include_reference")
044  protected Boolean includeReference;
045
046  /**
047   * The taxonomy sources to be used for the structured extraction. They can either be an existing
048   * file or a taxonomy. For your request to work, `fields` must also be provided.
049   * `taxonomy_sources` is not supported with `metadata_template`.
050   */
051  @JsonProperty("taxonomy_sources")
052  protected List<AiTaxonomySource> taxonomySources;
053
054  public AiExtractStructured(@JsonProperty("items") List<AiItemBase> items) {
055    super();
056    this.items = items;
057  }
058
059  protected AiExtractStructured(Builder builder) {
060    super();
061    this.items = builder.items;
062    this.metadataTemplate = builder.metadataTemplate;
063    this.fields = builder.fields;
064    this.aiAgent = builder.aiAgent;
065    this.includeConfidenceScore = builder.includeConfidenceScore;
066    this.includeReference = builder.includeReference;
067    this.taxonomySources = builder.taxonomySources;
068    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
069  }
070
071  public List<AiItemBase> getItems() {
072    return items;
073  }
074
075  public AiExtractStructuredMetadataTemplateField getMetadataTemplate() {
076    return metadataTemplate;
077  }
078
079  public List<AiExtractStructuredFieldsField> getFields() {
080    return fields;
081  }
082
083  public AiExtractStructuredAgent getAiAgent() {
084    return aiAgent;
085  }
086
087  public Boolean getIncludeConfidenceScore() {
088    return includeConfidenceScore;
089  }
090
091  public Boolean getIncludeReference() {
092    return includeReference;
093  }
094
095  public List<AiTaxonomySource> getTaxonomySources() {
096    return taxonomySources;
097  }
098
099  @Override
100  public boolean equals(Object o) {
101    if (this == o) {
102      return true;
103    }
104    if (o == null || getClass() != o.getClass()) {
105      return false;
106    }
107    AiExtractStructured casted = (AiExtractStructured) o;
108    return Objects.equals(items, casted.items)
109        && Objects.equals(metadataTemplate, casted.metadataTemplate)
110        && Objects.equals(fields, casted.fields)
111        && Objects.equals(aiAgent, casted.aiAgent)
112        && Objects.equals(includeConfidenceScore, casted.includeConfidenceScore)
113        && Objects.equals(includeReference, casted.includeReference)
114        && Objects.equals(taxonomySources, casted.taxonomySources);
115  }
116
117  @Override
118  public int hashCode() {
119    return Objects.hash(
120        items,
121        metadataTemplate,
122        fields,
123        aiAgent,
124        includeConfidenceScore,
125        includeReference,
126        taxonomySources);
127  }
128
129  @Override
130  public String toString() {
131    return "AiExtractStructured{"
132        + "items='"
133        + items
134        + '\''
135        + ", "
136        + "metadataTemplate='"
137        + metadataTemplate
138        + '\''
139        + ", "
140        + "fields='"
141        + fields
142        + '\''
143        + ", "
144        + "aiAgent='"
145        + aiAgent
146        + '\''
147        + ", "
148        + "includeConfidenceScore='"
149        + includeConfidenceScore
150        + '\''
151        + ", "
152        + "includeReference='"
153        + includeReference
154        + '\''
155        + ", "
156        + "taxonomySources='"
157        + taxonomySources
158        + '\''
159        + "}";
160  }
161
162  public static class Builder extends NullableFieldTracker {
163
164    protected final List<AiItemBase> items;
165
166    protected AiExtractStructuredMetadataTemplateField metadataTemplate;
167
168    protected List<AiExtractStructuredFieldsField> fields;
169
170    protected AiExtractStructuredAgent aiAgent;
171
172    protected Boolean includeConfidenceScore;
173
174    protected Boolean includeReference;
175
176    protected List<AiTaxonomySource> taxonomySources;
177
178    public Builder(List<AiItemBase> items) {
179      super();
180      this.items = items;
181    }
182
183    public Builder metadataTemplate(AiExtractStructuredMetadataTemplateField metadataTemplate) {
184      this.metadataTemplate = metadataTemplate;
185      return this;
186    }
187
188    public Builder fields(List<AiExtractStructuredFieldsField> fields) {
189      this.fields = fields;
190      return this;
191    }
192
193    public Builder aiAgent(AiAgentReference aiAgent) {
194      this.aiAgent = new AiExtractStructuredAgent(aiAgent);
195      return this;
196    }
197
198    public Builder aiAgent(AiAgentExtractStructured aiAgent) {
199      this.aiAgent = new AiExtractStructuredAgent(aiAgent);
200      return this;
201    }
202
203    public Builder aiAgent(AiExtractStructuredAgent aiAgent) {
204      this.aiAgent = aiAgent;
205      return this;
206    }
207
208    public Builder includeConfidenceScore(Boolean includeConfidenceScore) {
209      this.includeConfidenceScore = includeConfidenceScore;
210      return this;
211    }
212
213    public Builder includeReference(Boolean includeReference) {
214      this.includeReference = includeReference;
215      return this;
216    }
217
218    public Builder taxonomySources(List<AiTaxonomySource> taxonomySources) {
219      this.taxonomySources = taxonomySources;
220      return this;
221    }
222
223    public AiExtractStructured build() {
224      return new AiExtractStructured(this);
225    }
226  }
227}