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 1MB in size, or a maximum of 25
024   * files, whichever comes first. If the text file size exceeds 1MB, the first 1MB 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  /** The items to be processed by the LLM, often files. */
043  protected final List<AiItemAsk> items;
044
045  /**
046   * The history of prompts and answers previously passed to the LLM. This provides additional
047   * context to the LLM in generating the response.
048   */
049  @JsonProperty("dialogue_history")
050  protected List<AiDialogueHistory> dialogueHistory;
051
052  /** A flag to indicate whether citations should be returned. */
053  @JsonProperty("include_citations")
054  protected Boolean includeCitations;
055
056  @JsonProperty("ai_agent")
057  protected AiAskAgent aiAgent;
058
059  public AiAsk(AiAskModeField mode, String prompt, List<AiItemAsk> items) {
060    super();
061    this.mode = new EnumWrapper<AiAskModeField>(mode);
062    this.prompt = prompt;
063    this.items = items;
064  }
065
066  public AiAsk(
067      @JsonProperty("mode") EnumWrapper<AiAskModeField> mode,
068      @JsonProperty("prompt") String prompt,
069      @JsonProperty("items") List<AiItemAsk> items) {
070    super();
071    this.mode = mode;
072    this.prompt = prompt;
073    this.items = items;
074  }
075
076  protected AiAsk(Builder builder) {
077    super();
078    this.mode = builder.mode;
079    this.prompt = builder.prompt;
080    this.items = builder.items;
081    this.dialogueHistory = builder.dialogueHistory;
082    this.includeCitations = builder.includeCitations;
083    this.aiAgent = builder.aiAgent;
084    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
085  }
086
087  public EnumWrapper<AiAskModeField> getMode() {
088    return mode;
089  }
090
091  public String getPrompt() {
092    return prompt;
093  }
094
095  public List<AiItemAsk> getItems() {
096    return items;
097  }
098
099  public List<AiDialogueHistory> getDialogueHistory() {
100    return dialogueHistory;
101  }
102
103  public Boolean getIncludeCitations() {
104    return includeCitations;
105  }
106
107  public AiAskAgent getAiAgent() {
108    return aiAgent;
109  }
110
111  @Override
112  public boolean equals(Object o) {
113    if (this == o) {
114      return true;
115    }
116    if (o == null || getClass() != o.getClass()) {
117      return false;
118    }
119    AiAsk casted = (AiAsk) o;
120    return Objects.equals(mode, casted.mode)
121        && Objects.equals(prompt, casted.prompt)
122        && Objects.equals(items, casted.items)
123        && Objects.equals(dialogueHistory, casted.dialogueHistory)
124        && Objects.equals(includeCitations, casted.includeCitations)
125        && Objects.equals(aiAgent, casted.aiAgent);
126  }
127
128  @Override
129  public int hashCode() {
130    return Objects.hash(mode, prompt, items, dialogueHistory, includeCitations, aiAgent);
131  }
132
133  @Override
134  public String toString() {
135    return "AiAsk{"
136        + "mode='"
137        + mode
138        + '\''
139        + ", "
140        + "prompt='"
141        + prompt
142        + '\''
143        + ", "
144        + "items='"
145        + items
146        + '\''
147        + ", "
148        + "dialogueHistory='"
149        + dialogueHistory
150        + '\''
151        + ", "
152        + "includeCitations='"
153        + includeCitations
154        + '\''
155        + ", "
156        + "aiAgent='"
157        + aiAgent
158        + '\''
159        + "}";
160  }
161
162  public static class Builder extends NullableFieldTracker {
163
164    protected final EnumWrapper<AiAskModeField> mode;
165
166    protected final String prompt;
167
168    protected final List<AiItemAsk> items;
169
170    protected List<AiDialogueHistory> dialogueHistory;
171
172    protected Boolean includeCitations;
173
174    protected AiAskAgent aiAgent;
175
176    public Builder(AiAskModeField mode, String prompt, List<AiItemAsk> items) {
177      super();
178      this.mode = new EnumWrapper<AiAskModeField>(mode);
179      this.prompt = prompt;
180      this.items = items;
181    }
182
183    public Builder(EnumWrapper<AiAskModeField> mode, String prompt, List<AiItemAsk> items) {
184      super();
185      this.mode = mode;
186      this.prompt = prompt;
187      this.items = items;
188    }
189
190    public Builder dialogueHistory(List<AiDialogueHistory> dialogueHistory) {
191      this.dialogueHistory = dialogueHistory;
192      return this;
193    }
194
195    public Builder includeCitations(Boolean includeCitations) {
196      this.includeCitations = includeCitations;
197      return this;
198    }
199
200    public Builder aiAgent(AiAgentReference aiAgent) {
201      this.aiAgent = new AiAskAgent(aiAgent);
202      return this;
203    }
204
205    public Builder aiAgent(AiAgentAsk aiAgent) {
206      this.aiAgent = new AiAskAgent(aiAgent);
207      return this;
208    }
209
210    public Builder aiAgent(AiAskAgent aiAgent) {
211      this.aiAgent = aiAgent;
212      return this;
213    }
214
215    public AiAsk build() {
216      return new AiAsk(this);
217    }
218  }
219}