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:@coderabbitai #68

Merged
merged 1 commit into from
Nov 12, 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
92 changes: 92 additions & 0 deletions src/libs/Ollama/Generated/AnyOf.2.Json.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#nullable enable

namespace Ollama
{
public readonly partial struct AnyOf<T1, T2>
{
/// <summary>
/// Serializes the current instance to a JSON string using the provided JsonSerializerContext.
/// </summary>
public string ToJson(
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return global::System.Text.Json.JsonSerializer.Serialize(
this,
this.GetType(),
jsonSerializerContext);
}

/// <summary>
/// Serializes the current instance to a JSON string using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public string ToJson(
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.Serialize(
this,
jsonSerializerOptions);
}

/// <summary>
/// Deserializes a JSON string using the provided JsonSerializerContext.
/// </summary>
public static global::Ollama.AnyOf<T1, T2>? FromJson(
string json,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return global::System.Text.Json.JsonSerializer.Deserialize(
json,
typeof(global::Ollama.AnyOf<T1, T2>),
jsonSerializerContext) as global::Ollama.AnyOf<T1, T2>?;
}

/// <summary>
/// Deserializes a JSON string using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public static global::Ollama.AnyOf<T1, T2>? FromJson(
string json,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.Deserialize<global::Ollama.AnyOf<T1, T2>>(
json,
jsonSerializerOptions);
}

/// <summary>
/// Deserializes a JSON stream using the provided JsonSerializerContext.
/// </summary>
public static async global::System.Threading.Tasks.ValueTask<global::Ollama.AnyOf<T1, T2>?> FromJsonStreamAsync(
global::System.IO.Stream jsonStream,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return (await global::System.Text.Json.JsonSerializer.DeserializeAsync(
jsonStream,
typeof(global::Ollama.AnyOf<T1, T2>),
jsonSerializerContext).ConfigureAwait(false)) as global::Ollama.AnyOf<T1, T2>?;
}

/// <summary>
/// Deserializes a JSON stream using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public static global::System.Threading.Tasks.ValueTask<global::Ollama.AnyOf<T1, T2>?> FromJsonStreamAsync(
global::System.IO.Stream jsonStream,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.DeserializeAsync<global::Ollama.AnyOf<T1, T2>?>(
jsonStream,
jsonSerializerOptions);
}
}
}
91 changes: 2 additions & 89 deletions src/libs/Ollama/Generated/AnyOf.2.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;

#nullable enable

Expand Down Expand Up @@ -172,7 +171,8 @@ public override int GetHashCode()
static int HashCodeAggregator(int hashCode, object? value) => value == null
? (hashCode ^ 0) * prime
: (hashCode ^ value.GetHashCode()) * prime;
return fields.Aggregate(offset, HashCodeAggregator);

return global::System.Linq.Enumerable.Aggregate(fields, offset, HashCodeAggregator);
}

/// <summary>
Expand Down Expand Up @@ -209,92 +209,5 @@ public override bool Equals(object? obj)
{
return obj is AnyOf<T1, T2> o && Equals(o);
}


/// <summary>
/// Serializes the current instance to a JSON string using the provided JsonSerializerContext.
/// </summary>
public string ToJson(
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return global::System.Text.Json.JsonSerializer.Serialize(
this,
this.GetType(),
jsonSerializerContext);
}

/// <summary>
/// Serializes the current instance to a JSON string using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public string ToJson(
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.Serialize(
this,
jsonSerializerOptions);
}

/// <summary>
/// Deserializes a JSON string using the provided JsonSerializerContext.
/// </summary>
public static global::Ollama.AnyOf<T1, T2>? FromJson(
string json,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return global::System.Text.Json.JsonSerializer.Deserialize(
json,
typeof(global::Ollama.AnyOf<T1, T2>),
jsonSerializerContext) as global::Ollama.AnyOf<T1, T2>?;
}

/// <summary>
/// Deserializes a JSON string using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public static global::Ollama.AnyOf<T1, T2>? FromJson(
string json,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.Deserialize<global::Ollama.AnyOf<T1, T2>>(
json,
jsonSerializerOptions);
}

