001package com.box.sdkgen.schemas.aiextractstructuredresponse; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.internal.utils.DateTimeUtils; 006import com.box.sdkgen.schemas.aiagentinfo.AiAgentInfo; 007import com.fasterxml.jackson.annotation.JsonFilter; 008import com.fasterxml.jackson.annotation.JsonProperty; 009import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 010import com.fasterxml.jackson.databind.annotation.JsonSerialize; 011import java.time.OffsetDateTime; 012import java.util.Map; 013import java.util.Objects; 014 015/** AI extract structured response. */ 016@JsonFilter("nullablePropertyFilter") 017public class AiExtractStructuredResponse extends SerializableObject { 018 019 protected final Map<String, Object> answer; 020 021 /** The ISO date formatted timestamp of when the answer to the prompt was created. */ 022 @JsonProperty("created_at") 023 @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class) 024 @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class) 025 protected final OffsetDateTime createdAt; 026 027 /** The reason the response finishes. */ 028 @JsonProperty("completion_reason") 029 protected String completionReason; 030 031 /** 032 * The confidence score levels and numeric values for each extracted field as a JSON dictionary. 033 * This can be empty if no field could be extracted. 034 */ 035 @JsonProperty("confidence_score") 036 protected Map<String, Object> confidenceScore; 037 038 /** 039 * The reference for each extracted field as a JSON dictionary. This can be empty if no field 040 * could be extracted. 041 */ 042 protected Map<String, Object> reference; 043 044 @JsonProperty("ai_agent_info") 045 protected AiAgentInfo aiAgentInfo; 046 047 public AiExtractStructuredResponse( 048 @JsonProperty("answer") Map<String, Object> answer, 049 @JsonProperty("created_at") OffsetDateTime createdAt) { 050 super(); 051 this.answer = answer; 052 this.createdAt = createdAt; 053 } 054 055 protected AiExtractStructuredResponse(Builder builder) { 056 super(); 057 this.answer = builder.answer; 058 this.createdAt = builder.createdAt; 059 this.completionReason = builder.completionReason; 060 this.confidenceScore = builder.confidenceScore; 061 this.reference = builder.reference; 062 this.aiAgentInfo = builder.aiAgentInfo; 063 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 064 } 065 066 public Map<String, Object> getAnswer() { 067 return answer; 068 } 069 070 public OffsetDateTime getCreatedAt() { 071 return createdAt; 072 } 073 074 public String getCompletionReason() { 075 return completionReason; 076 } 077 078 public Map<String, Object> getConfidenceScore() { 079 return confidenceScore; 080 } 081 082 public Map<String, Object> getReference() { 083 return reference; 084 } 085 086 public AiAgentInfo getAiAgentInfo() { 087 return aiAgentInfo; 088 } 089 090 @Override 091 public boolean equals(Object o) { 092 if (this == o) { 093 return true; 094 } 095 if (o == null || getClass() != o.getClass()) { 096 return false; 097 } 098 AiExtractStructuredResponse casted = (AiExtractStructuredResponse) o; 099 return Objects.equals(answer, casted.answer) 100 && Objects.equals(createdAt, casted.createdAt) 101 && Objects.equals(completionReason, casted.completionReason) 102 && Objects.equals(confidenceScore, casted.confidenceScore) 103 && Objects.equals(reference, casted.reference) 104 && Objects.equals(aiAgentInfo, casted.aiAgentInfo); 105 } 106 107 @Override 108 public int hashCode() { 109 return Objects.hash( 110 answer, createdAt, completionReason, confidenceScore, reference, aiAgentInfo); 111 } 112 113 @Override 114 public String toString() { 115 return "AiExtractStructuredResponse{" 116 + "answer='" 117 + answer 118 + '\'' 119 + ", " 120 + "createdAt='" 121 + createdAt 122 + '\'' 123 + ", " 124 + "completionReason='" 125 + completionReason 126 + '\'' 127 + ", " 128 + "confidenceScore='" 129 + confidenceScore 130 + '\'' 131 + ", " 132 + "reference='" 133 + reference 134 + '\'' 135 + ", " 136 + "aiAgentInfo='" 137 + aiAgentInfo 138 + '\'' 139 + "}"; 140 } 141 142 public static class Builder extends NullableFieldTracker { 143 144 protected final Map<String, Object> answer; 145 146 protected final OffsetDateTime createdAt; 147 148 protected String completionReason; 149 150 protected Map<String, Object> confidenceScore; 151 152 protected Map<String, Object> reference; 153 154 protected AiAgentInfo aiAgentInfo; 155 156 public Builder(Map<String, Object> answer, OffsetDateTime createdAt) { 157 super(); 158 this.answer = answer; 159 this.createdAt = createdAt; 160 } 161 162 public Builder completionReason(String completionReason) { 163 this.completionReason = completionReason; 164 return this; 165 } 166 167 public Builder confidenceScore(Map<String, Object> confidenceScore) { 168 this.confidenceScore = confidenceScore; 169 return this; 170 } 171 172 public Builder reference(Map<String, Object> reference) { 173 this.reference = reference; 174 return this; 175 } 176 177 public Builder aiAgentInfo(AiAgentInfo aiAgentInfo) { 178 this.aiAgentInfo = aiAgentInfo; 179 return this; 180 } 181 182 public AiExtractStructuredResponse build() { 183 return new AiExtractStructuredResponse(this); 184 } 185 } 186}