001package com.box.sdkgen.schemas.aiask;
002
003import com.box.sdkgen.internal.NullableFieldTracker;
004import com.box.sdkgen.internal.SerializableObject;
005import com.box.sdkgen.schemas.aiagentask.AiAgentAsk;
006import com.box.sdkgen.schemas.aiagentreference.AiAgentReference;
007import com.box.sdkgen.schemas.aiaskagent.AiAskAgent;
008import com.box.sdkgen.schemas.aidialoguehistory.AiDialogueHistory;
009import com.box.sdkgen.schemas.aiitemask.AiItemAsk;
010import com.box.sdkgen.serialization.json.EnumWrapper;
011import com.fasterxml.jackson.annotation.JsonFilter;
012import com.fasterxml.jackson.annotation.JsonProperty;
013import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
014import com.fasterxml.jackson.databind.annotation.JsonSerialize;
015import java.util.List;
016import java.util.Objects;
017
018/** AI ask request object. */
019@JsonFilter("nullablePropertyFilter")
020public class AiAsk extends SerializableObject {
021
022  /**
023   * Box AI handles text documents with text representations up to 2MB in size, or a maximum of 25
024   * files, whichever comes first. If the text file size exceeds 2MB, the first 2MB of text
025   * representation will be processed. Box AI handles image documents with a resolution of 1024 x
026   * 1024 pixels, with a maximum of 5 images or 5 pages for multi-page images. If the number of
027   * image or image pages exceeds 5, the first 5 images or pages will be processed. If you set mode
028   * parameter to `single_item_qa`, the items array can have one element only. Currently Box AI does
029   * not support multi-modal requests. If both images and text are sent Box AI will only process the
030   * text.
031   */
032  @JsonDeserialize(using = AiAskModeField.AiAskModeFieldDeserializer.class)
033  @JsonSerialize(using = AiAskModeField.AiAskModeFieldSerializer.class)
034  protected final EnumWrapper<AiAskModeField> mode;
035
036  /**
037   * The prompt provided by the client to be answered by the LLM. The prompt's length is limited to
038   * 10000 characters.
039   */
040  protected final String prompt;
041
042  /**
043   * The items to be processed by the LLM, often files. To search across and ask questions about the
044   * contents of a Box Hub, pass a single item with `type` set to `hubs`. See the item `type`
045   * property for details.
046   */
047  protected final List<AiItemAsk> items;
048
049  /**
050   * The history of prompts and answers previously passed to the LLM. This provides additional
051   * context to the LLM in generating the response.
052   */
053  @JsonProperty("dialogue_history")
054  protected List<AiDialogueHistory> dialogueHistory;
055
056  /** A flag to indicate whether citations should be returned. */
057  @JsonProperty("include_citations")
058  protected Boolean includeCitations;
059
060  @JsonProperty("ai_agent")
061  protected AiAskAgent aiAgent;
062
063  public AiAsk(AiAskModeField mode, String prompt, List<AiItemAsk> items) {
064    super();
065    this.mode = new EnumWrapper<AiAskModeField>(mode);
066    this.prompt = prompt;
067    this.items = items;
068  }
069
070  public AiAsk(
071      @JsonProperty("mode") EnumWrapper<AiAskModeField> mode,
072      @JsonProperty("prompt") String prompt,
073      @JsonProperty("items") List<AiItemAsk> items) {
074    super();
075    this.mode = mode;
076    this.prompt = prompt;
077    this.items = items;
078  }
079
080  protected AiAsk(Builder builder) {
081    super();
082    this.mode = builder.mode;
083    this.prompt = builder.prompt;
084    this.items = builder.items;
085    this.dialogueHistory = builder.dialogueHistory;
086    this.includeCitations = builder.includeCitations;
087    this.aiAgent = builder.aiAgent;
088    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
089  }
090
091  public EnumWrapper<AiAskModeField> getMode() {
092    return mode;
093  }
094
095  public String getPrompt() {
096    return prompt;
097  }
098
099  public List<AiItemAsk> getItems() {
100    return items;
101  }
102
103  public List<AiDialogueHistory> getDialogueHistory() {
104    return dialogueHistory;
105  }
106
107  public Boolean getIncludeCitations() {
108    return includeCitations;
109  }
110
111  public AiAskAgent getAiAgent() {
112    return aiAgent;
113  }
114
115  @Override
116  public boolean equals(Object o) {
117    if (this == o) {
118      return true;
119    }
120    if (o == null || getClass() != o.getClass()) {
121      return false;
122    }
123    AiAsk casted = (AiAsk) o;
124    return Objects.equals(mode, casted.mode)
125        && Objects.equals(prompt, casted.prompt)
126        && Objects.equals(items, casted.items)
127        && Objects.equals(dialogueHistory, casted.dialogueHistory)
128        && Objects.equals(includeCitations, casted.includeCitations)
129        && Objects.equals(aiAgent, casted.aiAgent);
130  }
131
132  @Override
133  public int hashCode() {
134    return Objects.hash(mode, prompt, items, dialogueHistory, includeCitations, aiAgent);
135  }
136
137  @Override
138  public String toString() {
139    return "AiAsk{"
140        + "mode='"
141        + mode
142        + '\''
143        + ", "
144        + "prompt='"
145        + prompt
146        + '\''
147        + ", "
148        + "items='"
149        + items
150        + '\''
151        + ", "
152        + "dialogueHistory='"
153        + dialogueHistory
154        + '\''
155        + ", "
156        + "includeCitations='"
157        + includeCitations
158        + '\''
159        + ", "
160        + "aiAgent='"
161        + aiAgent
162        + '\''
163        + "}";
164  }
165
166  public static class Builder extends NullableFieldTracker {
167
168    protected final EnumWrapper<AiAskModeField> mode;
169
170    protected final String prompt;
171
172    protected final List<AiItemAsk> items;
173
174    protected List<AiDialogueHistory> dialogueHistory;
175
176    protected Boolean includeCitations;
177
178    protected AiAskAgent aiAgent;
179
180    public Builder(AiAskModeField mode, String prompt, List<AiItemAsk> items) {
181      super();
182      this.mode = new EnumWrapper<AiAskModeField>(mode);
183      this.prompt = prompt;
184      this.items = items;
185    }
186
187    public Builder(EnumWrapper<AiAskModeField> mode, String prompt, List<AiItemAsk> items) {
188      super();
189      this.mode = mode;
190      this.prompt = prompt;
191      this.items = items;
192    }
193
194    public Builder dialogueHistory(List<AiDialogueHistory> dialogueHistory) {
195      this.dialogueHistory = dialogueHistory;
196      return this;
197    }
198
199    public Builder includeCitations(Boolean includeCitations) {
200      this.includeCitations = includeCitations;
201      return this;
202    }
203
204    public Builder aiAgent(AiAgentReference aiAgent) {
205      this.aiAgent = new AiAskAgent(aiAgent);
206      return this;
207    }
208
209    public Builder aiAgent(AiAgentAsk aiAgent) {
210      this.aiAgent = new AiAskAgent(aiAgent);
211      return this;
212    }
213
214    public Builder aiAgent(AiAskAgent aiAgent) {
215      this.aiAgent = aiAgent;
216      return this;
217    }
218
219    public AiAsk build() {
220      return new AiAsk(this);
221    }
222  }
223}