Skip to content

Commit

Permalink
feat: Updated to use latest OpenApiGenerator.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Aug 13, 2024
1 parent 0d96c7f commit 2b181dc
Show file tree
Hide file tree
Showing 40 changed files with 288 additions and 768 deletions.
2 changes: 1 addition & 1 deletion src/libs/Ollama/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void AddToolService(
public async Task<Message> SendAsync(
string? message = null,
MessageRole role = MessageRole.User,
IEnumerable<string?>? imagesAsBase64 = null,
IEnumerable<string>? imagesAsBase64 = null,
CancellationToken cancellationToken = default)
{
if (message != null)
Expand Down

This file was deleted.

18 changes: 9 additions & 9 deletions src/libs/Ollama/Generated/JsonConverters.CreateModelStatus.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class CreateModelStatusJsonConverter : global::System.Text.Json.Serializa
}

readerCopy = reader;
global::Ollama.CreateModelStatusVariant2? value2 = default;
global::Ollama.CreateModelStatusEnum? value2 = default;
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.CreateModelStatusVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.CreateModelStatusVariant2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.CreateModelStatusVariant2).Name}");
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.CreateModelStatusEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.CreateModelStatusEnum> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.CreateModelStatusEnum).Name}");
value2 = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, typeInfo);
}
catch (global::System.Text.Json.JsonException)
Expand All @@ -46,7 +46,7 @@ public class CreateModelStatusJsonConverter : global::System.Text.Json.Serializa
);
if (!result.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(string).Name}, {typeof(global::Ollama.CreateModelStatusVariant2).Name}>");
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(string).Name}, {typeof(global::Ollama.CreateModelStatusEnum).Name}>");
}

if (value1 != null)
Expand All @@ -58,8 +58,8 @@ public class CreateModelStatusJsonConverter : global::System.Text.Json.Serializa

else if (value2 != null)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.CreateModelStatusVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.CreateModelStatusVariant2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.CreateModelStatusVariant2).Name}");
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.CreateModelStatusEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.CreateModelStatusEnum> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.CreateModelStatusEnum).Name}");
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
return result;
Expand All @@ -76,7 +76,7 @@ public override void Write(

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

if (value.IsValue1)
Expand All @@ -88,8 +88,8 @@ public override void Write(

else if (value.IsValue2)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.CreateModelStatusVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.CreateModelStatusVariant2?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.CreateModelStatusVariant2).Name}");
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.CreateModelStatusEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.CreateModelStatusEnum?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.CreateModelStatusEnum).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.Value2, typeInfo);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class CreateModelStatusVariant2JsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelStatusVariant2>
public sealed class CreateModelStatusEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelStatusEnum>
{
/// <inheritdoc />
public override global::Ollama.CreateModelStatusVariant2 Read(
public override global::Ollama.CreateModelStatusEnum Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,15 +18,15 @@ public sealed class CreateModelStatusVariant2JsonConverter : global::System.Text
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Ollama.CreateModelStatusVariant2Extensions.ToEnum(stringValue) ?? default;
return global::Ollama.CreateModelStatusEnumExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Ollama.CreateModelStatusVariant2)numValue;
return (global::Ollama.CreateModelStatusEnum)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -38,12 +38,12 @@ public sealed class CreateModelStatusVariant2JsonConverter : global::System.Text
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Ollama.CreateModelStatusVariant2 value,
global::Ollama.CreateModelStatusEnum value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::Ollama.CreateModelStatusVariant2Extensions.ToValueString(value));
writer.WriteStringValue(global::Ollama.CreateModelStatusEnumExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace OpenApiGenerator.JsonConverters
{
/// <inheritdoc />
public sealed class CreateModelResponseStatusNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelResponseStatus?>
public sealed class CreateModelStatusEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelStatusEnum?>
{
/// <inheritdoc />
public override global::Ollama.CreateModelResponseStatus? Read(
public override global::Ollama.CreateModelStatusEnum? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand All @@ -18,15 +18,15 @@ public sealed class CreateModelResponseStatusNullableJsonConverter : global::Sys
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Ollama.CreateModelResponseStatusExtensions.ToEnum(stringValue);
return global::Ollama.CreateModelStatusEnumExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Ollama.CreateModelResponseStatus)numValue;
return (global::Ollama.CreateModelStatusEnum)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
Expand All @@ -38,7 +38,7 @@ public sealed class CreateModelResponseStatusNullableJsonConverter : global::Sys
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Ollama.CreateModelResponseStatus? value,
global::Ollama.CreateModelStatusEnum? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));
Expand All @@ -49,7 +49,7 @@ public override void Write(
}
else
{
writer.WriteStringValue(global::Ollama.CreateModelResponseStatusExtensions.ToValueString(value.Value));
writer.WriteStringValue(global::Ollama.CreateModelStatusEnumExtensions.ToValueString(value.Value));
}
}
}
Expand Down

This file was deleted.

18 changes: 9 additions & 9 deletions src/libs/Ollama/Generated/JsonConverters.DoneReason.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class DoneReasonJsonConverter : global::System.Text.Json.Serialization.Js
}

readerCopy = reader;
global::Ollama.DoneReasonVariant2? value2 = default;
global::Ollama.DoneReasonEnum? value2 = default;
try
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.DoneReasonVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.DoneReasonVariant2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.DoneReasonVariant2).Name}");
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.DoneReasonEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.DoneReasonEnum> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.DoneReasonEnum).Name}");
value2 = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, typeInfo);
}
catch (global::System.Text.Json.JsonException)
Expand All @@ -46,7 +46,7 @@ public class DoneReasonJsonConverter : global::System.Text.Json.Serialization.Js
);
if (!result.Validate())
{
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(string).Name}, {typeof(global::Ollama.DoneReasonVariant2).Name}>");
throw new global::System.Text.Json.JsonException($"Invalid JSON format for AnyOf<{typeof(string).Name}, {typeof(global::Ollama.DoneReasonEnum).Name}>");
}

if (value1 != null)
Expand All @@ -58,8 +58,8 @@ public class DoneReasonJsonConverter : global::System.Text.Json.Serialization.Js

else if (value2 != null)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.DoneReasonVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.DoneReasonVariant2> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.DoneReasonVariant2).Name}");
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.DoneReasonEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.DoneReasonEnum> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Ollama.DoneReasonEnum).Name}");
_ = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}
return result;
Expand All @@ -76,7 +76,7 @@ public override void Write(

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

if (value.IsValue1)
Expand All @@ -88,8 +88,8 @@ public override void Write(

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

0 comments on commit 2b181dc

Please sign in to comment.