Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.53 KB

README.md

File metadata and controls

46 lines (31 loc) · 1.53 KB

A DALL-E 3 Python Native Plugin for Semantic Kernel v1.0.1

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.

Setting up the configuration 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>"

Required packages

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.

Calling the plugin with Semantic Kernel 1.0.1

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.

Sample returned image

An impressionist painting of a cat sitting in a sofa