openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.1.0-beta.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/Custom/Images/GeneratedImageSize.cs

79lines · modecode

1using System;
2
3namespace OpenAI.Images;
4
5// CUSTOM: Added custom struct in favor of the generated extensible enum.
6/// <summary> The size of the image that will be generated. </summary>
7[CodeGenModel("CreateImageRequestSize")]
8[CodeGenSuppress("GeneratedImageSize", typeof(string))]
9[CodeGenSuppress("op_Implicit", typeof(string))]
10public readonly partial struct GeneratedImageSize : IEquatable<GeneratedImageSize>
11{
12 private readonly string _value;
13
14 /// <summary> Initializes a new instance of <see cref="GeneratedImageSize"/>. </summary>
15 /// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception>
16 internal GeneratedImageSize(string value)
17 {
18 _value = value ?? throw new ArgumentNullException(nameof(value));
19 }
20
21 /// <summary>
22 /// Creates a new instance of <see cref="GeneratedImageSize"/>.
23 /// </summary>
24 /// <remarks>
25 /// <b>Note:</b> arbitrary dimensions are not supported and a given model will only support a set of predefined
26 /// sizes. If supported dimensions are not known, try using one of the static properties like <see cref="W1024xH1024"/>.
27 /// </remarks>
28 /// <param name="width"> The desired width, in pixels, for an image. </param>
29 /// <param name="height"> The desired height, in pixels, for an image. </param>
30 public GeneratedImageSize(int width, int height)
31 {
32 _value = $"{width}x{height}";
33 }
34
35 /// <summary>
36 /// A small, square image with 256 pixels of both width and height.
37 /// <para>
38 /// Supported <b>only</b> for the older <c>dall-e-2</c> model.
39 /// </para>
40 /// </summary>
41 [CodeGenMember("_256x256")]
42 public static readonly GeneratedImageSize W256xH256 = new(256, 256);
43
44 /// <summary>
45 /// A medium-small, square image with 512 pixels of both width and height.
46 /// <para>
47 /// Supported <b>only</b> for the older <c>dall-e-2</c> model.
48 /// </para>
49 /// </summary>
50 [CodeGenMember("_512x512")]
51 public static readonly GeneratedImageSize W512xH512 = new(512, 512);
52
53 /// <summary>
54 /// A square image with 1024 pixels of both width and height.
55 /// <para>
56 /// <b>Supported</b> and <b>default</b> for both <c>dall-e-2</c> and <c>dall-e-3</c> models.
57 /// </para>
58 /// </summary>
59 [CodeGenMember("_1024x1024")]
60 public static readonly GeneratedImageSize W1024xH1024 = new(1024, 1024);
61
62 /// <summary>
63 /// An extra tall image, 1024 pixels wide by 1792 pixels high.
64 /// <para>
65 /// Supported <b>only</b> for the <c>dall-e-3</c> model.
66 /// </para>
67 /// </summary>
68 [CodeGenMember("_1792x1024")]
69 public static readonly GeneratedImageSize W1024xH1792 = new(1024, 1792);
70
71 /// <summary>
72 /// An extra wide image, 1792 pixels wide by 1024 pixels high.
73 /// <para>
74 /// Supported <b>only</b> for the <c>dall-e-3</c> model.
75 /// </para>
76 /// </summary>
77 [CodeGenMember("_1024x1792")]
78 public static readonly GeneratedImageSize W1792xH1024 = new(1792, 1024);
79}