Skip to content

Commit

Permalink
feat: Use AutoSDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Sep 15, 2024
1 parent 0c9fae6 commit f00eb70
Show file tree
Hide file tree
Showing 70 changed files with 828 additions and 95 deletions.
2 changes: 1 addition & 1 deletion src/libs/Ollama/Generated/AnyOf.2.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#nullable enable

namespace System
namespace Ollama
{
/// <summary>
///
Expand Down
10 changes: 5 additions & 5 deletions src/libs/Ollama/Generated/JsonConverters.AnyOf2.g.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public class AnyOfJsonConverter<T1, T2> : global::System.Text.Json.Serialization.JsonConverter<global::System.AnyOf<T1, T2>>
public class AnyOfJsonConverter<T1, T2> : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.AnyOf<T1, T2>>
{
/// <inheritdoc />
public override global::System.AnyOf<T1, T2> Read(
public override global::Ollama.AnyOf<T1, T2> Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
Expand Down Expand Up @@ -39,7 +39,7 @@ public class AnyOfJsonConverter<T1, T2> : global::System.Text.Json.Serialization
{
}

var result = new global::System.AnyOf<T1, T2>(
var result = new global::Ollama.AnyOf<T1, T2>(
value1,
value2
);
Expand All @@ -63,7 +63,7 @@ public class AnyOfJsonConverter<T1, T2> : global::System.Text.Json.Serialization
/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::System.AnyOf<T1, T2> value,
global::Ollama.AnyOf<T1, T2> value,
global::System.Text.Json.JsonSerializerOptions options)
{
options = options ?? throw new global::System.ArgumentNullException(nameof(options));
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Ollama/Generated/JsonConverters.AnyOfFactory2.g.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class AnyOfJsonConverterFactory2 : global::System.Text.Json.Serialization.JsonConverterFactory
{
/// <inheritdoc />
public override bool CanConvert(global::System.Type? typeToConvert)
{
return typeToConvert is { IsGenericType: true } && typeToConvert.GetGenericTypeDefinition() == typeof(global::System.AnyOf<,>);
return typeToConvert is { IsGenericType: true } && typeToConvert.GetGenericTypeDefinition() == typeof(global::Ollama.AnyOf<,>);
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#nullable enable
#pragma warning disable CS0618 // Type or member is obsolete

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public class CreateModelStatusJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelStatus>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class CreateModelStatusEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelStatusEnum>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class CreateModelStatusEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.CreateModelStatusEnum?>
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Ollama/Generated/JsonConverters.DoneReason.g.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#nullable enable
#pragma warning disable CS0618 // Type or member is obsolete

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public class DoneReasonJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.DoneReason>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class DoneReasonEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.DoneReasonEnum>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class DoneReasonEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.DoneReasonEnum?>
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Ollama/Generated/JsonConverters.MessageRole.g.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class MessageRoleJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.MessageRole>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class MessageRoleNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.MessageRole?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#nullable enable
#pragma warning disable CS0618 // Type or member is obsolete

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public class PullModelStatusJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.PullModelStatus>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class PullModelStatusEnumJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.PullModelStatusEnum>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class PullModelStatusEnumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.PullModelStatusEnum?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class PushModelResponseStatusJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.PushModelResponseStatus>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class PushModelResponseStatusNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.PushModelResponseStatus?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class ResponseFormatJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.ResponseFormat>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class ResponseFormatNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.ResponseFormat?>
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Ollama/Generated/JsonConverters.ToolType.g.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class ToolTypeJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.ToolType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#nullable enable

namespace OpenApiGenerator.JsonConverters
namespace Ollama.JsonConverters
{
/// <inheritdoc />
public sealed class ToolTypeNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ollama.ToolType?>
Expand Down
39 changes: 39 additions & 0 deletions src/libs/Ollama/Generated/JsonConverters.UnixTimestamp.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#nullable enable

namespace Ollama.JsonConverters
{
/// <inheritdoc />
public class UnixTimestampJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::System.DateTimeOffset>
{
/// <inheritdoc />
public override global::System.DateTimeOffset Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
if (reader.TokenType == global::System.Text.Json.JsonTokenType.Number)
{
if (reader.TryGetInt64(out long unixTimestamp))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestamp);
}
if (reader.TryGetInt32(out int unixTimestampInt))
{
return global::System.DateTimeOffset.FromUnixTimeSeconds(unixTimestampInt);
}
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::System.DateTimeOffset value,
global::System.Text.Json.JsonSerializerOptions options)
{
long unixTimestamp = value.ToUnixTimeSeconds();
writer.WriteNumberValue(unixTimestamp);
}
}
}
36 changes: 18 additions & 18 deletions src/libs/Ollama/Generated/JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ namespace Ollama
DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull,
Converters = new global::System.Type[]
{
typeof(global::OpenApiGenerator.JsonConverters.ResponseFormatJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.ResponseFormatNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.MessageRoleJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.MessageRoleNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.ToolTypeJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.ToolTypeNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.DoneReasonEnumJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.DoneReasonEnumNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CreateModelStatusEnumJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CreateModelStatusEnumNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PullModelStatusEnumJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PullModelStatusEnumNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PushModelResponseStatusJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PushModelResponseStatusNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.DoneReasonJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CreateModelStatusJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PullModelStatusJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2),
typeof(global::Ollama.JsonConverters.ResponseFormatJsonConverter),
typeof(global::Ollama.JsonConverters.ResponseFormatNullableJsonConverter),
typeof(global::Ollama.JsonConverters.MessageRoleJsonConverter),
typeof(global::Ollama.JsonConverters.MessageRoleNullableJsonConverter),
typeof(global::Ollama.JsonConverters.ToolTypeJsonConverter),
typeof(global::Ollama.JsonConverters.ToolTypeNullableJsonConverter),
typeof(global::Ollama.JsonConverters.DoneReasonEnumJsonConverter),
typeof(global::Ollama.JsonConverters.DoneReasonEnumNullableJsonConverter),
typeof(global::Ollama.JsonConverters.CreateModelStatusEnumJsonConverter),
typeof(global::Ollama.JsonConverters.CreateModelStatusEnumNullableJsonConverter),
typeof(global::Ollama.JsonConverters.PullModelStatusEnumJsonConverter),
typeof(global::Ollama.JsonConverters.PullModelStatusEnumNullableJsonConverter),
typeof(global::Ollama.JsonConverters.PushModelResponseStatusJsonConverter),
typeof(global::Ollama.JsonConverters.PushModelResponseStatusNullableJsonConverter),
typeof(global::Ollama.JsonConverters.DoneReasonJsonConverter),
typeof(global::Ollama.JsonConverters.CreateModelStatusJsonConverter),
typeof(global::Ollama.JsonConverters.PullModelStatusJsonConverter),
typeof(global::Ollama.JsonConverters.AnyOfJsonConverterFactory2),
})]

[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ollama.JsonSerializerContextTypes))]
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Ollama/Generated/JsonSerializerContextTypes.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public sealed partial class JsonSerializerContextTypes
/// <summary>
///
/// </summary>
public global::System.AnyOf<string, global::Ollama.PushModelResponseStatus?>? Type55 { get; set; }
public global::Ollama.AnyOf<string, global::Ollama.PushModelResponseStatus?>? Type55 { get; set; }
/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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 __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), JsonSerializerContext);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
Expand Down Expand Up @@ -72,7 +72,7 @@ partial void ProcessGenerateChatCompletionResponse(
while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
{
var __content = await reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
var streamedResponse = global::System.Text.Json.JsonSerializer.Deserialize(__content, global::Ollama.SourceGenerationContext.Default.GenerateChatCompletionResponse) ??
var streamedResponse = global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::Ollama.GenerateChatCompletionResponse), JsonSerializerContext) as global::Ollama.GenerateChatCompletionResponse ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");

