Skip to content

Python repository for a plugin that allows Semantic Kernel to access DALL-E 3

License

Notifications You must be signed in to change notification settings

MeyerPerin-Foundation/dalle3-sk-plugin-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Python repository for a plugin that allows Semantic Kernel to access DALL-E 3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages