Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Updated OpenAPI spec #29

Merged
merged 1 commit into from
Aug 16, 2024
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
14 changes: 2 additions & 12 deletions src/libs/Ollama/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);
}

Comment on lines +41 to +59
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider reintroducing validation checks for data integrity.

The removal of validation checks in the deserialization process can lead to potential issues with handling invalid data. Without these checks, invalid data might be silently accepted, which could cause downstream errors or inconsistencies.

Consider reintroducing some form of validation to ensure data integrity and prevent potential issues.

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
14 changes: 2 additions & 12 deletions src/libs/Ollama/Generated/JsonConverters.CreateModelStatus.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,25 @@ public class CreateModelStatusJsonConverter : global::System.Text.Json.Serializa
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::Ollama.CreateModelStatus(
value1,

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

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

else if (value2 != null)
{
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 @@ -74,18 +70,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(string).Name}, {typeof(global::Ollama.CreateModelStatusEnum).Name}> object.");
}

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

else if (value.IsValue2)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.CreateModelStatusEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.CreateModelStatusEnum?> ??
Expand Down
14 changes: 2 additions & 12 deletions src/libs/Ollama/Generated/JsonConverters.DoneReason.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,25 @@ public class DoneReasonJsonConverter : global::System.Text.Json.Serialization.Js
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::Ollama.DoneReason(
value1,

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

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

else if (value2 != null)
{
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);
}

Comment on lines +42 to +60
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reevaluate the removal of validation checks for reliability.

The removal of validation checks in the deserialization process can result in invalid data being processed without triggering exceptions. This change might affect the reliability of the application by allowing potentially inconsistent data to propagate through the system.

Consider implementing alternative validation mechanisms to ensure data consistency and reliability.

return result;
}

Expand All @@ -74,18 +70,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(string).Name}, {typeof(global::Ollama.DoneReasonEnum).Name}> object.");
}

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

else if (value.IsValue2)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.DoneReasonEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.DoneReasonEnum?> ??
Expand Down
14 changes: 2 additions & 12 deletions src/libs/Ollama/Generated/JsonConverters.PullModelStatus.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,25 @@ public class PullModelStatusJsonConverter : global::System.Text.Json.Serializati
catch (global::System.Text.Json.JsonException)
{
}

var result = new global::Ollama.PullModelStatus(
value1,

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

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

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

Comment on lines +42 to +60
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assess the impact of removing validation checks on system stability.

The removal of validation checks in the deserialization process may lead to invalid data being processed without error handling, which could compromise system stability. This change might allow inconsistent data to be serialized and deserialized without triggering exceptions.

Consider reintroducing validation mechanisms to maintain data integrity and ensure system stability.

return result;
}

Expand All @@ -74,18 +70,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(string).Name}, {typeof(global::Ollama.PullModelStatusEnum).Name}> object.");
}

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

else if (value.IsValue2)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Ollama.PullModelStatusEnum), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Ollama.PullModelStatusEnum?> ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ partial void ProcessGenerateChatCompletionResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/chat", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.GenerateChatCompletionRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.GenerateChatCompletionRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ partial void ProcessGenerateCompletionResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/generate", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.GenerateCompletionRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.GenerateCompletionRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ partial void ProcessGenerateEmbeddingResponseContent(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/embeddings", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.GenerateEmbeddingRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.GenerateEmbeddingRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/Ollama/Generated/Ollama.ModelsClient.CopyModel.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ partial void ProcessCopyModelResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/copy", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.CopyModelRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.CopyModelRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ partial void ProcessCreateBlobResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/blobs/{digest}", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.ByteArray);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.ByteArray),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/octet-stream");
httpRequest.Content = __httpRequestContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ partial void ProcessCreateModelResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/create", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.CreateModelRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.CreateModelRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ partial void ProcessDeleteModelResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Delete,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/delete", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.DeleteModelRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.DeleteModelRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/Ollama/Generated/Ollama.ModelsClient.PullModel.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ partial void ProcessPullModelResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/pull", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.PullModelRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.PullModelRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/Ollama/Generated/Ollama.ModelsClient.PushModel.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ partial void ProcessPushModelResponse(
using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + "/push", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.PushModelRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: global::System.Text.Json.JsonSerializer.Serialize(request, global::Ollama.SourceGenerationContext.Default.PushModelRequest),
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;
Expand Down
Loading