prompt-organizer

Crates.ioprompt-organizer
lib.rsprompt-organizer
version0.1.0
sourcesrc
created_at2024-04-29 09:49:57.285414
updated_at2024-04-29 09:49:57.285414
descriptionA simple library to better manage AI prompts in your Rust code.
homepage
repositoryhttps://github.com/m1guelpf/prompt-organizer
max_upload_size
id1224024
size11,415
Miguel Piedrafita (m1guelpf)

documentation

README

prompt-organizer

A simple library to better manage AI prompts in your Rust code.

github crates.io docs.rs build status

This crate provides a procedural macro for defining AI prompts (or any multi-line string which might include user-provided parameters) in a more readable way.

cargo add prompt-organizer

Usage

use prompt_organizer::prompt;

prompt!{my_example_prompt, "
    You are {name}, an AI assistant.
"}

assert_eq!(my_example_prompt("some name"), "You are some name, an AI assistant.");

If you need to include quotes in your prompt, you can use string literals:

use prompt_organizer::prompt;

prompt!{my_example_prompt, r#"
    You are {name}, an AI assistant.

    "this is part of the prompt"
"#}

assert_eq!(my_example_prompt("some name"), "You are some name, an AI assistant.\n\n\"this is part of the prompt\"");

The prompt! macro will automatically normalize the indentation of your prompt, allowing for nicer formatting in-code.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 2

cargo fmt