yield return streamedResponse;
Expand Down
10 changes: 7 additions & 3 deletions src/libs/Ollama/Generated/Ollama.ChatClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Ollama
/// If no httpClient is provided, a new one will be created.<br/>
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
public sealed partial class ChatClient : global::System.IDisposable
public sealed partial class ChatClient : global::Ollama.IChatClient, global::System.IDisposable
{
/// <summary>
/// Ollama server URL
Expand All @@ -17,6 +17,11 @@ public sealed partial class ChatClient : global::System.IDisposable

private readonly global::System.Net.Http.HttpClient _httpClient;

/// <summary>
///
/// </summary>
public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Ollama.SourceGenerationContext.Default;


/// <summary>
/// Creates a new instance of the ChatClient.
Expand All @@ -27,8 +32,7 @@ public sealed partial class ChatClient : global::System.IDisposable
/// <param name="baseUri"></param>
public ChatClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null
)
global::System.Uri? baseUri = null)
{
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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 __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, request.GetType(), JsonSerializerContext);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
Expand Down Expand Up @@ -72,7 +72,7 @@ partial void ProcessGenerateCompletionResponse(
while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
{
var __content = await reader.ReadLineAsync().ConfigureAwait(false) ?? string.Empty;
var streamedResponse = global::System.Text.Json.JsonSerializer.Deserialize(__content, global::Ollama.SourceGenerationContext.Default.GenerateCompletionResponse) ??
var streamedResponse = global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::Ollama.GenerateCompletionResponse), JsonSerializerContext) as global::Ollama.GenerateCompletionResponse ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");

yield return streamedResponse;
Expand Down
10 changes: 7 additions & 3 deletions src/libs/Ollama/Generated/Ollama.CompletionsClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Ollama
/// If no httpClient is provided, a new one will be created.<br/>
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
public sealed partial class CompletionsClient : global::System.IDisposable
public sealed partial class CompletionsClient : global::Ollama.ICompletionsClient, global::System.IDisposable
{
/// <summary>
/// Ollama server URL
Expand All @@ -17,6 +17,11 @@ public sealed partial class CompletionsClient : global::System.IDisposable

private readonly global::System.Net.Http.HttpClient _httpClient;

/// <summary>
///
/// </summary>
public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Ollama.SourceGenerationContext.Default;


/// <summary>
/// Creates a new instance of the CompletionsClient.
Expand All @@ -27,8 +32,7 @@ public sealed partial class CompletionsClient : global::System.IDisposable
/// <param name="baseUri"></param>
public CompletionsClient(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null
)
global::System.Uri? baseUri = null)
{
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
Expand Down
Loading

0 comments on commit f00eb70

Please sign in to comment.