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