001package com.box.sdkgen.schemas.airesponse;
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.Objects;
013
014/** AI response. */
015@JsonFilter("nullablePropertyFilter")
016public class AiResponse extends SerializableObject {
017
018  /** The answer provided by the LLM. */
019  protected final String 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  @JsonProperty("ai_agent_info")
032  protected AiAgentInfo aiAgentInfo;
033
034  public AiResponse(
035      @JsonProperty("answer") String answer, @JsonProperty("created_at") OffsetDateTime createdAt) {
036    super();
037    this.answer = answer;
038    this.createdAt = createdAt;
039  }
040
041  protected AiResponse(Builder builder) {
042    super();
043    this.answer = builder.answer;
044    this.createdAt = builder.createdAt;
045    this.completionReason = builder.completionReason;
046    this.aiAgentInfo = builder.aiAgentInfo;
047    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
048  }
049
050  public String getAnswer() {
051    return answer;
052  }
053
054  public OffsetDateTime getCreatedAt() {
055    return createdAt;
056  }
057
058  public String getCompletionReason() {
059    return completionReason;
060  }
061
062  public AiAgentInfo getAiAgentInfo() {
063    return aiAgentInfo;
064  }
065
066  @Override
067  public boolean equals(Object o) {
068    if (this == o) {
069      return true;
070    }
071    if (o == null || getClass() != o.getClass()) {
072      return false;
073    }
074    AiResponse casted = (AiResponse) o;
075    return Objects.equals(answer, casted.answer)
076        && Objects.equals(createdAt, casted.createdAt)
077        && Objects.equals(completionReason, casted.completionReason)
078        && Objects.equals(aiAgentInfo, casted.aiAgentInfo);
079  }
080
081  @Override
082  public int hashCode() {
083    return Objects.hash(answer, createdAt, completionReason, aiAgentInfo);
084  }
085
086  @Override
087  public String toString() {
088    return "AiResponse{"
089        + "answer='"
090        + answer
091        + '\''
092        + ", "
093        + "createdAt='"
094        + createdAt
095        + '\''
096        + ", "
097        + "completionReason='"
098        + completionReason
099        + '\''
100        + ", "
101        + "aiAgentInfo='"
102        + aiAgentInfo
103        + '\''
104        + "}";
105  }
106
107  public static class Builder extends NullableFieldTracker {
108
109    protected final String answer;
110
111    protected final OffsetDateTime createdAt;
112
113    protected String completionReason;
114
115    protected AiAgentInfo aiAgentInfo;
116
117    public Builder(String answer, OffsetDateTime createdAt) {
118      super();
119      this.answer = answer;
120      this.createdAt = createdAt;
121    }
122
123    public Builder completionReason(String completionReason) {
124      this.completionReason = completionReason;
125      return this;
126    }
127
128    public Builder aiAgentInfo(AiAgentInfo aiAgentInfo) {
129      this.aiAgentInfo = aiAgentInfo;
130      return this;
131    }
132
133    public AiResponse build() {
134      return new AiResponse(this);
135    }
136  }
137}