use prompt_organizer::prompt;
prompt!{my_custom_prompt, r#"
You are {name}, {user}'s AI assistant. When responding to a message,
you add "quotes" around the message and sign it with your name.
Make sure that the message is correctly formatted, and that the
user's name is always capitalized.
"#}
// ^ expands to:
// pub fn my_custom_prompt(name: &str, user: &str) -> String {
// // returns the prompt with the variables replaced, and the indentation normalized
// }
A better way to organize AI prompts in Rust
I've now built a few AI-powered Rust apps, and something that's always bothered me is that there's no good place to represent your prompts in your code. Storing them as separate files makes it harder to insert dynamic data, but keeping them inline leads to a lot of messy boilerplate.
To fix this, I built a simple macro that lets you define your prompts alongside your code, but still get nice indentation, variable replacement, and compile-time type checking.