Generates descriptions and images of defined "assets" using AI. Saves the generated assets to a markdown file for use in Obsidian or other note-taking apps. Also generates a corresponding image. I created this to generate random RPG assets for use in my D&D campaign, but it can be used for any kind of asset generation.
-
Clone the repository:
git clone [email protected]:DrakeRichards/ai-asset-generator.git
-
Install the dependencies:
cd ai-asset-generator cargo build --release
-
If using the OpenAI API (default), set the
OPENAI_API_KEY
environment variable to your OpenAI API key. Alternatively, you can save this key in a .env file in the same directory as the binary. -
Check the help message for usage instructions:
./target/release/ai-asset-generator --help
Not yet implemented. I'll figure out how to do this later.
-
Download the compiled binary from the releases page.
-
If using the OpenAI API (default), set the
OPENAI_API_KEY
environment variable to your OpenAI API key. Alternatively, you can save this key in a .env file in the same directory as the binary. -
Check the help message for usage instructions:
./ai-asset-generator --help
This tool takes a TOML configuration file as an input and generates a random RPG asset based on the configuration. The generated asset is saved to a markdown file and an image file. Below is an example configuration file:
output_directory = "."
[random_phrase_generator]
csv_files = ["test/animals.csv", "test/verbs.csv"]
[llm_structured_response]
provider = "OpenAi"
json_schema_file = "test/example.schema.json"
system_prompt = "You are a tester for my JSON schema file. You need to provide a JSON object that matches the schema."
initial_prompt = "Provide a JSON object that matches the schema."
[llm_structured_response.provider_config]
model = "gpt-4o-2024-08-06"
[ai_images.provider]
name = "OpenAi"
[ai_images.provider.config]
url = "http://localhost:7860"
[ai_images.params]
output_directory = "."
width = 1024
height = 1024
steps = 15
sampler_name = "UniPC"
cfg_scale = 2
[ai_images.params.prompt]
base = "A beautiful sunset over the ocean."
prefix = ""
suffix = ""
negative = ""
[markdown_template_filler]
template_file_path = "test/example-template.md"
Each section is defined as follows:
output_directory
: The directory to save the generated markdown file. Default is the current directory.
Parameters for generating a random phrase to be used in the generation, if no input is provided by the user.
csv_files
: An array of CSV files containing phrases to be used in the generation. Each file needs to have a header row ofvalue,weight
followed by the phrases to be used. Thevalue
column contains the phrase, and theweight
column contains the weight of the phrase. The weight is used to determine how likely the phrase is to be selected. The higher the weight, the more likely the phrase is to be selected.
Parameters for generating a response to a structured input from an LLM provider like OpenAI.
provider
: The provider to use for the generation. Currently, onlyOpenAi
is supported.json_schema_file
: The path to the JSON schema file to use for the generation. See the OpenAI Structered Outputs specification for more information.- If you want to generate an image using the
ai_images
section, you need to include animage_prompt
key in the JSON schema file.
- If you want to generate an image using the
system_prompt
: The system prompt to use for the generation.initial_prompt
: The initial prompt to use for the generation. This is the default initial prompt that will be used if no initial prompt is provided by either the user or therandom_phrase_generator
section.
model
: The model to use for the generation. See the OpenAI API documentation for more information.
Parameters for generating an image using an AI model such as DALL-E or Stable Diffusion.
name
: The provider to use for the generation. Currently, onlyOpenAi
andStableDiffusion
are supported.
url
: The URL of the provider's API. Only needed if Stable Diffusion is the provider.
output_directory
: The directory to save the generated image. Default is the current directory.width
: The width of the generated image. Default is1024
.height
: The height of the generated image. Default is1024
.steps
: The number of steps to use in the generation. Default is15
. Only used by Stable Diffusion.sampler_name
: The name of the sampler to use in the generation. Default isUniPC
. Only used by Stable Diffusion.cfg_scale
: The scale of the configuration. Default is2
. Only used by Stable Diffusion.
base
: The base prompt to use for the generation.prefix
: The prefix to insert before the base prompt. Useful if you want to force a certain style or theme.suffix
: The suffix to insert after the base prompt. Useful to initialize LORAs.negative
: The negative prompt to use for the generation.
Parameters for filling in a markdown template with the generated content.
template_file_path
: The path to the markdown template file to fill in. The template file should contain placeholders that will be replaced with the generated content. Placeholders should be in the format{{ key_name }}
.- If you want to include an image in the markdown file, use the placeholder
{{ image_file_name }}
. Since this tool assumes you will be using wikilinks-style image links, it strips out all but the name and extension of the image file.
- If you want to include an image in the markdown file, use the placeholder
Test that the example configuration file works:
./ai-asset-generator --config test/example-config.toml
Output:
# Dog
This animal is jumping.