Skip to content

Commit

Permalink
fix: Fixed OpenAI issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 6, 2024
1 parent 17c135c commit b613000
Show file tree
Hide file tree
Showing 72 changed files with 4,911 additions and 8,820 deletions.
12,252 changes: 3,610 additions & 8,642 deletions specs/openai.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<PropertyGroup Label="Versioning">
<Version>0.12.0</Version>
<Version>0.12.1</Version>
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerDefaultPreReleaseIdentifiers>dev</MinVerDefaultPreReleaseIdentifiers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static string PreparePath(
{
return string.Empty;
}
if (schema.Value.Enum.Any() && schema.Value.Default != null)
if (schema.Value.Enum.Any() && schema.Value.Default is OpenApiString enumString && !string.IsNullOrWhiteSpace(enumString.Value))
{
return type.CSharpType.TrimEnd('?') + "." + schema.Value.Default.ToEnumValue().Name;
}
Expand All @@ -107,7 +107,7 @@ public static string PreparePath(
}, parents);
return typeData.CSharpType.TrimEnd('?') + "." + schema.Value.Default.ToEnumValue().Name;
}
if (schema.Value.Default is OpenApiString @string)
if (schema.Value.Default is OpenApiString @string && !string.IsNullOrWhiteSpace(@string.Value))
{
return $"\"{@string.Value}\"";
}
Expand Down Expand Up @@ -180,15 +180,15 @@ public static string ClearForXml(this string text)
return any switch
{
OpenApiNull => null,
OpenApiString @string => @string.Value,
OpenApiString @string => string.IsNullOrWhiteSpace(@string.Value) ? null : @string.Value,
OpenApiInteger integer => integer.Value.ToString(CultureInfo.InvariantCulture),
OpenApiLong @long => @long.Value.ToString(CultureInfo.InvariantCulture),
OpenApiFloat @float => @float.Value.ToString(CultureInfo.InvariantCulture),
OpenApiDouble @double => @double.Value.ToString(CultureInfo.InvariantCulture),
OpenApiBoolean boolean => boolean.Value ? "true" : "false",
OpenApiArray array => $"[{string.Join(", ", array.Select(GetString))}]",
//OpenApiObject @object => $"{{{string.Join(", ", @object.Select(x => $"{x.Key}: {GetString(x.Value)}"))}}}",
_ => string.Empty,
_ => null,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed partial class ChatCompletionChoice
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("finish_reason")]
public string? FinishReason { get; set; } = "";
public string? FinishReason { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public sealed partial class ChatCompletionFunctionCall
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("name")]
public string? Name { get; set; } = "";
public string? Name { get; set; }

/// <summary>
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("arguments")]
public string? Arguments { get; set; } = "";
public string? Arguments { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class ChatCompletionFunctionParameters
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("type")]
public string? Type { get; set; } = "";
public string? Type { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public sealed partial class ChatCompletionFunctions
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("name")]
public string? Name { get; set; } = "";
public string? Name { get; set; }

/// <summary>
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("description")]
public string? Description { get; set; } = "";
public string? Description { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class ChatCompletionRequestMessage
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("role")]
public string? Role { get; set; } = "";
public string? Role { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class ChatCompletionResponseMessage
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("role")]
public string? Role { get; set; } = "";
public string? Role { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class Choice
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("text")]
public string? Text { get; set; } = "";
public string? Text { get; set; }

/// <summary>
/// Default Value: 0
Expand All @@ -31,7 +31,7 @@ public sealed partial class Choice
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("finish_reason")]
public string? FinishReason { get; set; } = "";
public string? FinishReason { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed partial class CreateChatCompletionRequest
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("model")]
public string? Model { get; set; } = "";
public string? Model { get; set; }

/// <summary>
/// Default Value: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public sealed partial class CreateChatCompletionResponse
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("id")]
public string? Id { get; set; } = "";
public string? Id { get; set; }

/// <summary>
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("object")]
public string? Object { get; set; } = "";
public string? Object { get; set; }

/// <summary>
/// Default Value: 0
Expand All @@ -31,7 +31,7 @@ public sealed partial class CreateChatCompletionResponse
///
/// </summary>
[global::Newtonsoft.Json.JsonProperty("model")]
public string? Model { get; set; } = "";
public string? Model { get; set; }

/// <summary>
/// Default Value: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed partial class ChatCompletionChoice
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("finish_reason")]
public string? FinishReason { get; set; } = "";
public string? FinishReason { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public sealed partial class ChatCompletionFunctionCall
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("name")]
public string? Name { get; set; } = "";
public string? Name { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("arguments")]
public string? Arguments { get; set; } = "";
public string? Arguments { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class ChatCompletionFunctionParameters
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("type")]
public string? Type { get; set; } = "";
public string? Type { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public sealed partial class ChatCompletionFunctions
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("name")]
public string? Name { get; set; } = "";
public string? Name { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("description")]
public string? Description { get; set; } = "";
public string? Description { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class ChatCompletionRequestMessage
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("role")]
public string? Role { get; set; } = "";
public string? Role { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class ChatCompletionResponseMessage
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("role")]
public string? Role { get; set; } = "";
public string? Role { get; set; }

