OkGoDoIt / OpenAI-API-dotnet

An unofficial C#/.NET SDK for accessing the OpenAI GPT-3 API
https://www.nuget.org/packages/OpenAI/
Other
1.86k stars 430 forks source link

Image Generation: DALL-E-3 #180

Closed elango-kamatchi closed 1 year ago

elango-kamatchi commented 1 year ago

How can we create image with version DALL-E-3?. Seems CreateImageAsync method, we don't have select of which version like DALL-E-2 or DALL-E-3.

lofcz commented 1 year ago

Dalle3 is supported in this fork: https://github.com/lofcz/OpenAiNg

elango-kamatchi commented 1 year ago

Hi lofcz, OpenAiNg supports only .NET Core >= 6.0, but my project is .NET Framework and version 4.7.2. So we cannot install OpenAiNg.

Dalle3 is supported in this fork: https://github.com/lofcz/OpenAiNg

lofcz commented 1 year ago

I'm sorry to hear that, to support Dalle3 upstream, you can do the following:

  1. Fork OpenAI-API-dotnet
  2. Copy & paste the following changes, these are all compatible with the original database:
  3. https://github.com/lofcz/OpenAiNg/commit/fb208ab37cbde43f4ddbb5e0e5cc4c152797d2cb
  4. https://github.com/lofcz/OpenAiNg/commit/936dcabc2e3f07c74fa9522eda059259bf65daf9
  5. https://github.com/lofcz/OpenAiNg/commit/184465a858d5ee47ebd7eebc2b0de0d144a4782f

Hope this helps.

elango-kamatchi commented 1 year ago

Thank you lofcz.

VinceGsm commented 1 year ago

Hello @lofcz , i have the same question this issue have. With OpenAiNg, how can you choose between Dall-E v2 and v3 (not v3 HD) or does it automatically consume the v3 ?

lofcz commented 1 year ago

In OpenAiNg, just provide either Dalle2 or Dalle3 as the model in the ImageGenerate request. HD needs to be toggled on manually as another argument.

Here is an example for dalle3:

OpenAiApi conn = OpenAiService.Connect(); // replace this line with your connection, something like new OpenAiApi("your_key")
ImageResult? il = await conn?.ImageGenerations.CreateImageAsync(new ImageGenerationRequest
{
    Prompt = "A lion",
    Size = ImageSize._1024,
    Model = Model.Dalle3,
    Quality = ImageQuality.Hd // ImageQuality.Standard by default
});   

(note the Quality setting)

And here for dalle2:

OpenAiApi conn = OpenAiService.Connect(); // replace this line with your connection, something like new OpenAiApi("your_key")
ImageResult? il = await conn?.ImageGenerations.CreateImageAsync(new ImageGenerationRequest
{
    Prompt = "A lion",
    Size = ImageSize._512,
    Model = Model.Dalle2
});   

Note OpenAiNg already supports the newly added Size options, exclusive for Dalle3 and also vivid / natural style. Hope this helps @VinceGsm

VinceGsm commented 1 year ago

Many thanks @lofcz OpenAiNg is exactly what I was looking for. Have a great day !