Skip to content

Commit

Permalink
feat: Updated OpenAPI spec
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 15, 2024
1 parent 4e83239 commit 8ea6207
Show file tree
Hide file tree
Showing 53 changed files with 106 additions and 373 deletions.
11 changes: 2 additions & 9 deletions src/libs/OpenAI/Generated/JsonConverters.AnyOf1.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ public class AnyOfJsonConverter<T1> : global::System.Text.Json.Serialization.Jso
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::System.AnyOf<T1>(
value1
);
if (!result.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(T1).Name}>");
}

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);
}

return result;
}

Expand All @@ -52,11 +50,6 @@ 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.");

if (!value.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid AnyOf<{typeof(T1).Name}> object.");
}

if (value.IsValue1)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T1?> ??
Expand Down
14 changes: 2 additions & 12 deletions src/libs/OpenAI/Generated/JsonConverters.AnyOf2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,25 @@ public class AnyOfJsonConverter<T1, T2> : global::System.Text.Json.Serialization
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::System.AnyOf<T1, T2>(
value1,

value2
);
if (!result.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(T1).Name}, {typeof(T2).Name}>");
}

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 result;
}

Expand All @@ -73,18 +69,12 @@ 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.");

if (!value.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid AnyOf<{typeof(T1).Name}, {typeof(T2).Name}> object.");
}

if (value.IsValue1)
{
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.Serialize(writer, value.Value1, typeInfo);
}

else if (value.IsValue2)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(T2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<T2?> ??
Expand Down
26 changes: 2 additions & 24 deletions src/libs/OpenAI/Generated/JsonConverters.AssistantStreamEvent.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,65 +87,53 @@ public class AssistantStreamEventJsonConverter : global::System.Text.Json.Serial
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::OpenAI.AssistantStreamEvent(
thread,

run,

runStep,

message,

error,

done
);
if (!result.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid JSON format for OneOf<{typeof(global::OpenAI.ThreadStreamEvent).Name}, {typeof(global::OpenAI.RunStreamEvent).Name}, {typeof(global::OpenAI.RunStepStreamEvent).Name}, {typeof(global::OpenAI.MessageStreamEvent).Name}, {typeof(global::OpenAI.ErrorEvent).Name}, {typeof(global::OpenAI.DoneEvent).Name}>");
}

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

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

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

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

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

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

return result;
}

Expand All @@ -158,46 +146,36 @@ 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.");

if (!value.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid OneOf<{typeof(global::OpenAI.ThreadStreamEvent).Name}, {typeof(global::OpenAI.RunStreamEvent).Name}, {typeof(global::OpenAI.RunStepStreamEvent).Name}, {typeof(global::OpenAI.MessageStreamEvent).Name}, {typeof(global::OpenAI.ErrorEvent).Name}, {typeof(global::OpenAI.DoneEvent).Name}> object.");
}

if (value.IsThread)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.ThreadStreamEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.ThreadStreamEvent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.ThreadStreamEvent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Thread, typeInfo);
}

else if (value.IsRun)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.RunStreamEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.RunStreamEvent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.RunStreamEvent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Run, typeInfo);
}

else if (value.IsRunStep)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.RunStepStreamEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.RunStepStreamEvent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.RunStepStreamEvent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.RunStep, typeInfo);
}

else if (value.IsMessage)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.MessageStreamEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.MessageStreamEvent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.MessageStreamEvent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Message, typeInfo);
}

else if (value.IsError)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.ErrorEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.ErrorEvent?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.ErrorEvent).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Error, typeInfo);
}

else if (value.IsDone)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.DoneEvent), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.DoneEvent?> ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,47 +63,39 @@ public class AssistantsApiResponseFormatOptionJsonConverter : global::System.Tex
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::OpenAI.AssistantsApiResponseFormatOption(
value1,

value2,

value3,

value4
);
if (!result.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid JSON format for OneOf<{typeof(global::OpenAI.AssistantsApiResponseFormatOptionEnum).Name}, {typeof(global::OpenAI.ResponseFormatText).Name}, {typeof(global::OpenAI.ResponseFormatJsonObject).Name}, {typeof(global::OpenAI.ResponseFormatJsonSchema).Name}>");
}

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

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

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

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

return result;
}

Expand All @@ -116,32 +108,24 @@ 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.");

if (!value.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid OneOf<{typeof(global::OpenAI.AssistantsApiResponseFormatOptionEnum).Name}, {typeof(global::OpenAI.ResponseFormatText).Name}, {typeof(global::OpenAI.ResponseFormatJsonObject).Name}, {typeof(global::OpenAI.ResponseFormatJsonSchema).Name}> object.");
}

if (value.IsValue1)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.AssistantsApiResponseFormatOptionEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.AssistantsApiResponseFormatOptionEnum?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.AssistantsApiResponseFormatOptionEnum).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value1, typeInfo);
}

else if (value.IsValue2)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.ResponseFormatText), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.ResponseFormatText?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.ResponseFormatText).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value2, typeInfo);
}

else if (value.IsValue3)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.ResponseFormatJsonObject), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.ResponseFormatJsonObject?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::OpenAI.ResponseFormatJsonObject).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value3, typeInfo);
}

else if (value.IsValue4)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::OpenAI.ResponseFormatJsonSchema), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::OpenAI.ResponseFormatJsonSchema?> ??
Expand Down
Loading

0 comments on commit 8ea6207

Please sign in to comment.