001package com.box.sdk;
002
003import com.box.sdk.internal.utils.JsonUtils;
004import com.eclipsesource.json.JsonObject;
005
006/** The parameters for the LLM endpoint specific to OpenAI / Google models. */
007public class BoxAIAgentLLMEndpointParams extends BoxJSONObject {
008  /** The type of the LLM endpoint parameters. Value can be "google_params" or "openai_params". */
009  private String type;
010
011  /** Constructs LLM endpoint parameters with default settings. */
012  public BoxAIAgentLLMEndpointParams(String type) {
013    super();
014    this.type = type;
015  }
016
017  /**
018   * Constructs LLM endpoint parameters with default settings.
019   *
020   * @param jsonObject JSON object representing the LLM endpoint parameters.
021   */
022  public BoxAIAgentLLMEndpointParams(JsonObject jsonObject) {
023    super(jsonObject);
024  }
025
026  /**
027   * Parses a JSON object representing LLM endpoint parameters.
028   *
029   * @param jsonObject JSON object representing the LLM endpoint parameters.
030   * @return The LLM endpoint parameters parsed from the JSON object.
031   */
032  public static BoxAIAgentLLMEndpointParams parse(JsonObject jsonObject) {
033    String type = jsonObject.get("type").asString();
034    switch (type) {
035      case BoxAIAgentLLMEndpointParamsGoogle.TYPE:
036        return new BoxAIAgentLLMEndpointParamsGoogle(jsonObject);
037      case BoxAIAgentLLMEndpointParamsOpenAI.TYPE:
038        return new BoxAIAgentLLMEndpointParamsOpenAI(jsonObject);
039      default:
040        throw new IllegalArgumentException("Invalid LLM endpoint params type: " + type);
041    }
042  }
043
044  /**
045   * Gets the type of the LLM endpoint parameters.
046   *
047   * @return The type of the LLM endpoint parameters.
048   */
049  public String getType() {
050    return type;
051  }
052
053  /**
054   * Sets the type of the LLM endpoint parameters.
055   *
056   * @param type The type of the LLM endpoint parameters.
057   */
058  public void setType(String type) {
059    this.type = type;
060  }
061
062  @Override
063  void parseJSONMember(JsonObject.Member member) {
064    super.parseJSONMember(member);
065    String memberName = member.getName();
066    if (memberName.equals("type")) {
067      this.type = member.getValue().asString();
068    }
069  }
070
071  public JsonObject getJSONObject() {
072    JsonObject jsonObject = new JsonObject();
073    JsonUtils.addIfNotNull(jsonObject, "type", this.type);
074    return jsonObject;
075  }
076}