Skip to content

Commit

Permalink
feat: Removed default values - now I use it only in xml docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 24, 2024
1 parent 92750fa commit f921dda
Show file tree
Hide file tree
Showing 3,015 changed files with 7,889 additions and 7,876 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
25 changes: 18 additions & 7 deletions src/libs/AutoSDK/Extensions/OpenApiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ public static bool HasAllOfTypeForMetadata(
context = context ?? throw new ArgumentNullException(nameof(context));
context.TypeData = context.TypeData ?? throw new InvalidOperationException("Invalid state: TypeData is null");

if (context.TypeData.Value.CSharpType == "object?" || context.Schema.Default is OpenApiArray)
if (context.TypeData.Value.CSharpType == "object?" ||
context.Schema.Default is OpenApiArray ||
context.TypeData.Value.CSharpTypeNullability)
{
return string.Empty;
}
Expand All @@ -357,9 +359,12 @@ public static bool HasAllOfTypeForMetadata(
if (context.Schema.Enum.Any() && context.Schema.Default is OpenApiString enumString && !string.IsNullOrWhiteSpace(enumString.Value))
{
var @enum = context.ComputeEnum();
var value = @enum.TryGetValue(context.Schema.Default.GetString() ?? string.Empty, out var result) ? result.Name : "Unknown";
if (!@enum.TryGetValue(context.Schema.Default.GetString() ?? string.Empty, out var result))
{
return string.Empty;
}

return context.TypeData.Value.CSharpTypeWithoutNullability + "." + value;
return context.TypeData.Value.CSharpTypeWithoutNullability + "." + result.Name;
}
if (context.Schema.AnyOf.Any(x => x.Enum.Any()) && context.Schema.Default != null)
{
Expand Down Expand Up @@ -393,19 +398,25 @@ public static bool HasAllOfTypeForMetadata(
.Where(x => x.Hint is Hint.OneOf)
.First(x => x.Schema.Enum.Any());
var @enum = enumChildContext.ComputeEnum();
var value = @enum.TryGetValue(context.Schema.Default.GetString() ?? string.Empty, out var result) ? result.Name : "Unknown";
if (!@enum.TryGetValue(context.Schema.Default.GetString() ?? string.Empty, out var result))
{
return string.Empty;
}

return enumChildContext.TypeData?.CSharpTypeWithoutNullability + "." + value;
return enumChildContext.TypeData?.CSharpTypeWithoutNullability + "." + result.Name;
}
if (context.Schema.AllOf.Any(x => x.Enum.Any()) && context.Schema.Default != null)
{
var enumChildContext = context.Children
.Where(x => x.Hint is Hint.AllOf)
.First(x => x.Schema.Enum.Any());
var @enum = enumChildContext.ComputeEnum();
var value = @enum.TryGetValue(context.Schema.Default.GetString() ?? string.Empty, out var result) ? result.Name : "Unknown";
if (!@enum.TryGetValue(context.Schema.Default.GetString() ?? string.Empty, out var result))
{
return string.Empty;
}

return enumChildContext.TypeData?.CSharpTypeWithoutNullability + "." + value;
return enumChildContext.TypeData?.CSharpTypeWithoutNullability + "." + result.Name;
}
if (context.Schema.Default is OpenApiString @string && !string.IsNullOrWhiteSpace(@string.Value))
{
Expand Down
4 changes: 3 additions & 1 deletion src/libs/AutoSDK/Sources/Sources.Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ private static string GetDefaultValue(PropertyData property, bool isRequiredKeyw
return " = default!;";
}

return property.IsRequired || string.IsNullOrWhiteSpace(property.DefaultValue) ? string.Empty : $" = {property.DefaultValue};";
return property.Type.CSharpTypeNullability || string.IsNullOrWhiteSpace(property.DefaultValue)
? string.Empty
: $" = {property.DefaultValue};";
}

public static string GenerateClassModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ partial void ProcessV1ConversationalRagResponseContent(
string? path = default,
global::System.Collections.Generic.IList<string>? labels = default,
global::System.Collections.Generic.IList<string>? fileIds = default,
int? maxSegments = 15,
global::G.ConversationalRagFlowPublicFieldsRetrievalStrategy? retrievalStrategy = global::G.ConversationalRagFlowPublicFieldsRetrievalStrategy.Default,
double? retrievalSimilarityThreshold = 0.8,
int? maxSegments = default,
global::G.ConversationalRagFlowPublicFieldsRetrievalStrategy? retrievalStrategy = default,
double? retrievalSimilarityThreshold = default,
int? maxNeighbors = default,
double? hybridSearchAlpha = 0.98,
double? hybridSearchAlpha = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::G.ConversationalRagFlowPublicFields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ partial void ProcessV1EmbedResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1EmbedAsync(
global::System.Collections.Generic.IList<string> texts,
global::G.EmbedType? type = global::G.EmbedType.Segment,
global::G.EmbedType? type = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::G.EmbeddingsBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ partial void ProcessV1J2UltraChatResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::G.ChatResponse> V1J2UltraChatAsync(
global::G.LanguageStudioApiServerDataTypesJ2ChatChatRequest request,
string? model = "j2-ultra",
string? model = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -163,16 +163,16 @@ partial void ProcessV1J2UltraChatResponseContent(
public async global::System.Threading.Tasks.Task<global::G.ChatResponse> V1J2UltraChatAsync(
global::System.Collections.Generic.IList<global::G.ChatMessage> messages,
string system,
string? model = "j2-ultra",
string? model = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
global::G.Penalty? countPenalty = default,
int? numResults = 1,
double? temperature = 0.7,
int? maxTokens = 300,
int? minTokens = 0,
double? topP = 1,
int? topKReturn = 0,
int? numResults = default,
double? temperature = default,
int? maxTokens = default,
int? minTokens = default,
double? topP = default,
int? topKReturn = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ partial void ProcessV1J2GrandeCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2GrandeCompleteAsync(
global::G.CompletionBody request,
string? model = "j2-grande",
string? model = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -162,15 +162,15 @@ partial void ProcessV1J2GrandeCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2GrandeCompleteAsync(
string prompt,
string? model = "j2-grande",
int? numResults = 1,
int? maxTokens = 16,
int? minTokens = 0,
double? temperature = 1,
double? topP = 1,
double? minP = 0,
string? model = default,
int? numResults = default,
int? maxTokens = default,
int? minTokens = default,
double? temperature = default,
double? topP = default,
double? minP = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int? topKReturn = 0,
int? topKReturn = default,
object? logitBias = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ partial void ProcessV1J2GrandeCustomModelCompleteResponseContent(
public async global::System.Threading.Tasks.Task<string> V1J2GrandeCustomModelCompleteAsync(
string customModelName,
global::G.CompletionBody request,
string? customModelType = "j2-grande",
string? customModelType = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -170,15 +170,15 @@ partial void ProcessV1J2GrandeCustomModelCompleteResponseContent(
public async global::System.Threading.Tasks.Task<string> V1J2GrandeCustomModelCompleteAsync(
string customModelName,
string prompt,
string? customModelType = "j2-grande",
int? numResults = 1,
int? maxTokens = 16,
int? minTokens = 0,
double? temperature = 1,
double? topP = 1,
double? minP = 0,
string? customModelType = default,
int? numResults = default,
int? maxTokens = default,
int? minTokens = default,
double? temperature = default,
double? topP = default,
double? minP = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int? topKReturn = 0,
int? topKReturn = default,
object? logitBias = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ partial void ProcessV1J2GrandeInstructCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2GrandeInstructCompleteAsync(
global::G.CompletionBody request,
string? model = "j2-grande-instruct",
string? model = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -162,15 +162,15 @@ partial void ProcessV1J2GrandeInstructCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2GrandeInstructCompleteAsync(
string prompt,
string? model = "j2-grande-instruct",
int? numResults = 1,
int? maxTokens = 16,
int? minTokens = 0,
double? temperature = 1,
double? topP = 1,
double? minP = 0,
string? model = default,
int? numResults = default,
int? maxTokens = default,
int? minTokens = default,
double? temperature = default,
double? topP = default,
double? minP = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int? topKReturn = 0,
int? topKReturn = default,
object? logitBias = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ partial void ProcessV1J2JumboCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2JumboCompleteAsync(
global::G.CompletionBody request,
string? model = "j2-jumbo",
string? model = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -162,15 +162,15 @@ partial void ProcessV1J2JumboCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2JumboCompleteAsync(
string prompt,
string? model = "j2-jumbo",
int? numResults = 1,
int? maxTokens = 16,
int? minTokens = 0,
double? temperature = 1,
double? topP = 1,
double? minP = 0,
string? model = default,
int? numResults = default,
int? maxTokens = default,
int? minTokens = default,
double? temperature = default,
double? topP = default,
double? minP = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int? topKReturn = 0,
int? topKReturn = default,
object? logitBias = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ partial void ProcessV1J2JumboComplete2ResponseContent(
public async global::System.Threading.Tasks.Task<string> V1J2JumboComplete2Async(
string customModelName,
global::G.CompletionBody request,
string? customModelType = "j2-jumbo",
string? customModelType = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -170,15 +170,15 @@ partial void ProcessV1J2JumboComplete2ResponseContent(
public async global::System.Threading.Tasks.Task<string> V1J2JumboComplete2Async(
string customModelName,
string prompt,
string? customModelType = "j2-jumbo",
int? numResults = 1,
int? maxTokens = 16,
int? minTokens = 0,
double? temperature = 1,
double? topP = 1,
double? minP = 0,
string? customModelType = default,
int? numResults = default,
int? maxTokens = default,
int? minTokens = default,
double? temperature = default,
double? topP = default,
double? minP = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int? topKReturn = 0,
int? topKReturn = default,
object? logitBias = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ partial void ProcessV1J2JumboInstructCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2JumboInstructCompleteAsync(
global::G.CompletionBody request,
string? model = "j2-jumbo-instruct",
string? model = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -162,15 +162,15 @@ partial void ProcessV1J2JumboInstructCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2JumboInstructCompleteAsync(
string prompt,
string? model = "j2-jumbo-instruct",
int? numResults = 1,
int? maxTokens = 16,
int? minTokens = 0,
double? temperature = 1,
double? topP = 1,
double? minP = 0,
string? model = default,
int? numResults = default,
int? maxTokens = default,
int? minTokens = default,
double? temperature = default,
double? topP = default,
double? minP = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int? topKReturn = 0,
int? topKReturn = default,
object? logitBias = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ partial void ProcessV1J2LargeCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2LargeCompleteAsync(
global::G.CompletionBody request,
string? model = "j2-large",
string? model = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
Expand Down Expand Up @@ -162,15 +162,15 @@ partial void ProcessV1J2LargeCompleteResponseContent(
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<string> V1J2LargeCompleteAsync(
string prompt,
string? model = "j2-large",
int? numResults = 1,
int? maxTokens = 16,
int? minTokens = 0,
double? temperature = 1,
double? topP = 1,
double? minP = 0,
string? model = default,
int? numResults = default,
int? maxTokens = default,
int? minTokens = default,
double? temperature = default,
double? topP = default,
double? minP = default,
global::System.Collections.Generic.IList<string>? stopSequences = default,
int? topKReturn = 0,
int? topKReturn = default,
object? logitBias = default,
global::G.Penalty? frequencyPenalty = default,
global::G.Penalty? presencePenalty = default,
Expand Down
Loading

0 comments on commit f921dda

Please sign in to comment.