diff --git a/OpenAI_API/EndpointBase.cs b/OpenAI_API/EndpointBase.cs index d981c7e..20556db 100644 --- a/OpenAI_API/EndpointBase.cs +++ b/OpenAI_API/EndpointBase.cs @@ -27,7 +27,7 @@ public abstract class EndpointBase /// Constructor of the api endpoint base, to be called from the contructor of any devived classes. Rather than instantiating any endpoint yourself, access it through an instance of . /// /// - internal EndpointBase(OpenAIAPI api) + protected EndpointBase(OpenAIAPI api) { this._Api = api; } diff --git a/OpenAI_Tests/ImageGenerationEndpointTests.cs b/OpenAI_Tests/ImageGenerationEndpointTests.cs index 94c31fb..9a241b2 100644 --- a/OpenAI_Tests/ImageGenerationEndpointTests.cs +++ b/OpenAI_Tests/ImageGenerationEndpointTests.cs @@ -51,8 +51,8 @@ public void CreateDALLE2ImageWithUrl(string size) var api = new OpenAI_API.OpenAIAPI(); Assert.IsNotNull(api.ImageGenerations); - - var results = api.ImageGenerations.CreateImageAsync(new ImageGenerationRequest("A cyberpunk monkey hacker dreaming of a beautiful bunch of bananas, digital art", 2, new ImageSize(size))).Result; + + var results = api.ImageGenerations.CreateImageAsync(new ImageGenerationRequest("A cyberpunk monkey hacker dreaming of a beautiful bunch of bananas, digital art", 2, ConstructImageSize(size))).Result; Assert.IsNotNull(results); if (results.CreatedUnixTime.HasValue) { @@ -108,9 +108,9 @@ public void CreateDALLE3ImageWithUrl(string quality, string size) { var api = new OpenAI_API.OpenAIAPI(); - Assert.IsNotNull(api.ImageGenerations); + Assert.IsNotNull(api.ImageGenerations); - var results = api.ImageGenerations.CreateImageAsync(new ImageGenerationRequest("A cyberpunk monkey hacker dreaming of a beautiful bunch of bananas, digital art", OpenAI_API.Models.Model.DALLE3, new ImageSize(size), quality)).Result; + var results = api.ImageGenerations.CreateImageAsync(new ImageGenerationRequest("A cyberpunk monkey hacker dreaming of a beautiful bunch of bananas, digital art", OpenAI_API.Models.Model.DALLE3, ConstructImageSize(size), quality)).Result; Assert.IsNotNull(results); if (results.CreatedUnixTime.HasValue) { @@ -139,9 +139,9 @@ public void BadParameterCombosShouldFail(string model, string quality, string si { var api = new OpenAI_API.OpenAIAPI(); - Assert.IsNotNull(api.ImageGenerations); + Assert.IsNotNull(api.ImageGenerations); - Assert.ThrowsAsync(async () => await api.ImageGenerations.CreateImageAsync(new ImageGenerationRequest("A cyberpunk monkey hacker dreaming of a beautiful bunch of bananas, digital art", model, new ImageSize(size), quality))); + Assert.ThrowsAsync(async () => await api.ImageGenerations.CreateImageAsync(new ImageGenerationRequest("A cyberpunk monkey hacker dreaming of a beautiful bunch of bananas, digital art", model, ConstructImageSize(size), quality))); } [Test] @@ -157,6 +157,17 @@ public void BadNumImagesWithDalle3ShouldFail() Assert.ThrowsAsync(async () => await api.ImageGenerations.CreateImageAsync(req)); } + private ImageSize ConstructImageSize(string size) + => size switch + { + "256x256" => ImageSize._256, + "512x512" => ImageSize._512, + "1024x1024" => ImageSize._1024, + "1024x1792" => ImageSize._1024x1792, + "1792x1024" => ImageSize._1792x1024, + _ => ImageSize._256 + }; + } }