Skip to content

Commit

Permalink
fix: Fixed trimming/CLS compliant.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 18, 2024
1 parent 8e83ca6 commit 27600ff
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 57 deletions.
6 changes: 0 additions & 6 deletions src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)../key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup Label="CLSCompliant">
<AssemblyAttribute Include="System.CLSCompliantAttribute">
<_Parameter1>false</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<PropertyGroup Label="Nuget">
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ partial void ProcessCreateImageResponseContent(
int? n = 1,
global::OpenAI.CreateImageRequestQuality? quality = global::OpenAI.CreateImageRequestQuality.Standard,
global::OpenAI.CreateImageRequestResponseFormat? responseFormat = global::OpenAI.CreateImageRequestResponseFormat.Url,
global::OpenAI.CreateImageRequestSize? size = global::OpenAI.CreateImageRequestSize._1024x1024,
global::OpenAI.CreateImageRequestSize? size = global::OpenAI.CreateImageRequestSize.x1024x1024,
global::OpenAI.CreateImageRequestStyle? style = global::OpenAI.CreateImageRequestStyle.Vivid,
string? user = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ partial void ProcessCreateImageEditResponseContent(
byte[]? mask = default,
global::System.AnyOf<string?, global::OpenAI.CreateImageEditRequestModel?>? model = default,
int? n = 1,
global::OpenAI.CreateImageEditRequestSize? size = global::OpenAI.CreateImageEditRequestSize._1024x1024,
global::OpenAI.CreateImageEditRequestSize? size = global::OpenAI.CreateImageEditRequestSize.x1024x1024,
global::OpenAI.CreateImageEditRequestResponseFormat? responseFormat = global::OpenAI.CreateImageEditRequestResponseFormat.Url,
string? user = default,
global::System.Threading.CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ partial void ProcessCreateImageVariationResponseContent(
global::System.AnyOf<string?, global::OpenAI.CreateImageVariationRequestModel?>? model = default,
int? n = 1,
global::OpenAI.CreateImageVariationRequestResponseFormat? responseFormat = global::OpenAI.CreateImageVariationRequestResponseFormat.Url,
global::OpenAI.CreateImageVariationRequestSize? size = global::OpenAI.CreateImageVariationRequestSize._1024x1024,
global::OpenAI.CreateImageVariationRequestSize? size = global::OpenAI.CreateImageVariationRequestSize.x1024x1024,
string? user = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum CreateBatchRequestCompletionWindow
/// <summary>
///
/// </summary>
_24h,
x24h,
}

/// <summary>
Expand All @@ -26,7 +26,7 @@ public static string ToValueString(this CreateBatchRequestCompletionWindow value
{
return value switch
{
CreateBatchRequestCompletionWindow._24h => "24h",
CreateBatchRequestCompletionWindow.x24h => "24h",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
Expand All @@ -37,7 +37,7 @@ public static string ToValueString(this CreateBatchRequestCompletionWindow value
{
return value switch
{
"24h" => CreateBatchRequestCompletionWindow._24h,
"24h" => CreateBatchRequestCompletionWindow.x24h,
_ => null,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public sealed partial class CreateImageEditRequest
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("size")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.CreateImageEditRequestSizeJsonConverter))]
public global::OpenAI.CreateImageEditRequestSize? Size { get; set; } = global::OpenAI.CreateImageEditRequestSize._1024x1024;
public global::OpenAI.CreateImageEditRequestSize? Size { get; set; } = global::OpenAI.CreateImageEditRequestSize.x1024x1024;

/// <summary>
/// The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public enum CreateImageEditRequestSize
/// <summary>
///
/// </summary>
_256x256,
x256x256,
/// <summary>
///
/// </summary>
_512x512,
x512x512,
/// <summary>
///
/// </summary>
_1024x1024,
x1024x1024,
}

/// <summary>
Expand All @@ -36,9 +36,9 @@ public static string ToValueString(this CreateImageEditRequestSize value)
{
return value switch
{
CreateImageEditRequestSize._256x256 => "256x256",
CreateImageEditRequestSize._512x512 => "512x512",
CreateImageEditRequestSize._1024x1024 => "1024x1024",
CreateImageEditRequestSize.x256x256 => "256x256",
CreateImageEditRequestSize.x512x512 => "512x512",
CreateImageEditRequestSize.x1024x1024 => "1024x1024",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
Expand All @@ -49,9 +49,9 @@ public static string ToValueString(this CreateImageEditRequestSize value)
{
return value switch
{
"256x256" => CreateImageEditRequestSize._256x256,
"512x512" => CreateImageEditRequestSize._512x512,
"1024x1024" => CreateImageEditRequestSize._1024x1024,
"256x256" => CreateImageEditRequestSize.x256x256,
"512x512" => CreateImageEditRequestSize.x512x512,
"1024x1024" => CreateImageEditRequestSize.x1024x1024,
_ => null,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public sealed partial class CreateImageRequest
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("size")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.CreateImageRequestSizeJsonConverter))]
public global::OpenAI.CreateImageRequestSize? Size { get; set; } = global::OpenAI.CreateImageRequestSize._1024x1024;
public global::OpenAI.CreateImageRequestSize? Size { get; set; } = global::OpenAI.CreateImageRequestSize.x1024x1024;

/// <summary>
/// The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`.<br/>
Expand Down
30 changes: 15 additions & 15 deletions src/libs/OpenAI/Generated/OpenAI.Models.CreateImageRequestSize.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ public enum CreateImageRequestSize
/// <summary>
///
/// </summary>
_256x256,
x256x256,
/// <summary>
///
/// </summary>
_512x512,
x512x512,
/// <summary>
///
/// </summary>
_1024x1024,
x1024x1024,
/// <summary>
///
/// </summary>
_1792x1024,
x1792x1024,
/// <summary>
///
/// </summary>
_1024x1792,
x1024x1792,
}

/// <summary>
Expand All @@ -44,11 +44,11 @@ public static string ToValueString(this CreateImageRequestSize value)
{
return value switch
{
CreateImageRequestSize._256x256 => "256x256",
CreateImageRequestSize._512x512 => "512x512",
CreateImageRequestSize._1024x1024 => "1024x1024",
CreateImageRequestSize._1792x1024 => "1792x1024",
CreateImageRequestSize._1024x1792 => "1024x1792",
CreateImageRequestSize.x256x256 => "256x256",
CreateImageRequestSize.x512x512 => "512x512",
CreateImageRequestSize.x1024x1024 => "1024x1024",
CreateImageRequestSize.x1792x1024 => "1792x1024",
CreateImageRequestSize.x1024x1792 => "1024x1792",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
Expand All @@ -59,11 +59,11 @@ public static string ToValueString(this CreateImageRequestSize value)
{
return value switch
{
"256x256" => CreateImageRequestSize._256x256,
"512x512" => CreateImageRequestSize._512x512,
"1024x1024" => CreateImageRequestSize._1024x1024,
"1792x1024" => CreateImageRequestSize._1792x1024,
"1024x1792" => CreateImageRequestSize._1024x1792,
"256x256" => CreateImageRequestSize.x256x256,
"512x512" => CreateImageRequestSize.x512x512,
"1024x1024" => CreateImageRequestSize.x1024x1024,
"1792x1024" => CreateImageRequestSize.x1792x1024,
"1024x1792" => CreateImageRequestSize.x1024x1792,
_ => null,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public sealed partial class CreateImageVariationRequest
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("size")]
[global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.CreateImageVariationRequestSizeJsonConverter))]
public global::OpenAI.CreateImageVariationRequestSize? Size { get; set; } = global::OpenAI.CreateImageVariationRequestSize._1024x1024;
public global::OpenAI.CreateImageVariationRequestSize? Size { get; set; } = global::OpenAI.CreateImageVariationRequestSize.x1024x1024;

/// <summary>
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public enum CreateImageVariationRequestSize
/// <summary>
///
/// </summary>
_256x256,
x256x256,
/// <summary>
///
/// </summary>
_512x512,
x512x512,
/// <summary>
///
/// </summary>
_1024x1024,
x1024x1024,
}

/// <summary>
Expand All @@ -36,9 +36,9 @@ public static string ToValueString(this CreateImageVariationRequestSize value)
{
return value switch
{
CreateImageVariationRequestSize._256x256 => "256x256",
CreateImageVariationRequestSize._512x512 => "512x512",
CreateImageVariationRequestSize._1024x1024 => "1024x1024",
CreateImageVariationRequestSize.x256x256 => "256x256",
CreateImageVariationRequestSize.x512x512 => "512x512",
CreateImageVariationRequestSize.x1024x1024 => "1024x1024",
_ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null),
};
}
Expand All @@ -49,9 +49,9 @@ public static string ToValueString(this CreateImageVariationRequestSize value)
{
return value switch
{
"256x256" => CreateImageVariationRequestSize._256x256,
"512x512" => CreateImageVariationRequestSize._512x512,
"1024x1024" => CreateImageVariationRequestSize._1024x1024,
"256x256" => CreateImageVariationRequestSize.x256x256,
"512x512" => CreateImageVariationRequestSize.x512x512,
"1024x1024" => CreateImageVariationRequestSize.x1024x1024,
_ => null,
};
}
Expand Down
14 changes: 14 additions & 0 deletions src/libs/OpenAI/OpenAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,18 @@
<None Include="..\OpenAI.Generators\bin\$(Configuration)\netstandard2.0\System.Collections.Immutable.dll" Pack="true" PackagePath="analyzers/dotnet" Visible="false" />
</ItemGroup>

<ItemGroup Label="CLSCompliant">
<AssemblyAttribute Include="System.CLSCompliantAttribute">
<_Parameter1>true</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<PropertyGroup Label="Trimmable" Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<IsAotCompatible>true</IsAotCompatible>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
<SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
</PropertyGroup>

</Project>
18 changes: 9 additions & 9 deletions src/libs/OpenAI/Prices/Prices.Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ public static partial class Prices

return (model, quality.Value, size) switch
{
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Standard, CreateImageRequestSize._1024x1024) => 0.040,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Standard, CreateImageRequestSize._1024x1792) => 0.080,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Standard, CreateImageRequestSize._1792x1024) => 0.080,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Standard, CreateImageRequestSize.x1024x1024) => 0.040,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Standard, CreateImageRequestSize.x1024x1792) => 0.080,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Standard, CreateImageRequestSize.x1792x1024) => 0.080,

(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Hd, CreateImageRequestSize._1024x1024) => 0.080,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Hd, CreateImageRequestSize._1024x1792) => 0.120,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Hd, CreateImageRequestSize._1792x1024) => 0.120,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Hd, CreateImageRequestSize.x1024x1024) => 0.080,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Hd, CreateImageRequestSize.x1024x1792) => 0.120,
(CreateImageRequestModel.DallE3, CreateImageRequestQuality.Hd, CreateImageRequestSize.x1792x1024) => 0.120,

(CreateImageRequestModel.DallE2, _, CreateImageRequestSize._1024x1024) => 0.020,
(CreateImageRequestModel.DallE2, _, CreateImageRequestSize._512x512) => 0.018,
(CreateImageRequestModel.DallE2, _, CreateImageRequestSize._256x256) => 0.016,
(CreateImageRequestModel.DallE2, _, CreateImageRequestSize.x1024x1024) => 0.020,
(CreateImageRequestModel.DallE2, _, CreateImageRequestSize.x512x512) => 0.018,
(CreateImageRequestModel.DallE2, _, CreateImageRequestSize.x256x256) => 0.016,

_ => null,
};
Expand Down

0 comments on commit 27600ff

Please sign in to comment.