openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0-beta.12

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Images/GeneratedImageSize.cs

81lines · modecode

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