001package com.box.sdk;
002
003import com.eclipsesource.json.JsonObject;
004import java.util.Date;
005
006/**
007 * Represents an entry of the history of prompts and answers previously passed to the LLM. This
008 * provides additional context to the LLM in generating the response.
009 */
010public class BoxAIDialogueEntry extends BoxJSONObject {
011  private String prompt;
012  private String answer;
013  private Date createdAt;
014
015  /**
016   * @param prompt The prompt previously provided by the client and answered by the LLM.
017   * @param answer The answer previously provided by the LLM.
018   * @param createdAt The ISO date formatted timestamp of when the previous answer to the prompt was
019   *     created.
020   */
021  public BoxAIDialogueEntry(String prompt, String answer, Date createdAt) {
022    super();
023    this.prompt = prompt;
024    this.answer = answer;
025    this.createdAt = createdAt;
026  }
027
028  /**
029   * @param prompt The prompt previously provided by the client and answered by the LLM.
030   * @param answer The answer previously provided by the LLM.
031   */
032  public BoxAIDialogueEntry(String prompt, String answer) {
033    super();
034    this.prompt = prompt;
035    this.answer = answer;
036  }
037
038  /**
039   * Get the answer previously provided by the LLM.
040   *
041   * @return the answer previously provided by the LLM.
042   */
043  public String getAnswer() {
044    return answer;
045  }
046
047  /**
048   * Set the answer previously provided by the LLM.
049   *
050   * @param answer the answer previously provided by the LLM.
051   */
052  public void setAnswer(String answer) {
053    this.answer = answer;
054  }
055
056  /**
057   * Get the prompt previously provided by the client and answered by the LLM.
058   *
059   * @return the prompt previously provided by the client and answered by the LLM.
060   */
061  public String getPrompt() {
062    return prompt;
063  }
064
065  /**
066   * Set the prompt previously provided by the client and answered by the LLM.
067   *
068   * @param prompt the prompt previously provided by the client and answered by the LLM.
069   */
070  public void setPrompt(String prompt) {
071    this.prompt = prompt;
072  }
073
074  /**
075   * Get The ISO date formatted timestamp of when the previous answer to the prompt was created.
076   *
077   * @return The ISO date formatted timestamp of when the previous answer to the prompt was created.
078   */
079  public Date getCreatedAt() {
080    return createdAt;
081  }
082
083  /**
084   * Set The ISO date formatted timestamp of when the previous answer to the prompt was created.
085   *
086   * @param createdAt The ISO date formatted timestamp of when the previous answer to the prompt was
087   *     created.
088   */
089  public void setCreatedAt(Date createdAt) {
090    this.createdAt = createdAt;
091  }
092
093  /**
094   * Gets a JSON object representing this class.
095   *
096   * @return the JSON object representing this class.
097   */
098  public JsonObject getJSONObject() {
099    JsonObject itemJSON = new JsonObject().add("prompt", this.prompt).add("answer", this.answer);
100
101    if (this.createdAt != null) {
102      itemJSON.add("created_at", BoxDateFormat.format(this.createdAt));
103    }
104
105    return itemJSON;
106  }
107}