001package com.box.sdkgen.schemas.aitextgen; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.schemas.aiagentreference.AiAgentReference; 006import com.box.sdkgen.schemas.aiagenttextgen.AiAgentTextGen; 007import com.box.sdkgen.schemas.aidialoguehistory.AiDialogueHistory; 008import com.box.sdkgen.schemas.aitextgenagent.AiTextGenAgent; 009import com.fasterxml.jackson.annotation.JsonFilter; 010import com.fasterxml.jackson.annotation.JsonProperty; 011import java.util.List; 012import java.util.Objects; 013 014/** AI text gen request object. */ 015@JsonFilter("nullablePropertyFilter") 016public class AiTextGen extends SerializableObject { 017 018 /** 019 * The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 020 * 10000 characters. 021 */ 022 protected final String prompt; 023 024 /** 025 * The items to be processed by the LLM, often files. The array can include **exactly one** 026 * element. 027 * 028 * <p>**Note**: Box AI handles documents with text representations up to 1MB in size. If the file 029 * size exceeds 1MB, the first 1MB of text representation will be processed. 030 */ 031 protected final List<AiTextGenItemsField> items; 032 033 /** 034 * The history of prompts and answers previously passed to the LLM. This parameter provides the 035 * additional context to the LLM when generating the response. 036 */ 037 @JsonProperty("dialogue_history") 038 protected List<AiDialogueHistory> dialogueHistory; 039 040 @JsonProperty("ai_agent") 041 protected AiTextGenAgent aiAgent; 042 043 public AiTextGen( 044 @JsonProperty("prompt") String prompt, 045 @JsonProperty("items") List<AiTextGenItemsField> items) { 046 super(); 047 this.prompt = prompt; 048 this.items = items; 049 } 050 051 protected AiTextGen(Builder builder) { 052 super(); 053 this.prompt = builder.prompt; 054 this.items = builder.items; 055 this.dialogueHistory = builder.dialogueHistory; 056 this.aiAgent = builder.aiAgent; 057 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 058 } 059 060 public String getPrompt() { 061 return prompt; 062 } 063 064 public List<AiTextGenItemsField> getItems() { 065 return items; 066 } 067 068 public List<AiDialogueHistory> getDialogueHistory() { 069 return dialogueHistory; 070 } 071 072 public AiTextGenAgent getAiAgent() { 073 return aiAgent; 074 } 075 076 @Override 077 public boolean equals(Object o) { 078 if (this == o) { 079 return true; 080 } 081 if (o == null || getClass() != o.getClass()) { 082 return false; 083 } 084 AiTextGen casted = (AiTextGen) o; 085 return Objects.equals(prompt, casted.prompt) 086 && Objects.equals(items, casted.items) 087 && Objects.equals(dialogueHistory, casted.dialogueHistory) 088 && Objects.equals(aiAgent, casted.aiAgent); 089 } 090 091 @Override 092 public int hashCode() { 093 return Objects.hash(prompt, items, dialogueHistory, aiAgent); 094 } 095 096 @Override 097 public String toString() { 098 return "AiTextGen{" 099 + "prompt='" 100 + prompt 101 + '\'' 102 + ", " 103 + "items='" 104 + items 105 + '\'' 106 + ", " 107 + "dialogueHistory='" 108 + dialogueHistory 109 + '\'' 110 + ", " 111 + "aiAgent='" 112 + aiAgent 113 + '\'' 114 + "}"; 115 } 116 117 public static class Builder extends NullableFieldTracker { 118 119 protected final String prompt; 120 121 protected final List<AiTextGenItemsField> items; 122 123 protected List<AiDialogueHistory> dialogueHistory; 124 125 protected AiTextGenAgent aiAgent; 126 127 public Builder(String prompt, List<AiTextGenItemsField> items) { 128 super(); 129 this.prompt = prompt; 130 this.items = items; 131 } 132 133 public Builder dialogueHistory(List<AiDialogueHistory> dialogueHistory) { 134 this.dialogueHistory = dialogueHistory; 135 return this; 136 } 137 138 public Builder aiAgent(AiAgentReference aiAgent) { 139 this.aiAgent = new AiTextGenAgent(aiAgent); 140 return this; 141 } 142 143 public Builder aiAgent(AiAgentTextGen aiAgent) { 144 this.aiAgent = new AiTextGenAgent(aiAgent); 145 return this; 146 } 147 148 public Builder aiAgent(AiTextGenAgent aiAgent) { 149 this.aiAgent = aiAgent; 150 return this; 151 } 152 153 public AiTextGen build() { 154 return new AiTextGen(this); 155 } 156 } 157}