openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
achandmsft-patch-1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Images/GeneratedImageSize.cs

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