/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed partial class Choice
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("text")]
public string? Text { get; set; } = "";
public string? Text { get; set; }

/// <summary>
/// Default Value: 0
Expand All @@ -31,7 +31,7 @@ public sealed partial class Choice
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("finish_reason")]
public string? FinishReason { get; set; } = "";
public string? FinishReason { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed partial class CreateChatCompletionRequest
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
public string? Model { get; set; } = "";
public string? Model { get; set; }

/// <summary>
/// Default Value: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public sealed partial class CreateChatCompletionResponse
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("id")]
public string? Id { get; set; } = "";
public string? Id { get; set; }

/// <summary>
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("object")]
public string? Object { get; set; } = "";
public string? Object { get; set; }

/// <summary>
/// Default Value: 0
Expand All @@ -31,7 +31,7 @@ public sealed partial class CreateChatCompletionResponse
///
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("model")]
public string? Model { get; set; } = "";
public string? Model { get; set; }

/// <summary>
/// Default Value: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public partial class ChatClient
/// <param name="presencePenalty"></param>
/// <param name="responseFormat"></param>
/// <param name="seed"></param>
/// <param name="serviceTier"></param>
/// <param name="stop"></param>
/// <param name="stream"></param>
/// <param name="streamOptions"></param>
Expand All @@ -85,6 +86,7 @@ public partial class ChatClient
double? presencePenalty = 0,
global::G.CreateChatCompletionRequestResponseFormat? responseFormat = default,
int? seed = default,
global::G.CreateChatCompletionRequestServiceTier? serviceTier = default,
global::System.OneOf<string?, global::System.Collections.Generic.IList<string?>?>? stop = default,
bool? stream = false,
global::G.ChatCompletionStreamOptions? streamOptions = default,
Expand All @@ -109,6 +111,7 @@ public partial class ChatClient
PresencePenalty = presencePenalty,
ResponseFormat = responseFormat,
Seed = seed,
ServiceTier = serviceTier,
Stop = stop,
Stream = stream,
StreamOptions = streamOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public sealed partial class AssistantObject
public string? Instructions { get; set; } = default!;

/// <summary>
/// A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.<br/>
/// Default Value: []
/// A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.
/// </summary>
[global::Newtonsoft.Json.JsonProperty("tools", Required = global::Newtonsoft.Json.Required.Always)]
public global::System.Collections.Generic.IList<global::System.OneOf<global::G.AssistantToolsCode?, global::G.AssistantToolsFileSearch?, global::G.AssistantToolsFunction?>> Tools { get; set; } = default!;
Expand All @@ -73,7 +72,7 @@ public sealed partial class AssistantObject
public object? Metadata { get; set; } = default!;

/// <summary>
/// run_temperature_description | What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.<br/>
/// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.<br/>
/// Default Value: 1<br/>
/// Example: 1
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace G
public sealed partial class AssistantObjectToolResourcesCodeInterpreter
{
/// <summary>
/// A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.<br/>
/// Default Value: []
/// A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.
/// </summary>
[global::Newtonsoft.Json.JsonProperty("file_ids")]
public global::System.Collections.Generic.IList<string?>? FileIds { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public sealed partial class CreateAssistantRequest
public string? Instructions { get; set; }

/// <summary>
/// A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.<br/>
/// Default Value: []
/// A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.
/// </summary>
[global::Newtonsoft.Json.JsonProperty("tools")]
public global::System.Collections.Generic.IList<global::System.OneOf<global::G.AssistantToolsCode?, global::G.AssistantToolsFileSearch?, global::G.AssistantToolsFunction?>?>? Tools { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace G
public sealed partial class CreateAssistantRequestToolResourcesCodeInterpreter
{
/// <summary>
/// A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.<br/>
/// Default Value: []
/// A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.
/// </summary>
[global::Newtonsoft.Json.JsonProperty("file_ids")]
public global::System.Collections.Generic.IList<string?>? FileIds { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ public sealed partial class CreateChatCompletionRequest
[global::Newtonsoft.Json.JsonProperty("seed")]
public int? Seed { get; set; }

/// <summary>
/// Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:<br/>
/// - If set to 'auto', the system will utilize scale tier credits until they are exhausted.<br/>
/// - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.<br/>
/// When this parameter is set, the response body will include the `service_tier` utilized.
/// </summary>
[global::Newtonsoft.Json.JsonProperty("service_tier")]
public global::G.CreateChatCompletionRequestServiceTier? ServiceTier { get; set; }

/// <summary>
/// Up to 4 sequences where the API will stop generating further tokens.
/// </summary>
Expand Down
Loading

0 comments on commit b613000

Please sign in to comment.