Awesome
Image Gen Demo
At a very high level, this demo uses generative AI with OpenAI to take in prompts, generates images with Dall-E and places them into a database. It consists of three parts, which are explained later.
Table of Contents
Prerequisites
Have the following CLIs:
TODO: add kubens to not need -n gen
Other:
- An OpenAI API key and API access
TODO: add docs link
Infrastructure
We will need a:
- Kubernetes cluster
- Container registry
- PostgreSQL database
Set up DigitalOcean Infrastructure
If you use the Hivenetes k8s boostrapper you can have it create all of these resources for you:
- Clone https://github.com/hivenetes/k8s-bootstrapper
- Follow the Terraform instructions
Note: Enable the database in
bootstrapper.tfvars
before runningterraform plan
. You can also enable the container registry if you want to use it instead of Docker Hub.
Architecture
Applications
Launcher
This application takes in prompts for OpenAI and launches jobs for each prompt.
Image Generator and Database store
This app uses bash to talk to the OpenAI API to create a Dall-E image. It then stores these prompts and image URLs into a database.
Database
This is a Java application that uses Spring Data and Spring Web to create a database table and REST endpoint to make GET and POST requests. It's specifically for a PostgreSQL database.
Things to do
- Create gen namespace
kubectl apply -f k8s/namespace.yaml
- Create and run database app
- Create and run image generator and store app
- Create and run launcher app
- Observability
TODO
Mandatory by VMware Explore/SpringOne talk
- Display prompts and URLs as images on webpage
- Convert all bash to Java+Spring
Ideal by Explore
- Use secrets for OpenAI key
Future work
- Use DigitalOcean spaces to store secrets
- Use secrets for database application.properties
- Create service account vs using default one
- Have a webpage to put prompts into vs running a pod
- Add image creation dates so the database can drop anything that has a timestamp before a current subset -- e.g. OpenAI Dall-E only stores images for an hour, so after this, the URLs don't work.
- Add tests