From 5200204267d487a79facbe37d620723be1ce8228 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 24 Oct 2024 09:37:15 -0700 Subject: [PATCH] feat: add AWS params (box/box-openapi#478) --- .codegen.json | 2 +- .../AiAgentBasicTextToolBase.cs | 2 +- .../AiLlmEndpointParamsAws.cs | 70 +++++++++++++++++++ .../AiLlmEndpointParamsAwsTypeField.cs | 8 +++ ...ParamsGoogleOrAiLlmEndpointParamsOpenAi.cs | 63 +++++++++++++++++ ...ParamsGoogleOrAiLlmEndpointParamsOpenAi.cs | 51 -------------- 6 files changed, 143 insertions(+), 53 deletions(-) create mode 100644 Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAws.cs create mode 100644 Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAwsTypeField.cs create mode 100644 Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs delete mode 100644 Box.Sdk.Gen/Schemas/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs diff --git a/.codegen.json b/.codegen.json index 07603b74..40cacc14 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "2efc8ab", "specHash": "e798cb1", "version": "1.3.1" } +{ "engineHash": "2efc8ab", "specHash": "90cf4e4", "version": "1.3.1" } diff --git a/Box.Sdk.Gen/Schemas/AiAgentBasicTextToolBase/AiAgentBasicTextToolBase.cs b/Box.Sdk.Gen/Schemas/AiAgentBasicTextToolBase/AiAgentBasicTextToolBase.cs index 74a7e896..58193a19 100644 --- a/Box.Sdk.Gen/Schemas/AiAgentBasicTextToolBase/AiAgentBasicTextToolBase.cs +++ b/Box.Sdk.Gen/Schemas/AiAgentBasicTextToolBase/AiAgentBasicTextToolBase.cs @@ -22,7 +22,7 @@ public class AiAgentBasicTextToolBase : ISerializable { /// The parameters for the LLM endpoint specific to OpenAI / Google models. /// [JsonPropertyName("llm_endpoint_params")] - public AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi? LlmEndpointParams { get; init; } + public AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi? LlmEndpointParams { get; init; } public AiAgentBasicTextToolBase() { diff --git a/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAws.cs b/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAws.cs new file mode 100644 index 00000000..72cf8b7b --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAws.cs @@ -0,0 +1,70 @@ +using Box.Sdk.Gen; +using System.Text.Json.Serialization; +using Box.Sdk.Gen.Internal; +using System.Collections.Generic; + +namespace Box.Sdk.Gen.Schemas { + public class AiLlmEndpointParamsAws : ISerializable { + [JsonInclude] + [JsonPropertyName("_istemperatureSet")] + protected bool _isTemperatureSet { get; set; } + + [JsonInclude] + [JsonPropertyName("_istop_pSet")] + protected bool _isTopPSet { get; set; } + + protected double? _temperature { get; set; } + + protected double? _topP { get; set; } + + /// + /// The type of the AI LLM endpoint params object for AWS. + /// This parameter is **required**. + /// + [JsonPropertyName("type")] + [JsonConverter(typeof(StringEnumConverter))] + public StringEnum Type { get; } + + /// + /// What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// We generally recommend altering this or `top_p` but not both. + /// + [JsonPropertyName("temperature")] + public double? Temperature { get => _temperature; init { _temperature = value; _isTemperatureSet = true; } } + + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results + /// of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability + /// mass are considered. We generally recommend altering this or temperature but not both. + /// + [JsonPropertyName("top_p")] + public double? TopP { get => _topP; init { _topP = value; _isTopPSet = true; } } + + public AiLlmEndpointParamsAws(AiLlmEndpointParamsAwsTypeField type = AiLlmEndpointParamsAwsTypeField.AwsParams) { + Type = type; + } + + [JsonConstructorAttribute] + internal AiLlmEndpointParamsAws(StringEnum type) { + Type = AiLlmEndpointParamsAwsTypeField.AwsParams; + } + internal string? RawJson { get; set; } = default; + + void ISerializable.SetJson(string json) { + RawJson = json; + } + + string? ISerializable.GetJson() { + return RawJson; + } + + /// + /// Returns raw json response returned from the API. + /// + public Dictionary? GetRawData() { + return SimpleJsonSerializer.GetAllFields(this); + } + + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAwsTypeField.cs b/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAwsTypeField.cs new file mode 100644 index 00000000..7ce2cf5a --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAws/AiLlmEndpointParamsAwsTypeField.cs @@ -0,0 +1,8 @@ +using System.ComponentModel; + +namespace Box.Sdk.Gen.Schemas { + public enum AiLlmEndpointParamsAwsTypeField { + [Description("aws_params")] + AwsParams + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs b/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs new file mode 100644 index 00000000..364bfdfb --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs @@ -0,0 +1,63 @@ +using Box.Sdk.Gen; +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Box.Sdk.Gen.Schemas; + +namespace Box.Sdk.Gen.Schemas { + [JsonConverter(typeof(AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAiConverter))] + public class AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi : OneOf { + public AiLlmEndpointParamsAws? AiLlmEndpointParamsAws => _val0; + + public AiLlmEndpointParamsGoogle? AiLlmEndpointParamsGoogle => _val1; + + public AiLlmEndpointParamsOpenAi? AiLlmEndpointParamsOpenAi => _val2; + + public AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsAws value) : base(value) {} + + public AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsGoogle value) : base(value) {} + + public AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsOpenAi value) : base(value) {} + + public static implicit operator AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsAws value) => new AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(value); + + public static implicit operator AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsGoogle value) => new AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(value); + + public static implicit operator AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsOpenAi value) => new AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(value); + + class AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAiConverter : JsonConverter { + public override AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + using var document = JsonDocument.ParseValue(ref reader); + var discriminant0Present = document.RootElement.TryGetProperty("type", out var discriminant0); + if (discriminant0Present) { + switch (discriminant0.ToString()){ + case "aws_params": + return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to AiLlmEndpointParamsAws"); + case "google_params": + return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to AiLlmEndpointParamsGoogle"); + case "openai_params": + return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to AiLlmEndpointParamsOpenAi"); + } + } + throw new Exception($"Discriminant not found in json payload {document.RootElement} while try to converting to type {typeToConvert}"); + } + + public override void Write(Utf8JsonWriter writer, AiLlmEndpointParamsAwsOrAiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi? value, JsonSerializerOptions options) { + if (value?.AiLlmEndpointParamsAws != null) { + JsonSerializer.Serialize(writer, value.AiLlmEndpointParamsAws, options); + return; + } + if (value?.AiLlmEndpointParamsGoogle != null) { + JsonSerializer.Serialize(writer, value.AiLlmEndpointParamsGoogle, options); + return; + } + if (value?.AiLlmEndpointParamsOpenAi != null) { + JsonSerializer.Serialize(writer, value.AiLlmEndpointParamsOpenAi, options); + return; + } + } + + } + + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs b/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs deleted file mode 100644 index 0c015265..00000000 --- a/Box.Sdk.Gen/Schemas/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi/AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Box.Sdk.Gen; -using System; -using System.Text.Json; -using System.Text.Json.Serialization; -using Box.Sdk.Gen.Schemas; - -namespace Box.Sdk.Gen.Schemas { - [JsonConverter(typeof(AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAiConverter))] - public class AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi : OneOf { - public AiLlmEndpointParamsGoogle? AiLlmEndpointParamsGoogle => _val0; - - public AiLlmEndpointParamsOpenAi? AiLlmEndpointParamsOpenAi => _val1; - - public AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsGoogle value) : base(value) {} - - public AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsOpenAi value) : base(value) {} - - public static implicit operator AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsGoogle value) => new AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(value); - - public static implicit operator AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(AiLlmEndpointParamsOpenAi value) => new AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi(value); - - class AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAiConverter : JsonConverter { - public override AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - using var document = JsonDocument.ParseValue(ref reader); - var discriminant0Present = document.RootElement.TryGetProperty("type", out var discriminant0); - if (discriminant0Present) { - switch (discriminant0.ToString()){ - case "google_params": - return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to AiLlmEndpointParamsGoogle"); - case "openai_params": - return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to AiLlmEndpointParamsOpenAi"); - } - } - throw new Exception($"Discriminant not found in json payload {document.RootElement} while try to converting to type {typeToConvert}"); - } - - public override void Write(Utf8JsonWriter writer, AiLlmEndpointParamsGoogleOrAiLlmEndpointParamsOpenAi? value, JsonSerializerOptions options) { - if (value?.AiLlmEndpointParamsGoogle != null) { - JsonSerializer.Serialize(writer, value.AiLlmEndpointParamsGoogle, options); - return; - } - if (value?.AiLlmEndpointParamsOpenAi != null) { - JsonSerializer.Serialize(writer, value.AiLlmEndpointParamsOpenAi, options); - return; - } - } - - } - - } -} \ No newline at end of file