Skip to content

Commit

Permalink
feat: To auto-updated workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 25, 2024
1 parent 9c64e17 commit 06157f1
Show file tree
Hide file tree
Showing 27 changed files with 341 additions and 797 deletions.
1 change: 0 additions & 1 deletion Ollama.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
src\Directory.Build.props = src\Directory.Build.props
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
LICENSE = LICENSE
docs\openapi.yaml = docs\openapi.yaml
README.md = README.md
.github\workflows\pull-request.yml = .github\workflows\pull-request.yml
EndProjectSection
Expand Down
58 changes: 54 additions & 4 deletions src/helpers/FixOpenApiSpec/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
using Microsoft.OpenApi;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Readers;

var path = args[0];
var text = await File.ReadAllTextAsync(path);

var openApiDocument = new OpenApiStringReader().Read(text, out var diagnostics);
//openApiDocument.Components.Schemas["ParallelToolCalls"]!.Default = null;
//openApiDocument.Components.Schemas["ParallelToolCalls"]!.Nullable = true;
openApiDocument.Components.Schemas["GenerateCompletionRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true);
openApiDocument.Components.Schemas["GenerateChatCompletionRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true);
openApiDocument.Components.Schemas["CreateModelRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true);
openApiDocument.Components.Schemas["PullModelRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true);
openApiDocument.Components.Schemas["PushModelRequest"]!.Properties["stream"]!.Default = new OpenApiBoolean(true);

ConvertToAnyOf(openApiDocument.Components.Schemas["DoneReason"]!);
ConvertToAnyOf(openApiDocument.Components.Schemas["CreateModelStatus"]!);
ConvertToAnyOf(openApiDocument.Components.Schemas["PullModelStatus"]!);

openApiDocument.Components.Schemas["PushModelResponse"]!.Properties["status"] = new OpenApiSchema
{
Description = "Status pushing the model.",
AnyOf = new List<OpenApiSchema>
{
new()
{
Type = "string",
},
new()
{
Type = "string",
Enum = new List<IOpenApiAny>
{
new OpenApiString("retrieving manifest"),
new OpenApiString("starting upload"),
new OpenApiString("pushing manifest"),
new OpenApiString("success"),
},
},
},
};

//openApiDocument.Components.Schemas["CreateEmbeddingRequest"]!.Properties["dimensions"].Nullable = true;

text = openApiDocument.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0);
_ = new OpenApiStringReader().Read(text, out diagnostics);
Expand All @@ -24,4 +55,23 @@
Environment.Exit(1);
}

await File.WriteAllTextAsync(path, text);
await File.WriteAllTextAsync(path, text);
return;

static void ConvertToAnyOf(OpenApiSchema schema)
{
schema.Type = null;
schema.AnyOf = new List<OpenApiSchema>
{
new()
{
Type = "string",
},
new()
{
Type = "string",
Enum = schema.Enum,
},
};
schema.Enum = null;
}
97 changes: 0 additions & 97 deletions src/libs/Ollama/Generated/JsonConverters.PushModelStatus.g.cs

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions src/libs/Ollama/Generated/JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ namespace Ollama
typeof(global::OpenApiGenerator.JsonConverters.PullModelStatusVariant2NullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PushModelResponseStatusJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PushModelResponseStatusNullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PushModelStatusVariant2JsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PushModelStatusVariant2NullableJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory2),
typeof(global::OpenApiGenerator.JsonConverters.DoneReasonJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.CreateModelStatusJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PullModelStatusJsonConverter),
typeof(global::OpenApiGenerator.JsonConverters.PushModelStatusJsonConverter),
})]

[global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ollama.JsonSerializerContextTypes))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ partial void ProcessGenerateChatCompletionResponse(
/// <param name="model">
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </param>
/// <param name="messages">
/// The messages of the chat, this can be used to keep a chat memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ partial void ProcessGenerateCompletionResponse(
/// <param name="model">
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </param>
/// <param name="prompt">
/// The prompt to generate a response.<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ partial void ProcessGenerateEmbeddingResponseContent(
/// <param name="model">
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </param>
/// <param name="prompt">
/// Text to generate embeddings for.<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed partial class CopyModelRequest
{
/// <summary>
/// Name of the model to copy.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("source")]
[global::System.Text.Json.Serialization.JsonRequired]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed partial class GenerateChatCompletionRequest
/// <summary>
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
[global::System.Text.Json.Serialization.JsonRequired]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed partial class GenerateChatCompletionResponse
/// <summary>
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
[global::System.Text.Json.Serialization.JsonRequired]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed partial class GenerateCompletionRequest
/// <summary>
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
[global::System.Text.Json.Serialization.JsonRequired]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed partial class GenerateCompletionResponse
/// <summary>
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
public string? Model { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed partial class GenerateEmbeddingRequest
/// <summary>
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
[global::System.Text.Json.Serialization.JsonRequired]
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Ollama/Generated/Ollama.Models.Model.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed partial class Model
/// <summary>
/// The model name. <br/>
/// Model names follow a `model:tag` format. Some examples are `orca-mini:3b-q4_1` and `llama3:70b`. The tag is optional and, if not provided, will default to `latest`. The tag is used to identify a specific version.<br/>
/// Example: llama3:8b
/// Example: llama3.1
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
public string? Model1 { get; set; }
Expand Down
Loading

0 comments on commit 06157f1

Please sign in to comment.