This plugin uses the OpenAI Python API to submit a prompt to the DALL-E 3 model and return the resulting URL.
To use this plugin, you must have an OpenAI API key.
This project uses python-dotenv
to manage configuration files. To set up the configuration file, you need to have a .env
file in the root of the project with the following contents:
OPENAI_API_KEY="<your api key>"
The source code includes a requirements.txt
file that lists the required packages. You can install them with pip install -r requirements.txt
. You can also simply install the semantic-kernel
and the python-dotenv
packages and they'll bring in the rest of the dependencies.
Using the plugin is straightforward. With the plugin in your code directory, you can call it like this:
import asyncio
import semantic_kernel as sk
from Plugins import Dalle3
async def main():
kernel = sk.Kernel()
animal_str = "A painting of a cat sitting in a sofa in the impressionist style"
dalle3 = kernel.import_skill(Dalle3())
animal_pic_url = await kernel.run_async(
dalle3['ImageFromPrompt'],
input_str=animal_str
)
print(animal_pic_url)
if __name__ == "__main__":
asyncio.run(main())
The plugin will return a URL to the image generated by DALL-E 3.