betalgo / openai

OpenAI .NET sdk - Azure OpenAI, ChatGPT, Whisper, and DALL-E
https://betalgo.github.io/openai/
MIT License
2.85k stars 513 forks source link

Expose Dall-E 3 revised prompt in the API #430

Closed taurit closed 7 months ago

taurit commented 7 months ago

Is your feature request related to a problem? Please describe.

Not a bug, just a request for a small feature that I find useful. I am trying to diagnose why images generated by Dall-E 3 API typically look worse/overly simplistic compared to those generated in ChatGPT Plus, despite using the same prompts.

Describe the solution you'd like

The image generation endpoint (https://api.openai.com/v1/images/generations), when used with the Dall-E 3 model, rewrites prompts and uses rewritten prompts to generate images instead of the original one. The API returns such a rewritten prompt in a response in the revised_prompt.

I would like to have this re-written prompt exposed as a C# property, so it's available to my application. The right place for it seems to be the ImageDataResult model.

Describe alternatives you've considered

I can switch to a tool like Postman or Insomnia to look into responses while debugging, but it would be convenient to have the whole response available in C# response model.

Additional context

For convenience, here's an example of a request and a response using DALL-E 3 API, illustrating the new property:

Request:

POST https://api.openai.com/v1/images/generations

{
  "model": "dall-e-3",
  "prompt": "Please generate a picture illustrating the following scene: 'a boy going through a tunnel, lit by torches on the walls, with a low ceiling'",
  "n": 1,
  "size": "1024x1024"
}

Response:

{
  "created": 1700428224,
  "data": [
    {
      "revised_prompt": "Visualize a scene depicting an African adolescent boy adventuring through a narrow tunnel. The tunnel has a low ceiling, posing a physical challenge for the adventurer. The lighting is dim, provided only by torches mounted intermittently along the tunnel walls. The flickering flames from these torches cast contrasting shadows, enhancing the mysterious ambiance of the surrounding environment.",
      "url": "https://oaidalleapiprodscus.blob.core.windows.net/(...)"
    }
  ]
}

Thanks for considering the feature, and for the great work so far!

belaszalontai commented 7 months ago

See this PR: https://github.com/betalgo/openai/pull/435