/// <summary>
/// Deserializes a JSON stream using the provided JsonSerializerContext.
/// </summary>
public static async global::System.Threading.Tasks.ValueTask<global::Ollama.AnyOf<T1, T2>?> FromJsonStream(
global::System.IO.Stream jsonStream,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
return (await global::System.Text.Json.JsonSerializer.DeserializeAsync(
jsonStream,
typeof(global::Ollama.AnyOf<T1, T2>),
jsonSerializerContext).ConfigureAwait(false)) as global::Ollama.AnyOf<T1, T2>?;
}

/// <summary>
/// Deserializes a JSON stream using the provided JsonSerializerOptions.
/// </summary>
#if NET8_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
[global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
#endif
public static global::System.Threading.Tasks.ValueTask<global::Ollama.AnyOf<T1, T2>?> FromJsonStream(
global::System.IO.Stream jsonStream,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null)
{
return global::System.Text.Json.JsonSerializer.DeserializeAsync<global::Ollama.AnyOf<T1, T2>?>(
jsonStream,
jsonSerializerOptions);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ partial void ProcessGenerateChatCompletionResponse(
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
/// <exception cref="global::Ollama.ApiException"></exception>
public async global::System.Collections.Generic.IAsyncEnumerable<global::Ollama.GenerateChatCompletionResponse> GenerateChatCompletionAsync(
global::Ollama.GenerateChatCompletionRequest request,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -68,18 +68,34 @@ partial void ProcessGenerateChatCompletionResponse(
ProcessGenerateChatCompletionResponse(
httpClient: HttpClient,
httpResponseMessage: __response);
__response.EnsureSuccessStatusCode();
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Ollama.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}

using var stream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var reader = new global::System.IO.StreamReader(stream);
using var __stream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var __reader = new global::System.IO.StreamReader(__stream);

while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
while (!__reader.EndOfStream && !cancellationToken.IsCancellationRequested)
{
var __content = await reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
var streamedResponse = global::Ollama.GenerateChatCompletionResponse.FromJson(__content, JsonSerializerContext) ??
var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
var __streamedResponse = global::Ollama.GenerateChatCompletionResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");

yield return streamedResponse;
yield return __streamedResponse;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/libs/Ollama/Generated/Ollama.ChatClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public sealed partial class ChatClient : global::Ollama.IChatClient, global::Sys
/// <inheritdoc/>
public global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization> Authorizations { get; }

/// <inheritdoc/>
public bool ReadResponseAsString { get; set; }
#if DEBUG
= true;
#endif
/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ partial void ProcessGenerateCompletionResponse(
/// </summary>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
/// <exception cref="global::Ollama.ApiException"></exception>
public async global::System.Collections.Generic.IAsyncEnumerable<global::Ollama.GenerateCompletionResponse> GenerateCompletionAsync(
global::Ollama.GenerateCompletionRequest request,
[global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -68,18 +68,34 @@ partial void ProcessGenerateCompletionResponse(
ProcessGenerateCompletionResponse(
httpClient: HttpClient,
httpResponseMessage: __response);
__response.EnsureSuccessStatusCode();
try
{
__response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException __ex)
{
throw new global::Ollama.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}

using var stream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var reader = new global::System.IO.StreamReader(stream);
using var __stream = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
using var __reader = new global::System.IO.StreamReader(__stream);

while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
while (!__reader.EndOfStream && !cancellationToken.IsCancellationRequested)
{
var __content = await reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
var streamedResponse = global::Ollama.GenerateCompletionResponse.FromJson(__content, JsonSerializerContext) ??
var __content = await __reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
var __streamedResponse = global::Ollama.GenerateCompletionResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");

yield return streamedResponse;
yield return __streamedResponse;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/libs/Ollama/Generated/Ollama.CompletionsClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public sealed partial class CompletionsClient : global::Ollama.ICompletionsClien
/// <inheritdoc/>
public global::System.Collections.Generic.List<global::Ollama.EndPointAuthorization> Authorizations { get; }

/// <inheritdoc/>
public bool ReadResponseAsString { get; set; }
#if DEBUG
= true;
#endif
/// <summary>
///
/// </summary>
Expand Down
Loading
Loading