Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,18 @@ partial void ProcessConvertDocumentFileStudioV1ChatFilesConvertPostResponseConte
}
}
using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Files, x => x))}]"),
name: "\"files\"");
for (var __iFiles = 0; __iFiles < request.Files.Count; __iFiles++)
{
var __contentFiles = new global::System.Net.Http.ByteArrayContent(request.Files[__iFiles]);
__httpRequestContent.Add(
content: __contentFiles,
name: "\"files\"",
fileName: $"\"file{__iFiles}.bin\"");
if (__contentFiles.Headers.ContentDisposition != null)
{
__contentFiles.Headers.ContentDisposition.FileNameStar = null;
}
}
__httpRequest.Content = __httpRequestContent;

PrepareRequest(
Expand Down
127 changes: 96 additions & 31 deletions src/libs/AI21/Generated/AI21.JsonConverters.AnyOf2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,113 @@ public class AnyOfJsonConverter<T1, T2> : 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.");

var
readerCopy = reader;
T1? value1 = default;
try

using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader);
var __rawJson = __jsonDocument.RootElement.GetRawText();
var __jsonProps = new global::System.Collections.Generic.HashSet<string>();
if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T1> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}");
value1 = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, typeInfo);
foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject())
{
__jsonProps.Add(__jsonProp.Name);
}
}
catch (global::System.Text.Json.JsonException)

var __score0 = 0;
{
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++;
}
}
}
catch (global::System.InvalidOperationException)
var __score1 = 0;
{
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; }

readerCopy = reader;
T1? value1 = default;
T2? value2 = default;
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}");
value2 = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, typeInfo);
}
catch (global::System.Text.Json.JsonException)
if (__bestIndex >= 0)
{
if (__bestIndex == 0)
{
try
{

var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T1> ??
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<T2> ??
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)
{
}
}
}
catch (global::System.InvalidOperationException)

if (value1 == null && value2 == null)
{
try
{

var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T1> ??
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)
{
}

try
{

var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T2> ??
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::AI21.AnyOf<T1, T2>(
Expand All @@ -51,19 +129,6 @@ public class AnyOfJsonConverter<T1, T2> : global::System.Text.Json.Serialization
value2
);

if (value1 != null)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T1> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T1).Name}");
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
else if (value2 != null)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(T2).Name}");
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}

return __value;
}

Expand Down
Loading
Loading