diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AdminApiKeyCreateResponse.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AdminApiKeyCreateResponse.g.cs index ff30bbc9..73150682 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AdminApiKeyCreateResponse.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AdminApiKeyCreateResponse.g.cs @@ -17,115 +17,34 @@ public class AdminApiKeyCreateResponseJsonConverter : global::System.Text.Json.S using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.AdminApiKey? adminApiKey = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKey), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKey).Name}"); + adminApiKey = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("created_at")) __score0++; - if (__jsonProps.Contains("expires_at")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("last_used_at")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("object")) __score0++; - if (__jsonProps.Contains("owner")) __score0++; - if (__jsonProps.Contains("owner.created_at")) __score0++; - if (__jsonProps.Contains("owner.id")) __score0++; - if (__jsonProps.Contains("owner.name")) __score0++; - if (__jsonProps.Contains("owner.object")) __score0++; - if (__jsonProps.Contains("owner.role")) __score0++; - if (__jsonProps.Contains("owner.type")) __score0++; - if (__jsonProps.Contains("redacted_value")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("value")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.AdminApiKey? adminApiKey = default; global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2? adminApiKeyCreateResponseVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKey), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKey).Name}"); - adminApiKey = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2).Name}"); - adminApiKeyCreateResponseVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2).Name}"); + adminApiKeyCreateResponseVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (adminApiKey == null && adminApiKeyCreateResponseVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKey), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKey).Name}"); - adminApiKey = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (adminApiKey == null && adminApiKeyCreateResponseVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2).Name}"); - adminApiKeyCreateResponseVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.AdminApiKeyCreateResponse( adminApiKey, @@ -144,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsAdminApiKey) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKey), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKey).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.AdminApiKey!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.AdminApiKey!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsAdminApiKeyCreateResponseVariant2) + if (value.IsAdminApiKeyCreateResponseVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.AdminApiKeyCreateResponseVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.AdminApiKeyCreateResponseVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.AdminApiKeyCreateResponseVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AllOf2.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AllOf2.g.cs index 7f6dc5d8..185188fb 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AllOf2.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.AllOf2.g.cs @@ -14,118 +14,36 @@ public class AllOfJsonConverter : global::System.Text.Json.Serialization options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); - using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) + + T1? value1 = default; + try { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); + value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - var __score0 = 0; + catch (global::System.Text.Json.JsonException) { - var __ti = typeInfoResolver.GetTypeInfo(typeof(T1), options); - if (__ti != null && __ti.Kind == global::System.Text.Json.Serialization.Metadata.JsonTypeInfoKind.Object) - { - foreach (var __prop in __ti.Properties) - { - if (__jsonProps.Contains(__prop.Name)) __score0++; - } - } } - var __score1 = 0; + catch (global::System.InvalidOperationException) { - var __ti = typeInfoResolver.GetTypeInfo(typeof(T2), options); - if (__ti != null && __ti.Kind == global::System.Text.Json.Serialization.Metadata.JsonTypeInfoKind.Object) - { - foreach (var __prop in __ti.Properties) - { - if (__jsonProps.Contains(__prop.Name)) __score1++; - } - } } - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - T1? value1 = default; T2? value2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - - else if (__bestIndex == 1) - { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); + value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (value1 == null && value2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - value1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (value1 == null && value2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - value2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.AllOf( value1, @@ -144,18 +62,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsValue1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Value1!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsValue2) + if (value.IsValue2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Value2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaComputerToolCallOutputResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaComputerToolCallOutputResource.g.cs index 5bbc960b..d834696e 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaComputerToolCallOutputResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaComputerToolCallOutputResource.g.cs @@ -17,113 +17,34 @@ public class BetaComputerToolCallOutputResourceJsonConverter : global::System.Te using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.BetaComputerToolCallOutput? computerToolCallOutput = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput).Name}"); + computerToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("acknowledged_safety_checks")) __score0++; - if (__jsonProps.Contains("agent")) __score0++; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("output")) __score0++; - if (__jsonProps.Contains("output.file_id")) __score0++; - if (__jsonProps.Contains("output.image_url")) __score0++; - if (__jsonProps.Contains("output.type")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaComputerToolCallOutput? computerToolCallOutput = default; global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2? betaComputerToolCallOutputResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput).Name}"); - computerToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2).Name}"); - betaComputerToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2).Name}"); + betaComputerToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (computerToolCallOutput == null && betaComputerToolCallOutputResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput).Name}"); - computerToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (computerToolCallOutput == null && betaComputerToolCallOutputResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2).Name}"); - betaComputerToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaComputerToolCallOutputResource( computerToolCallOutput, @@ -142,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsComputerToolCallOutput) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutput).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ComputerToolCallOutput!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ComputerToolCallOutput!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaComputerToolCallOutputResourceVariant2) + if (value.IsBetaComputerToolCallOutputResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaComputerToolCallOutputResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaComputerToolCallOutputResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaComputerToolCallOutputResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateModelResponseProperties.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateModelResponseProperties.g.cs index eeae132c..eaf36b6a 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateModelResponseProperties.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateModelResponseProperties.g.cs @@ -17,113 +17,34 @@ public class BetaCreateModelResponsePropertiesJsonConverter : global::System.Tex using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.BetaModelResponseProperties? betaModelResponseProperties = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); + betaModelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("metadata")) __score0++; - if (__jsonProps.Contains("prompt_cache_key")) __score0++; - if (__jsonProps.Contains("prompt_cache_retention")) __score0++; - if (__jsonProps.Contains("safety_identifier")) __score0++; - if (__jsonProps.Contains("service_tier")) __score0++; - if (__jsonProps.Contains("temperature")) __score0++; - if (__jsonProps.Contains("top_logprobs")) __score0++; - if (__jsonProps.Contains("top_p")) __score0++; - if (__jsonProps.Contains("user")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("prompt_cache_options")) __score1++; - if (__jsonProps.Contains("prompt_cache_options.mode")) __score1++; - if (__jsonProps.Contains("prompt_cache_options.ttl")) __score1++; - if (__jsonProps.Contains("top_logprobs")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaModelResponseProperties? betaModelResponseProperties = default; global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2? betaCreateModelResponsePropertiesVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); - betaModelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2).Name}"); - betaCreateModelResponsePropertiesVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2).Name}"); + betaCreateModelResponsePropertiesVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (betaModelResponseProperties == null && betaCreateModelResponsePropertiesVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); - betaModelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (betaModelResponseProperties == null && betaCreateModelResponsePropertiesVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2).Name}"); - betaCreateModelResponsePropertiesVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaCreateModelResponseProperties( betaModelResponseProperties, @@ -142,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsBetaModelResponseProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaModelResponseProperties!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaModelResponseProperties!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaCreateModelResponsePropertiesVariant2) + if (value.IsBetaCreateModelResponsePropertiesVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponsePropertiesVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaCreateModelResponsePropertiesVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaCreateModelResponsePropertiesVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateResponse.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateResponse.g.cs index 0848c906..7f307812 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateResponse.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCreateResponse.g.cs @@ -17,159 +17,48 @@ public class BetaCreateResponseJsonConverter : global::System.Text.Json.Serializ using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.BetaCreateModelResponseProperties? modelProperties = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties).Name}"); + modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - var __score1 = 0; - if (__jsonProps.Contains("background")) __score1++; - if (__jsonProps.Contains("max_tool_calls")) __score1++; - if (__jsonProps.Contains("model")) __score1++; - if (__jsonProps.Contains("previous_response_id")) __score1++; - if (__jsonProps.Contains("prompt")) __score1++; - if (__jsonProps.Contains("text")) __score1++; - if (__jsonProps.Contains("text.format")) __score1++; - if (__jsonProps.Contains("text.verbosity")) __score1++; - if (__jsonProps.Contains("tool_choice")) __score1++; - if (__jsonProps.Contains("tools")) __score1++; - var __score2 = 0; - if (__jsonProps.Contains("context_management")) __score2++; - if (__jsonProps.Contains("conversation")) __score2++; - if (__jsonProps.Contains("include")) __score2++; - if (__jsonProps.Contains("input")) __score2++; - if (__jsonProps.Contains("instructions")) __score2++; - if (__jsonProps.Contains("max_output_tokens")) __score2++; - if (__jsonProps.Contains("moderation")) __score2++; - if (__jsonProps.Contains("multi_agent")) __score2++; - if (__jsonProps.Contains("parallel_tool_calls")) __score2++; - if (__jsonProps.Contains("reasoning")) __score2++; - if (__jsonProps.Contains("store")) __score2++; - if (__jsonProps.Contains("stream")) __score2++; - if (__jsonProps.Contains("stream_options")) __score2++; - if (__jsonProps.Contains("truncation")) __score2++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - if (__score2 > __bestScore) { __bestScore = __score2; __bestIndex = 2; } - - global::tryAGI.OpenAI.BetaCreateModelResponseProperties? modelProperties = default; global::tryAGI.OpenAI.BetaResponseProperties? properties = default; - global::tryAGI.OpenAI.BetaCreateResponseVariant3? betaCreateResponseVariant3 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 2) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3).Name}"); - betaCreateResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); + properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (modelProperties == null && properties == null && betaCreateResponseVariant3 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (modelProperties == null && properties == null && betaCreateResponseVariant3 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - if (modelProperties == null && properties == null && betaCreateResponseVariant3 == null) + global::tryAGI.OpenAI.BetaCreateResponseVariant3? betaCreateResponseVariant3 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3).Name}"); + betaCreateResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3).Name}"); - betaCreateResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaCreateResponse( modelProperties, @@ -190,24 +79,64 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsModelProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateModelResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ModelProperties!.Value, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ModelProperties!.Value, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsProperties) + if (value.IsProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Properties!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Properties!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaCreateResponseVariant3) + if (value.IsBetaCreateResponseVariant3) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponseVariant3).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaCreateResponseVariant3!, typeInfo); + var __element2 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaCreateResponseVariant3!, typeInfo); + if (__element2.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element2.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallOutputResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallOutputResource.g.cs index e86186bc..10d25b4f 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallOutputResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallOutputResource.g.cs @@ -17,102 +17,34 @@ public class BetaCustomToolCallOutputResourceJsonConverter : global::System.Text using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.BetaCustomToolCallOutput? customToolCallOutput = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput).Name}"); + customToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("agent")) __score0++; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("output")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaCustomToolCallOutput? customToolCallOutput = default; global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2? betaCustomToolCallOutputResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput).Name}"); - customToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2).Name}"); - betaCustomToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2).Name}"); + betaCustomToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (customToolCallOutput == null && betaCustomToolCallOutputResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput).Name}"); - customToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (customToolCallOutput == null && betaCustomToolCallOutputResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2).Name}"); - betaCustomToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaCustomToolCallOutputResource( customToolCallOutput, @@ -131,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsCustomToolCallOutput) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutput).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CustomToolCallOutput!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CustomToolCallOutput!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaCustomToolCallOutputResourceVariant2) + if (value.IsBetaCustomToolCallOutputResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallOutputResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaCustomToolCallOutputResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaCustomToolCallOutputResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallResource.g.cs index b4e64678..5d19eb51 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaCustomToolCallResource.g.cs @@ -17,104 +17,34 @@ public class BetaCustomToolCallResourceJsonConverter : global::System.Text.Json. using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.BetaCustomToolCall? customToolCall = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCall).Name}"); + customToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("agent")) __score0++; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("input")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("namespace")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaCustomToolCall? customToolCall = default; global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2? betaCustomToolCallResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCall).Name}"); - customToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2).Name}"); - betaCustomToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2).Name}"); + betaCustomToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (customToolCall == null && betaCustomToolCallResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCall).Name}"); - customToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (customToolCall == null && betaCustomToolCallResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2).Name}"); - betaCustomToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaCustomToolCallResource( customToolCall, @@ -133,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsCustomToolCall) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCall).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CustomToolCall!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CustomToolCall!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaCustomToolCallResourceVariant2) + if (value.IsBetaCustomToolCallResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCustomToolCallResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaCustomToolCallResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaCustomToolCallResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallOutputResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallOutputResource.g.cs index 48dc42ee..0574081a 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallOutputResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallOutputResource.g.cs @@ -17,105 +17,34 @@ public class BetaFunctionToolCallOutputResourceJsonConverter : global::System.Te using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.BetaFunctionToolCallOutput? functionToolCallOutput = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput).Name}"); + functionToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("agent")) __score0++; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("namespace")) __score0++; - if (__jsonProps.Contains("output")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaFunctionToolCallOutput? functionToolCallOutput = default; global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2? betaFunctionToolCallOutputResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput).Name}"); - functionToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2).Name}"); - betaFunctionToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2).Name}"); + betaFunctionToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (functionToolCallOutput == null && betaFunctionToolCallOutputResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput).Name}"); - functionToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (functionToolCallOutput == null && betaFunctionToolCallOutputResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2).Name}"); - betaFunctionToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaFunctionToolCallOutputResource( functionToolCallOutput, @@ -134,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsFunctionToolCallOutput) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutput).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.FunctionToolCallOutput!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.FunctionToolCallOutput!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaFunctionToolCallOutputResourceVariant2) + if (value.IsBetaFunctionToolCallOutputResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallOutputResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaFunctionToolCallOutputResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaFunctionToolCallOutputResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallResource.g.cs index c66a8228..8bb4d938 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaFunctionToolCallResource.g.cs @@ -17,105 +17,34 @@ public class BetaFunctionToolCallResourceJsonConverter : global::System.Text.Jso using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.BetaFunctionToolCall? functionToolCall = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCall).Name}"); + functionToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("agent")) __score0++; - if (__jsonProps.Contains("arguments")) __score0++; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("namespace")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaFunctionToolCall? functionToolCall = default; global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2? betaFunctionToolCallResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCall).Name}"); - functionToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2).Name}"); - betaFunctionToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2).Name}"); + betaFunctionToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (functionToolCall == null && betaFunctionToolCallResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCall).Name}"); - functionToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (functionToolCall == null && betaFunctionToolCallResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2).Name}"); - betaFunctionToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaFunctionToolCallResource( functionToolCall, @@ -134,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsFunctionToolCall) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCall).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.FunctionToolCall!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.FunctionToolCall!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaFunctionToolCallResourceVariant2) + if (value.IsBetaFunctionToolCallResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaFunctionToolCallResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaFunctionToolCallResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaFunctionToolCallResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaInputMessageResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaInputMessageResource.g.cs index 9b38eec6..26c0d2bb 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaInputMessageResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaInputMessageResource.g.cs @@ -17,99 +17,34 @@ public class BetaInputMessageResourceJsonConverter : global::System.Text.Json.Se using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.BetaInputMessage? inputMessage = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessage).Name}"); + inputMessage = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("agent")) __score0++; - if (__jsonProps.Contains("content")) __score0++; - if (__jsonProps.Contains("role")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("id")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaInputMessage? inputMessage = default; global::tryAGI.OpenAI.BetaInputMessageResourceVariant2? betaInputMessageResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessage).Name}"); - inputMessage = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2).Name}"); - betaInputMessageResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2).Name}"); + betaInputMessageResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (inputMessage == null && betaInputMessageResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessage).Name}"); - inputMessage = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (inputMessage == null && betaInputMessageResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2).Name}"); - betaInputMessageResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaInputMessageResource( inputMessage, @@ -128,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsInputMessage) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessage).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.InputMessage!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.InputMessage!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaInputMessageResourceVariant2) + if (value.IsBetaInputMessageResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaInputMessageResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaInputMessageResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaInputMessageResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponse.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponse.g.cs index 1a1fdbb7..a97d8fdc 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponse.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponse.g.cs @@ -17,179 +17,48 @@ public class BetaResponseJsonConverter : global::System.Text.Json.Serialization. using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.BetaModelResponseProperties? modelProperties = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); + modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("metadata")) __score0++; - if (__jsonProps.Contains("prompt_cache_key")) __score0++; - if (__jsonProps.Contains("prompt_cache_retention")) __score0++; - if (__jsonProps.Contains("safety_identifier")) __score0++; - if (__jsonProps.Contains("service_tier")) __score0++; - if (__jsonProps.Contains("temperature")) __score0++; - if (__jsonProps.Contains("top_logprobs")) __score0++; - if (__jsonProps.Contains("top_p")) __score0++; - if (__jsonProps.Contains("user")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("background")) __score1++; - if (__jsonProps.Contains("max_tool_calls")) __score1++; - if (__jsonProps.Contains("model")) __score1++; - if (__jsonProps.Contains("previous_response_id")) __score1++; - if (__jsonProps.Contains("prompt")) __score1++; - if (__jsonProps.Contains("text")) __score1++; - if (__jsonProps.Contains("text.format")) __score1++; - if (__jsonProps.Contains("text.verbosity")) __score1++; - if (__jsonProps.Contains("tool_choice")) __score1++; - if (__jsonProps.Contains("tools")) __score1++; - var __score2 = 0; - if (__jsonProps.Contains("completed_at")) __score2++; - if (__jsonProps.Contains("conversation")) __score2++; - if (__jsonProps.Contains("created_at")) __score2++; - if (__jsonProps.Contains("error")) __score2++; - if (__jsonProps.Contains("id")) __score2++; - if (__jsonProps.Contains("incomplete_details")) __score2++; - if (__jsonProps.Contains("instructions")) __score2++; - if (__jsonProps.Contains("max_output_tokens")) __score2++; - if (__jsonProps.Contains("moderation")) __score2++; - if (__jsonProps.Contains("object")) __score2++; - if (__jsonProps.Contains("output")) __score2++; - if (__jsonProps.Contains("output_text")) __score2++; - if (__jsonProps.Contains("parallel_tool_calls")) __score2++; - if (__jsonProps.Contains("prompt_cache_options")) __score2++; - if (__jsonProps.Contains("prompt_cache_options.mode")) __score2++; - if (__jsonProps.Contains("prompt_cache_options.ttl")) __score2++; - if (__jsonProps.Contains("reasoning")) __score2++; - if (__jsonProps.Contains("status")) __score2++; - if (__jsonProps.Contains("truncation")) __score2++; - if (__jsonProps.Contains("usage")) __score2++; - if (__jsonProps.Contains("usage.input_tokens")) __score2++; - if (__jsonProps.Contains("usage.input_tokens_details")) __score2++; - if (__jsonProps.Contains("usage.output_tokens")) __score2++; - if (__jsonProps.Contains("usage.output_tokens_details")) __score2++; - if (__jsonProps.Contains("usage.total_tokens")) __score2++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - if (__score2 > __bestScore) { __bestScore = __score2; __bestIndex = 2; } - - global::tryAGI.OpenAI.BetaModelResponseProperties? modelProperties = default; global::tryAGI.OpenAI.BetaResponseProperties? properties = default; - global::tryAGI.OpenAI.BetaResponseVariant3? betaResponseVariant3 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 2) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseVariant3).Name}"); - betaResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); + properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (modelProperties == null && properties == null && betaResponseVariant3 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (modelProperties == null && properties == null && betaResponseVariant3 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - if (modelProperties == null && properties == null && betaResponseVariant3 == null) + global::tryAGI.OpenAI.BetaResponseVariant3? betaResponseVariant3 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseVariant3).Name}"); + betaResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseVariant3).Name}"); - betaResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaResponse( modelProperties, @@ -210,24 +79,64 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsModelProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaModelResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ModelProperties!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ModelProperties!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsProperties) + if (value.IsProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Properties!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Properties!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaResponseVariant3) + if (value.IsBetaResponseVariant3) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponseVariant3).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaResponseVariant3!, typeInfo); + var __element2 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaResponseVariant3!, typeInfo); + if (__element2.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element2.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponsesClientEventResponseCreate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponsesClientEventResponseCreate.g.cs index a11d1276..5466adbb 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponsesClientEventResponseCreate.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.BetaResponsesClientEventResponseCreate.g.cs @@ -17,94 +17,34 @@ public class BetaResponsesClientEventResponseCreateJsonConverter : global::Syste using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1? betaResponsesClientEventResponseCreateVariant1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1).Name}"); + betaResponsesClientEventResponseCreateVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1? betaResponsesClientEventResponseCreateVariant1 = default; global::tryAGI.OpenAI.BetaCreateResponse? betaCreateResponse = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1).Name}"); - betaResponsesClientEventResponseCreateVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponse).Name}"); - betaCreateResponse = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponse).Name}"); + betaCreateResponse = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (betaResponsesClientEventResponseCreateVariant1 == null && betaCreateResponse == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1).Name}"); - betaResponsesClientEventResponseCreateVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (betaResponsesClientEventResponseCreateVariant1 == null && betaCreateResponse == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponse).Name}"); - betaCreateResponse = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreate( betaResponsesClientEventResponseCreateVariant1, @@ -123,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsBetaResponsesClientEventResponseCreateVariant1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaResponsesClientEventResponseCreateVariant1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaResponsesClientEventResponseCreateVariant1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaResponsesClientEventResponseCreateVariant1!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsBetaCreateResponse) + if (value.IsBetaCreateResponse) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.BetaCreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.BetaCreateResponse).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.BetaCreateResponse!.Value, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.BetaCreateResponse!.Value, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ComputerToolCallOutputResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ComputerToolCallOutputResource.g.cs index 66be6491..f3a3e587 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ComputerToolCallOutputResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ComputerToolCallOutputResource.g.cs @@ -17,112 +17,34 @@ public class ComputerToolCallOutputResourceJsonConverter : global::System.Text.J using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.ComputerToolCallOutput? computerToolCallOutput = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutput).Name}"); + computerToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("acknowledged_safety_checks")) __score0++; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("output")) __score0++; - if (__jsonProps.Contains("output.file_id")) __score0++; - if (__jsonProps.Contains("output.image_url")) __score0++; - if (__jsonProps.Contains("output.type")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.ComputerToolCallOutput? computerToolCallOutput = default; global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2? computerToolCallOutputResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutput).Name}"); - computerToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2).Name}"); - computerToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2).Name}"); + computerToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (computerToolCallOutput == null && computerToolCallOutputResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutput).Name}"); - computerToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (computerToolCallOutput == null && computerToolCallOutputResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2).Name}"); - computerToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.ComputerToolCallOutputResource( computerToolCallOutput, @@ -141,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsComputerToolCallOutput) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutput).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ComputerToolCallOutput!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ComputerToolCallOutput!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsComputerToolCallOutputResourceVariant2) + if (value.IsComputerToolCallOutputResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ComputerToolCallOutputResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ComputerToolCallOutputResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ComputerToolCallOutputResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateChatCompletionRequest.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateChatCompletionRequest.g.cs index 53d4f86a..d39ecefa 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateChatCompletionRequest.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateChatCompletionRequest.g.cs @@ -17,132 +17,34 @@ public class CreateChatCompletionRequestJsonConverter : global::System.Text.Json using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.CreateModelResponseProperties? modelResponseProperties = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); + modelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - var __score1 = 0; - if (__jsonProps.Contains("audio")) __score1++; - if (__jsonProps.Contains("audio.format")) __score1++; - if (__jsonProps.Contains("audio.voice")) __score1++; - if (__jsonProps.Contains("frequency_penalty")) __score1++; - if (__jsonProps.Contains("function_call")) __score1++; - if (__jsonProps.Contains("functions")) __score1++; - if (__jsonProps.Contains("logit_bias")) __score1++; - if (__jsonProps.Contains("logprobs")) __score1++; - if (__jsonProps.Contains("max_completion_tokens")) __score1++; - if (__jsonProps.Contains("max_tokens")) __score1++; - if (__jsonProps.Contains("messages")) __score1++; - if (__jsonProps.Contains("modalities")) __score1++; - if (__jsonProps.Contains("model")) __score1++; - if (__jsonProps.Contains("moderation")) __score1++; - if (__jsonProps.Contains("n")) __score1++; - if (__jsonProps.Contains("parallel_tool_calls")) __score1++; - if (__jsonProps.Contains("prediction")) __score1++; - if (__jsonProps.Contains("presence_penalty")) __score1++; - if (__jsonProps.Contains("reasoning_effort")) __score1++; - if (__jsonProps.Contains("response_format")) __score1++; - if (__jsonProps.Contains("seed")) __score1++; - if (__jsonProps.Contains("stop")) __score1++; - if (__jsonProps.Contains("store")) __score1++; - if (__jsonProps.Contains("stream")) __score1++; - if (__jsonProps.Contains("stream_options")) __score1++; - if (__jsonProps.Contains("tool_choice")) __score1++; - if (__jsonProps.Contains("tools")) __score1++; - if (__jsonProps.Contains("top_logprobs")) __score1++; - if (__jsonProps.Contains("verbosity")) __score1++; - if (__jsonProps.Contains("web_search_options")) __score1++; - if (__jsonProps.Contains("web_search_options.search_context_size")) __score1++; - if (__jsonProps.Contains("web_search_options.user_location")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.CreateModelResponseProperties? modelResponseProperties = default; global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2? createChatCompletionRequestVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); - modelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2).Name}"); - createChatCompletionRequestVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2).Name}"); + createChatCompletionRequestVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (modelResponseProperties == null && createChatCompletionRequestVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); - modelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (modelResponseProperties == null && createChatCompletionRequestVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2).Name}"); - createChatCompletionRequestVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.CreateChatCompletionRequest( modelResponseProperties, @@ -161,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsModelResponseProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ModelResponseProperties!.Value, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ModelResponseProperties!.Value, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsCreateChatCompletionRequestVariant2) + if (value.IsCreateChatCompletionRequestVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateChatCompletionRequestVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CreateChatCompletionRequestVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CreateChatCompletionRequestVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateModelResponseProperties.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateModelResponseProperties.g.cs index 9b98b027..078c056f 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateModelResponseProperties.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateModelResponseProperties.g.cs @@ -17,113 +17,34 @@ public class CreateModelResponsePropertiesJsonConverter : global::System.Text.Js using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.ModelResponseProperties? modelResponseProperties = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); + modelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("metadata")) __score0++; - if (__jsonProps.Contains("prompt_cache_key")) __score0++; - if (__jsonProps.Contains("prompt_cache_retention")) __score0++; - if (__jsonProps.Contains("safety_identifier")) __score0++; - if (__jsonProps.Contains("service_tier")) __score0++; - if (__jsonProps.Contains("temperature")) __score0++; - if (__jsonProps.Contains("top_logprobs")) __score0++; - if (__jsonProps.Contains("top_p")) __score0++; - if (__jsonProps.Contains("user")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("prompt_cache_options")) __score1++; - if (__jsonProps.Contains("prompt_cache_options.mode")) __score1++; - if (__jsonProps.Contains("prompt_cache_options.ttl")) __score1++; - if (__jsonProps.Contains("top_logprobs")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.ModelResponseProperties? modelResponseProperties = default; global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2? createModelResponsePropertiesVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); - modelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2).Name}"); - createModelResponsePropertiesVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2).Name}"); + createModelResponsePropertiesVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (modelResponseProperties == null && createModelResponsePropertiesVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); - modelResponseProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (modelResponseProperties == null && createModelResponsePropertiesVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2).Name}"); - createModelResponsePropertiesVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.CreateModelResponseProperties( modelResponseProperties, @@ -142,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsModelResponseProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ModelResponseProperties!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ModelResponseProperties!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsCreateModelResponsePropertiesVariant2) + if (value.IsCreateModelResponsePropertiesVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponsePropertiesVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CreateModelResponsePropertiesVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CreateModelResponsePropertiesVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateResponse.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateResponse.g.cs index a3dcbc60..caa0845a 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateResponse.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CreateResponse.g.cs @@ -17,158 +17,48 @@ public class CreateResponseJsonConverter : global::System.Text.Json.Serializatio using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.CreateModelResponseProperties? modelProperties = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); + modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - var __score1 = 0; - if (__jsonProps.Contains("background")) __score1++; - if (__jsonProps.Contains("max_tool_calls")) __score1++; - if (__jsonProps.Contains("model")) __score1++; - if (__jsonProps.Contains("previous_response_id")) __score1++; - if (__jsonProps.Contains("prompt")) __score1++; - if (__jsonProps.Contains("text")) __score1++; - if (__jsonProps.Contains("text.format")) __score1++; - if (__jsonProps.Contains("text.verbosity")) __score1++; - if (__jsonProps.Contains("tool_choice")) __score1++; - if (__jsonProps.Contains("tools")) __score1++; - var __score2 = 0; - if (__jsonProps.Contains("context_management")) __score2++; - if (__jsonProps.Contains("conversation")) __score2++; - if (__jsonProps.Contains("include")) __score2++; - if (__jsonProps.Contains("input")) __score2++; - if (__jsonProps.Contains("instructions")) __score2++; - if (__jsonProps.Contains("max_output_tokens")) __score2++; - if (__jsonProps.Contains("moderation")) __score2++; - if (__jsonProps.Contains("parallel_tool_calls")) __score2++; - if (__jsonProps.Contains("reasoning")) __score2++; - if (__jsonProps.Contains("store")) __score2++; - if (__jsonProps.Contains("stream")) __score2++; - if (__jsonProps.Contains("stream_options")) __score2++; - if (__jsonProps.Contains("truncation")) __score2++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - if (__score2 > __bestScore) { __bestScore = __score2; __bestIndex = 2; } - - global::tryAGI.OpenAI.CreateModelResponseProperties? modelProperties = default; global::tryAGI.OpenAI.ResponseProperties? properties = default; - global::tryAGI.OpenAI.CreateResponseVariant3? createResponseVariant3 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 2) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponseVariant3).Name}"); - createResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); + properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (modelProperties == null && properties == null && createResponseVariant3 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (modelProperties == null && properties == null && createResponseVariant3 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - if (modelProperties == null && properties == null && createResponseVariant3 == null) + global::tryAGI.OpenAI.CreateResponseVariant3? createResponseVariant3 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponseVariant3).Name}"); + createResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponseVariant3).Name}"); - createResponseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.CreateResponse( modelProperties, @@ -189,24 +79,64 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsModelProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateModelResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ModelProperties!.Value, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ModelProperties!.Value, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsProperties) + if (value.IsProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Properties!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Properties!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsCreateResponseVariant3) + if (value.IsCreateResponseVariant3) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponseVariant3).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CreateResponseVariant3!, typeInfo); + var __element2 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CreateResponseVariant3!, typeInfo); + if (__element2.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element2.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallOutputResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallOutputResource.g.cs index 03d1f0f6..e464512c 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallOutputResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallOutputResource.g.cs @@ -17,101 +17,34 @@ public class CustomToolCallOutputResourceJsonConverter : global::System.Text.Jso using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.CustomToolCallOutput? customToolCallOutput = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutput).Name}"); + customToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("output")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.CustomToolCallOutput? customToolCallOutput = default; global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2? customToolCallOutputResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutput).Name}"); - customToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2).Name}"); - customToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2).Name}"); + customToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (customToolCallOutput == null && customToolCallOutputResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutput).Name}"); - customToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (customToolCallOutput == null && customToolCallOutputResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2).Name}"); - customToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.CustomToolCallOutputResource( customToolCallOutput, @@ -130,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsCustomToolCallOutput) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutput).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CustomToolCallOutput!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CustomToolCallOutput!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsCustomToolCallOutputResourceVariant2) + if (value.IsCustomToolCallOutputResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallOutputResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CustomToolCallOutputResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CustomToolCallOutputResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallResource.g.cs index 92c2a168..17305a4e 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.CustomToolCallResource.g.cs @@ -17,103 +17,34 @@ public class CustomToolCallResourceJsonConverter : global::System.Text.Json.Seri using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.CustomToolCall? customToolCall = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCall).Name}"); + customToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("input")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("namespace")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.CustomToolCall? customToolCall = default; global::tryAGI.OpenAI.CustomToolCallResourceVariant2? customToolCallResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCall).Name}"); - customToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2).Name}"); - customToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2).Name}"); + customToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (customToolCall == null && customToolCallResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCall).Name}"); - customToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (customToolCall == null && customToolCallResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2).Name}"); - customToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.CustomToolCallResource( customToolCall, @@ -132,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsCustomToolCall) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCall).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CustomToolCall!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CustomToolCall!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsCustomToolCallResourceVariant2) + if (value.IsCustomToolCallResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CustomToolCallResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CustomToolCallResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CustomToolCallResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.DeletedConversation.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.DeletedConversation.g.cs index ccf23b4c..47173311 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.DeletedConversation.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.DeletedConversation.g.cs @@ -17,61 +17,20 @@ public class DeletedConversationJsonConverter : global::System.Text.Json.Seriali using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - - } - } - - var __score0 = 0; - if (__jsonProps.Contains("deleted")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("object")) __score0++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } global::tryAGI.OpenAI.DeletedConversationResource? resource = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.DeletedConversationResource), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.DeletedConversationResource).Name}"); - resource = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.DeletedConversationResource), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.DeletedConversationResource).Name}"); + resource = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (resource == null) + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.DeletedConversationResource), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.DeletedConversationResource).Name}"); - resource = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.DeletedConversation( resource ); @@ -88,12 +47,28 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsResource) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.DeletedConversationResource), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.DeletedConversationResource).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Resource!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Resource!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderLabelModel.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderLabelModel.g.cs index 841782b7..d2a0f27f 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderLabelModel.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderLabelModel.g.cs @@ -17,64 +17,20 @@ public class EvalGraderLabelModelJsonConverter : global::System.Text.Json.Serial using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - - } - } - - var __score0 = 0; - if (__jsonProps.Contains("input")) __score0++; - if (__jsonProps.Contains("labels")) __score0++; - if (__jsonProps.Contains("model")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("passing_labels")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } global::tryAGI.OpenAI.GraderLabelModel? labelModelGrader = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderLabelModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderLabelModel).Name}"); - labelModelGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderLabelModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderLabelModel).Name}"); + labelModelGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (labelModelGrader == null) + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderLabelModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderLabelModel).Name}"); - labelModelGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.EvalGraderLabelModel( labelModelGrader ); @@ -91,12 +47,28 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsLabelModelGrader) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderLabelModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderLabelModel).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.LabelModelGrader!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.LabelModelGrader!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderPython.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderPython.g.cs index d4d2a89a..83d4b16f 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderPython.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderPython.g.cs @@ -17,98 +17,34 @@ public class EvalGraderPythonJsonConverter : global::System.Text.Json.Serializat using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.GraderPython? pythonGrader = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderPython), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderPython).Name}"); + pythonGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("image_tag")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("source")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("pass_threshold")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.GraderPython? pythonGrader = default; global::tryAGI.OpenAI.EvalGraderPythonVariant2? evalGraderPythonVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderPython), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderPython).Name}"); - pythonGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2).Name}"); - evalGraderPythonVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2).Name}"); + evalGraderPythonVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (pythonGrader == null && evalGraderPythonVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderPython), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderPython).Name}"); - pythonGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (pythonGrader == null && evalGraderPythonVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2).Name}"); - evalGraderPythonVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.EvalGraderPython( pythonGrader, @@ -127,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsPythonGrader) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderPython), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderPython).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.PythonGrader!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.PythonGrader!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsEvalGraderPythonVariant2) + if (value.IsEvalGraderPythonVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderPythonVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.EvalGraderPythonVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.EvalGraderPythonVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderScoreModel.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderScoreModel.g.cs index f04af1e3..67d0f919 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderScoreModel.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderScoreModel.g.cs @@ -17,112 +17,34 @@ public class EvalGraderScoreModelJsonConverter : global::System.Text.Json.Serial using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.GraderScoreModel? scoreModelGrader = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderScoreModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderScoreModel).Name}"); + scoreModelGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("input")) __score0++; - if (__jsonProps.Contains("model")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("range")) __score0++; - if (__jsonProps.Contains("sampling_params")) __score0++; - if (__jsonProps.Contains("sampling_params.max_completions_tokens")) __score0++; - if (__jsonProps.Contains("sampling_params.reasoning_effort")) __score0++; - if (__jsonProps.Contains("sampling_params.seed")) __score0++; - if (__jsonProps.Contains("sampling_params.temperature")) __score0++; - if (__jsonProps.Contains("sampling_params.top_p")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("pass_threshold")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.GraderScoreModel? scoreModelGrader = default; global::tryAGI.OpenAI.EvalGraderScoreModelVariant2? evalGraderScoreModelVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderScoreModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderScoreModel).Name}"); - scoreModelGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2).Name}"); - evalGraderScoreModelVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2).Name}"); + evalGraderScoreModelVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (scoreModelGrader == null && evalGraderScoreModelVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderScoreModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderScoreModel).Name}"); - scoreModelGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (scoreModelGrader == null && evalGraderScoreModelVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2).Name}"); - evalGraderScoreModelVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.EvalGraderScoreModel( scoreModelGrader, @@ -141,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsScoreModelGrader) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderScoreModel), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderScoreModel).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ScoreModelGrader!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ScoreModelGrader!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsEvalGraderScoreModelVariant2) + if (value.IsEvalGraderScoreModelVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderScoreModelVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.EvalGraderScoreModelVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.EvalGraderScoreModelVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderStringCheck.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderStringCheck.g.cs index 274201fd..1674fb2b 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderStringCheck.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderStringCheck.g.cs @@ -17,63 +17,20 @@ public class EvalGraderStringCheckJsonConverter : global::System.Text.Json.Seria using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - - } - } - - var __score0 = 0; - if (__jsonProps.Contains("input")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("operation")) __score0++; - if (__jsonProps.Contains("reference")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } global::tryAGI.OpenAI.GraderStringCheck? stringCheckGrader = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderStringCheck), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderStringCheck).Name}"); - stringCheckGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderStringCheck), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderStringCheck).Name}"); + stringCheckGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (stringCheckGrader == null) + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderStringCheck), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderStringCheck).Name}"); - stringCheckGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.EvalGraderStringCheck( stringCheckGrader ); @@ -90,12 +47,28 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsStringCheckGrader) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderStringCheck), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderStringCheck).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.StringCheckGrader!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.StringCheckGrader!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderTextSimilarity.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderTextSimilarity.g.cs index 738dac62..e4265b55 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderTextSimilarity.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.EvalGraderTextSimilarity.g.cs @@ -17,99 +17,34 @@ public class EvalGraderTextSimilarityJsonConverter : global::System.Text.Json.Se using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.GraderTextSimilarity? textSimilarityGrader = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderTextSimilarity), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderTextSimilarity).Name}"); + textSimilarityGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("evaluation_metric")) __score0++; - if (__jsonProps.Contains("input")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("reference")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("pass_threshold")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.GraderTextSimilarity? textSimilarityGrader = default; global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2? evalGraderTextSimilarityVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderTextSimilarity), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderTextSimilarity).Name}"); - textSimilarityGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2).Name}"); - evalGraderTextSimilarityVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2).Name}"); + evalGraderTextSimilarityVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (textSimilarityGrader == null && evalGraderTextSimilarityVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderTextSimilarity), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderTextSimilarity).Name}"); - textSimilarityGrader = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (textSimilarityGrader == null && evalGraderTextSimilarityVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2).Name}"); - evalGraderTextSimilarityVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.EvalGraderTextSimilarity( textSimilarityGrader, @@ -128,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsTextSimilarityGrader) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.GraderTextSimilarity), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.GraderTextSimilarity).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.TextSimilarityGrader!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.TextSimilarityGrader!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsEvalGraderTextSimilarityVariant2) + if (value.IsEvalGraderTextSimilarityVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.EvalGraderTextSimilarityVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.EvalGraderTextSimilarityVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.EvalGraderTextSimilarityVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FineTuneChatCompletionRequestAssistantMessage.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FineTuneChatCompletionRequestAssistantMessage.g.cs index ed05a404..53ba1531 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FineTuneChatCompletionRequestAssistantMessage.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FineTuneChatCompletionRequestAssistantMessage.g.cs @@ -17,101 +17,34 @@ public class FineTuneChatCompletionRequestAssistantMessageJsonConverter : global using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage? assistantMessage1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage).Name}"); + assistantMessage1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("weight")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("audio")) __score1++; - if (__jsonProps.Contains("content")) __score1++; - if (__jsonProps.Contains("function_call")) __score1++; - if (__jsonProps.Contains("name")) __score1++; - if (__jsonProps.Contains("refusal")) __score1++; - if (__jsonProps.Contains("role")) __score1++; - if (__jsonProps.Contains("tool_calls")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage? assistantMessage1 = default; global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage? assistantMessage2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage).Name}"); - assistantMessage1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage).Name}"); - assistantMessage2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage).Name}"); + assistantMessage2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (assistantMessage1 == null && assistantMessage2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage).Name}"); - assistantMessage1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (assistantMessage1 == null && assistantMessage2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage).Name}"); - assistantMessage2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessage( assistantMessage1, @@ -130,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsAssistantMessage1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FineTuneChatCompletionRequestAssistantMessageAssistantMessage).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.AssistantMessage1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.AssistantMessage1!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsAssistantMessage2) + if (value.IsAssistantMessage2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ChatCompletionRequestAssistantMessage).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.AssistantMessage2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.AssistantMessage2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallOutputResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallOutputResource.g.cs index 76debfcd..5ff4ccf3 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallOutputResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallOutputResource.g.cs @@ -17,104 +17,34 @@ public class FunctionToolCallOutputResourceJsonConverter : global::System.Text.J using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.FunctionToolCallOutput? functionToolCallOutput = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutput).Name}"); + functionToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("namespace")) __score0++; - if (__jsonProps.Contains("output")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.FunctionToolCallOutput? functionToolCallOutput = default; global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2? functionToolCallOutputResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutput).Name}"); - functionToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2).Name}"); - functionToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2).Name}"); + functionToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (functionToolCallOutput == null && functionToolCallOutputResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutput).Name}"); - functionToolCallOutput = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (functionToolCallOutput == null && functionToolCallOutputResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2).Name}"); - functionToolCallOutputResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.FunctionToolCallOutputResource( functionToolCallOutput, @@ -133,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsFunctionToolCallOutput) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutput), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutput).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.FunctionToolCallOutput!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.FunctionToolCallOutput!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsFunctionToolCallOutputResourceVariant2) + if (value.IsFunctionToolCallOutputResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallOutputResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.FunctionToolCallOutputResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.FunctionToolCallOutputResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallResource.g.cs index c6d73660..9bb46cbe 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.FunctionToolCallResource.g.cs @@ -17,104 +17,34 @@ public class FunctionToolCallResourceJsonConverter : global::System.Text.Json.Se using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.FunctionToolCall? functionToolCall = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCall).Name}"); + functionToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("arguments")) __score0++; - if (__jsonProps.Contains("call_id")) __score0++; - if (__jsonProps.Contains("caller")) __score0++; - if (__jsonProps.Contains("id")) __score0++; - if (__jsonProps.Contains("name")) __score0++; - if (__jsonProps.Contains("namespace")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("created_by")) __score1++; - if (__jsonProps.Contains("id")) __score1++; - if (__jsonProps.Contains("status")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.FunctionToolCall? functionToolCall = default; global::tryAGI.OpenAI.FunctionToolCallResourceVariant2? functionToolCallResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCall).Name}"); - functionToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2).Name}"); - functionToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2).Name}"); + functionToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (functionToolCall == null && functionToolCallResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCall).Name}"); - functionToolCall = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (functionToolCall == null && functionToolCallResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2).Name}"); - functionToolCallResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.FunctionToolCallResource( functionToolCall, @@ -133,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsFunctionToolCall) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCall), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCall).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.FunctionToolCall!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.FunctionToolCall!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsFunctionToolCallResourceVariant2) + if (value.IsFunctionToolCallResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.FunctionToolCallResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.FunctionToolCallResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.FunctionToolCallResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.InputMessageResource.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.InputMessageResource.g.cs index 0f249724..11d3ce80 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.InputMessageResource.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.InputMessageResource.g.cs @@ -17,98 +17,34 @@ public class InputMessageResourceJsonConverter : global::System.Text.Json.Serial using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.InputMessage? inputMessage = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessage).Name}"); + inputMessage = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("content")) __score0++; - if (__jsonProps.Contains("role")) __score0++; - if (__jsonProps.Contains("status")) __score0++; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("id")) __score1++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.InputMessage? inputMessage = default; global::tryAGI.OpenAI.InputMessageResourceVariant2? inputMessageResourceVariant2 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessage).Name}"); - inputMessage = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2).Name}"); - inputMessageResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2).Name}"); + inputMessageResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (inputMessage == null && inputMessageResourceVariant2 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessage).Name}"); - inputMessage = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (inputMessage == null && inputMessageResourceVariant2 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2).Name}"); - inputMessageResourceVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.InputMessageResource( inputMessage, @@ -127,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsInputMessage) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessage), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessage).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.InputMessage!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.InputMessage!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsInputMessageResourceVariant2) + if (value.IsInputMessageResourceVariant2) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.InputMessageResourceVariant2).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.InputMessageResourceVariant2!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.InputMessageResourceVariant2!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.Response.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.Response.g.cs index 74a88dab..03991894 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.Response.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.Response.g.cs @@ -17,179 +17,48 @@ public class ResponseJsonConverter : global::System.Text.Json.Serialization.Json using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); - } - } - } + global::tryAGI.OpenAI.ModelResponseProperties? modelProperties = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); + modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("metadata")) __score0++; - if (__jsonProps.Contains("prompt_cache_key")) __score0++; - if (__jsonProps.Contains("prompt_cache_retention")) __score0++; - if (__jsonProps.Contains("safety_identifier")) __score0++; - if (__jsonProps.Contains("service_tier")) __score0++; - if (__jsonProps.Contains("temperature")) __score0++; - if (__jsonProps.Contains("top_logprobs")) __score0++; - if (__jsonProps.Contains("top_p")) __score0++; - if (__jsonProps.Contains("user")) __score0++; - var __score1 = 0; - if (__jsonProps.Contains("background")) __score1++; - if (__jsonProps.Contains("max_tool_calls")) __score1++; - if (__jsonProps.Contains("model")) __score1++; - if (__jsonProps.Contains("previous_response_id")) __score1++; - if (__jsonProps.Contains("prompt")) __score1++; - if (__jsonProps.Contains("text")) __score1++; - if (__jsonProps.Contains("text.format")) __score1++; - if (__jsonProps.Contains("text.verbosity")) __score1++; - if (__jsonProps.Contains("tool_choice")) __score1++; - if (__jsonProps.Contains("tools")) __score1++; - var __score2 = 0; - if (__jsonProps.Contains("completed_at")) __score2++; - if (__jsonProps.Contains("conversation")) __score2++; - if (__jsonProps.Contains("created_at")) __score2++; - if (__jsonProps.Contains("error")) __score2++; - if (__jsonProps.Contains("id")) __score2++; - if (__jsonProps.Contains("incomplete_details")) __score2++; - if (__jsonProps.Contains("instructions")) __score2++; - if (__jsonProps.Contains("max_output_tokens")) __score2++; - if (__jsonProps.Contains("moderation")) __score2++; - if (__jsonProps.Contains("object")) __score2++; - if (__jsonProps.Contains("output")) __score2++; - if (__jsonProps.Contains("output_text")) __score2++; - if (__jsonProps.Contains("parallel_tool_calls")) __score2++; - if (__jsonProps.Contains("prompt_cache_options")) __score2++; - if (__jsonProps.Contains("prompt_cache_options.mode")) __score2++; - if (__jsonProps.Contains("prompt_cache_options.ttl")) __score2++; - if (__jsonProps.Contains("reasoning")) __score2++; - if (__jsonProps.Contains("status")) __score2++; - if (__jsonProps.Contains("truncation")) __score2++; - if (__jsonProps.Contains("usage")) __score2++; - if (__jsonProps.Contains("usage.input_tokens")) __score2++; - if (__jsonProps.Contains("usage.input_tokens_details")) __score2++; - if (__jsonProps.Contains("usage.output_tokens")) __score2++; - if (__jsonProps.Contains("usage.output_tokens_details")) __score2++; - if (__jsonProps.Contains("usage.total_tokens")) __score2++; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - if (__score2 > __bestScore) { __bestScore = __score2; __bestIndex = 2; } - - global::tryAGI.OpenAI.ModelResponseProperties? modelProperties = default; global::tryAGI.OpenAI.ResponseProperties? properties = default; - global::tryAGI.OpenAI.ResponseVariant3? responseVariant3 = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 2) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseVariant3).Name}"); - responseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); + properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (modelProperties == null && properties == null && responseVariant3 == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); - modelProperties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (modelProperties == null && properties == null && responseVariant3 == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); - properties = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - if (modelProperties == null && properties == null && responseVariant3 == null) + global::tryAGI.OpenAI.ResponseVariant3? responseVariant3 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseVariant3).Name}"); + responseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseVariant3).Name}"); - responseVariant3 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.Response( modelProperties, @@ -210,24 +79,64 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsModelProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ModelResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ModelResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ModelProperties!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ModelProperties!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsProperties) + if (value.IsProperties) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseProperties), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseProperties).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.Properties!, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.Properties!, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsResponseVariant3) + if (value.IsResponseVariant3) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponseVariant3), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponseVariant3).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ResponseVariant3!, typeInfo); + var __element2 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ResponseVariant3!, typeInfo); + if (__element2.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element2.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponsesClientEventResponseCreate.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponsesClientEventResponseCreate.g.cs index 3cea7f97..77a7976e 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponsesClientEventResponseCreate.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonConverters.ResponsesClientEventResponseCreate.g.cs @@ -17,94 +17,34 @@ public class ResponsesClientEventResponseCreateJsonConverter : global::System.Te using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); var __rawJson = __jsonDocument.RootElement.GetRawText(); - var __jsonProps = new global::System.Collections.Generic.HashSet(); - if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) - { - foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) - { - __jsonProps.Add(__jsonProp.Name); - } + global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1? responsesClientEventResponseCreateVariant1 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1).Name}"); + responsesClientEventResponseCreateVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { } - var __score0 = 0; - if (__jsonProps.Contains("type")) __score0++; - var __score1 = 0; - var __bestScore = 0; - var __bestIndex = -1; - if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } - if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } - - global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1? responsesClientEventResponseCreateVariant1 = default; global::tryAGI.OpenAI.CreateResponse? createResponse = default; - if (__bestIndex >= 0) + try { - if (__bestIndex == 0) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1).Name}"); - responsesClientEventResponseCreateVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } - else if (__bestIndex == 1) - { - try - { - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponse).Name}"); - createResponse = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } - } + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponse).Name}"); + createResponse = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); } - - if (responsesClientEventResponseCreateVariant1 == null && createResponse == null) + catch (global::System.Text.Json.JsonException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1).Name}"); - responsesClientEventResponseCreateVariant1 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - - if (responsesClientEventResponseCreateVariant1 == null && createResponse == null) + catch (global::System.InvalidOperationException) { - try - { - - var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? - throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponse).Name}"); - createResponse = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); - } - catch (global::System.Text.Json.JsonException) - { - } - catch (global::System.InvalidOperationException) - { - } } - var __value = new global::tryAGI.OpenAI.ResponsesClientEventResponseCreate( responsesClientEventResponseCreateVariant1, @@ -123,18 +63,46 @@ public override void Write( options = options ?? throw new global::System.ArgumentNullException(nameof(options)); var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); if (value.IsResponsesClientEventResponseCreateVariant1) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.ResponsesClientEventResponseCreateVariant1).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.ResponsesClientEventResponseCreateVariant1!, typeInfo); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.ResponsesClientEventResponseCreateVariant1!, typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } - else if (value.IsCreateResponse) + if (value.IsCreateResponse) { var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::tryAGI.OpenAI.CreateResponse), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::tryAGI.OpenAI.CreateResponse).Name}"); - global::System.Text.Json.JsonSerializer.Serialize(writer, value.CreateResponse!.Value, typeInfo); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.CreateResponse!.Value, typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } } + writer.WriteEndObject(); } } } \ No newline at end of file diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContext.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContext.g.cs index 6fdfb1e5..15824543 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContext.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContext.g.cs @@ -39,6 +39,7 @@ namespace tryAGI.OpenAI [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List), TypeInfoPropertyName = "SystemCollectionsGeneric_ObjectList")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Text.Json.JsonElement?))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.AddUploadPartRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(byte[]))] @@ -513,7 +514,6 @@ namespace tryAGI.OpenAI [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.AnyOf), TypeInfoPropertyName = "AnyOfStringCreateCompletionRequestModel2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.CreateCompletionRequestModel), TypeInfoPropertyName = "CreateCompletionRequestModel2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.IList, global::System.Collections.Generic.IList>>), TypeInfoPropertyName = "OneOfStringIListStringIListInt32IListIListInt322")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] internal sealed partial class SourceGenerationContextChunk0 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -549,6 +549,7 @@ internal sealed partial class SourceGenerationContextChunk0 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.CreateCompletionResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] @@ -1025,7 +1026,6 @@ internal sealed partial class SourceGenerationContextChunk0 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuneSupervisedHyperparametersNEpochs), TypeInfoPropertyName = "FineTuneSupervisedHyperparametersNEpochs2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuningCheckpointPermission))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuningCheckpointPermissionObject), TypeInfoPropertyName = "FineTuningCheckpointPermissionObject2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuningIntegration))] internal sealed partial class SourceGenerationContextChunk1 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -1061,6 +1061,7 @@ internal sealed partial class SourceGenerationContextChunk1 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuningIntegration))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuningIntegrationType), TypeInfoPropertyName = "FineTuningIntegrationType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuningIntegrationWandb))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.FineTuningJob))] @@ -1537,7 +1538,6 @@ internal sealed partial class SourceGenerationContextChunk1 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventConversationItemRetrieveType), TypeInfoPropertyName = "RealtimeBetaClientEventConversationItemRetrieveType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventConversationItemTruncate))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventConversationItemTruncateType), TypeInfoPropertyName = "RealtimeBetaClientEventConversationItemTruncateType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventInputAudioBufferAppend))] internal sealed partial class SourceGenerationContextChunk2 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -1573,6 +1573,7 @@ internal sealed partial class SourceGenerationContextChunk2 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventInputAudioBufferAppend))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventInputAudioBufferAppendType), TypeInfoPropertyName = "RealtimeBetaClientEventInputAudioBufferAppendType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventInputAudioBufferClear))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeBetaClientEventInputAudioBufferClearType), TypeInfoPropertyName = "RealtimeBetaClientEventInputAudioBufferClearType2")] @@ -2049,7 +2050,6 @@ internal sealed partial class SourceGenerationContextChunk2 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateResponseClientSecret))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateResponseModalitie), TypeInfoPropertyName = "RealtimeTranscriptionSessionCreateResponseModalitie2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateResponseTurnDetection))] internal sealed partial class SourceGenerationContextChunk3 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -2085,6 +2085,7 @@ internal sealed partial class SourceGenerationContextChunk3 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateResponseTurnDetection))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateResponseGAType), TypeInfoPropertyName = "RealtimeTranscriptionSessionCreateResponseGAType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.RealtimeTranscriptionSessionCreateResponseGAIncludeItem), TypeInfoPropertyName = "RealtimeTranscriptionSessionCreateResponseGAIncludeItem2")] @@ -2561,7 +2562,6 @@ internal sealed partial class SourceGenerationContextChunk3 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UserRoleAssignment))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UserRoleAssignmentObject), TypeInfoPropertyName = "UserRoleAssignmentObject2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UserRoleUpdateRequest))] internal sealed partial class SourceGenerationContextChunk4 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -2597,6 +2597,7 @@ internal sealed partial class SourceGenerationContextChunk4 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UserRoleUpdateRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.VadConfigType), TypeInfoPropertyName = "VadConfigType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ValidateGraderRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ValidateGraderResponse))] @@ -3073,7 +3074,6 @@ internal sealed partial class SourceGenerationContextChunk4 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ItemFieldDiscriminator))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ItemFieldDiscriminatorType), TypeInfoPropertyName = "ItemFieldDiscriminatorType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.CompactResource))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.CompactResourceObject), TypeInfoPropertyName = "CompactResourceObject2")] internal sealed partial class SourceGenerationContextChunk5 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -3109,6 +3109,7 @@ internal sealed partial class SourceGenerationContextChunk5 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.CompactResourceObject), TypeInfoPropertyName = "CompactResourceObject2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.SkillResource))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.SkillResourceObject), TypeInfoPropertyName = "SkillResourceObject2")] @@ -3585,7 +3586,6 @@ internal sealed partial class SourceGenerationContextChunk5 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaInputFileContentParamType), TypeInfoPropertyName = "BetaInputFileContentParamType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaFileDetailEnum), TypeInfoPropertyName = "BetaFileDetailEnum2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallType), TypeInfoPropertyName = "BetaFunctionToolCallType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallStatus), TypeInfoPropertyName = "BetaFunctionToolCallStatus2")] internal sealed partial class SourceGenerationContextChunk6 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -3621,6 +3621,7 @@ internal sealed partial class SourceGenerationContextChunk6 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaFunctionToolCallStatus), TypeInfoPropertyName = "BetaFunctionToolCallStatus2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaWebSearchToolCallType), TypeInfoPropertyName = "BetaWebSearchToolCallType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaWebSearchToolCallStatus), TypeInfoPropertyName = "BetaWebSearchToolCallStatus2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaWebSearchToolCallAction), TypeInfoPropertyName = "BetaWebSearchToolCallAction2")] @@ -4097,7 +4098,6 @@ internal sealed partial class SourceGenerationContextChunk6 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UsageImagesGroupByItem), TypeInfoPropertyName = "UsageImagesGroupByItem2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UsageModerationsBucketWidth), TypeInfoPropertyName = "UsageModerationsBucketWidth2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UsageModerationsGroupByItem), TypeInfoPropertyName = "UsageModerationsGroupByItem2")] internal sealed partial class SourceGenerationContextChunk7 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -4133,6 +4133,7 @@ internal sealed partial class SourceGenerationContextChunk7 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UsageModerationsGroupByItem), TypeInfoPropertyName = "UsageModerationsGroupByItem2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UsageVectorStoresBucketWidth), TypeInfoPropertyName = "UsageVectorStoresBucketWidth2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.UsageVectorStoresGroupByItem), TypeInfoPropertyName = "UsageVectorStoresGroupByItem2")] @@ -4609,7 +4610,6 @@ internal sealed partial class SourceGenerationContextChunk7 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageEditPartialImageEventQuality?), TypeInfoPropertyName = "NullableImageEditPartialImageEventQuality2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageEditPartialImageEventBackground?), TypeInfoPropertyName = "NullableImageEditPartialImageEventBackground2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageEditPartialImageEventOutputFormat?), TypeInfoPropertyName = "NullableImageEditPartialImageEventOutputFormat2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageEditStreamEvent?), TypeInfoPropertyName = "NullableImageEditStreamEvent2")] internal sealed partial class SourceGenerationContextChunk8 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -4645,6 +4645,7 @@ internal sealed partial class SourceGenerationContextChunk8 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageEditStreamEvent?), TypeInfoPropertyName = "NullableImageEditStreamEvent2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageEditStreamEventDiscriminatorType?), TypeInfoPropertyName = "NullableImageEditStreamEventDiscriminatorType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageGenCompletedEventType?), TypeInfoPropertyName = "NullableImageGenCompletedEventType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ImageGenCompletedEventSize?), TypeInfoPropertyName = "NullableImageGenCompletedEventSize2")] @@ -5121,7 +5122,6 @@ internal sealed partial class SourceGenerationContextChunk8 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseFormatTextType?), TypeInfoPropertyName = "NullableResponseFormatTextType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseFormatTextGrammarType?), TypeInfoPropertyName = "NullableResponseFormatTextGrammarType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseFormatTextPythonType?), TypeInfoPropertyName = "NullableResponseFormatTextPythonType2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseFunctionCallArgumentsDeltaEventType?), TypeInfoPropertyName = "NullableResponseFunctionCallArgumentsDeltaEventType2")] internal sealed partial class SourceGenerationContextChunk9 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -5157,6 +5157,7 @@ internal sealed partial class SourceGenerationContextChunk9 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseFunctionCallArgumentsDeltaEventType?), TypeInfoPropertyName = "NullableResponseFunctionCallArgumentsDeltaEventType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseFunctionCallArgumentsDoneEventType?), TypeInfoPropertyName = "NullableResponseFunctionCallArgumentsDoneEventType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseImageGenCallCompletedEventType?), TypeInfoPropertyName = "NullableResponseImageGenCallCompletedEventType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ResponseImageGenCallGeneratingEventType?), TypeInfoPropertyName = "NullableResponseImageGenCallGeneratingEventType2")] @@ -5633,7 +5634,6 @@ internal sealed partial class SourceGenerationContextChunk9 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.Status?), TypeInfoPropertyName = "NullableStatus2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ThreadResourceStatusDiscriminatorType?), TypeInfoPropertyName = "NullableThreadResourceStatusDiscriminatorType2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.DeletedThreadResourceObject?), TypeInfoPropertyName = "NullableDeletedThreadResourceObject2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ThreadListResourceObject?), TypeInfoPropertyName = "NullableThreadListResourceObject2")] internal sealed partial class SourceGenerationContextChunk10 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -5669,6 +5669,7 @@ internal sealed partial class SourceGenerationContextChunk10 : global::System.Te [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ThreadListResourceObject?), TypeInfoPropertyName = "NullableThreadListResourceObject2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaTokenCountsResourceObject?), TypeInfoPropertyName = "NullableBetaTokenCountsResourceObject2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaInputItem?), TypeInfoPropertyName = "NullableBetaInputItem2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaTool?), TypeInfoPropertyName = "NullableBetaTool2")] @@ -6145,7 +6146,6 @@ internal sealed partial class SourceGenerationContextChunk10 : global::System.Te [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ListVectorStoreFilesOrder?), TypeInfoPropertyName = "NullableListVectorStoreFilesOrder2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.ListVectorStoreFilesFilter?), TypeInfoPropertyName = "NullableListVectorStoreFilesFilter2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaCreateResponseOpenaiBetaItem?), TypeInfoPropertyName = "NullableBetaCreateResponseOpenaiBetaItem2")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaGetResponseOpenaiBetaItem?), TypeInfoPropertyName = "NullableBetaGetResponseOpenaiBetaItem2")] internal sealed partial class SourceGenerationContextChunk11 : global::System.Text.Json.Serialization.JsonSerializerContext { } @@ -6181,6 +6181,7 @@ internal sealed partial class SourceGenerationContextChunk11 : global::System.Te [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.OneOf, global::System.Collections.Generic.List>>), TypeInfoPropertyName = "CreateModerationRequestInputVariant3ItemVariant2_82fca1e83967e178")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "MessageDeltaContentImageUrlObject_9c7d436e0b6fe539")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>), TypeInfoPropertyName = "RunStepDeltaStepDetailsToolCallsFunctionObject_5640d9ed7ecfcd45")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaGetResponseOpenaiBetaItem?), TypeInfoPropertyName = "NullableBetaGetResponseOpenaiBetaItem2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaDeleteResponseOpenaiBetaItem?), TypeInfoPropertyName = "NullableBetaDeleteResponseOpenaiBetaItem2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaCancelResponseOpenaiBetaItem?), TypeInfoPropertyName = "NullableBetaCancelResponseOpenaiBetaItem2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.BetaCompactconversationOpenaiBetaItem?), TypeInfoPropertyName = "NullableBetaCompactconversationOpenaiBetaItem2")] @@ -6198,7 +6199,6 @@ internal sealed partial class SourceGenerationContextChunk11 : global::System.Te [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List>))] diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContextTypes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContextTypes.g.cs index e9f48bc1..c8b2cb35 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContextTypes.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.JsonSerializerContextTypes.g.cs @@ -20,6 +20,11 @@ public sealed partial class JsonSerializerContextTypes /// public global::System.Collections.Generic.Dictionary? StringObjectDictionary { get; set; } + /// + /// Runtime object lists used by dynamic JSON payloads such as tool arguments. + /// + public global::System.Collections.Generic.List? ObjectList { get; set; } + /// /// /// diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContext.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContext.g.cs index 59b06b8f..866aa93a 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContext.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContext.g.cs @@ -686,6 +686,7 @@ namespace tryAGI.OpenAI.Realtime typeof(global::tryAGI.OpenAI.Realtime.JsonConverters.OneOfJsonConverter), })] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.Realtime.JsonSerializerContextTypes))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List), TypeInfoPropertyName = "SystemCollectionsGeneric_ObjectList")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.Realtime.AudioTranscription))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::tryAGI.OpenAI.Realtime.AnyOf), TypeInfoPropertyName = "AnyOfStringAudioTranscriptionModel2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(string))] diff --git a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContextTypes.g.cs b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContextTypes.g.cs index 5088c699..3eea17fd 100644 --- a/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContextTypes.g.cs +++ b/src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.Realtime.JsonSerializerContextTypes.g.cs @@ -20,6 +20,11 @@ public sealed partial class JsonSerializerContextTypes /// public global::System.Collections.Generic.Dictionary? StringObjectDictionary { get; set; } + /// + /// Runtime object lists used by dynamic JSON payloads such as tool arguments. + /// + public global::System.Collections.Generic.List? ObjectList { get; set; } + /// /// ///