simplify_baml 0.2.0

Simplified BAML runtime for structured LLM outputs using native Rust types with macros
Documentation
use simplify_baml_macros::{BamlSchema, baml_function};

#[derive(BamlSchema)]
#[allow(dead_code)]
struct TestOutput {
    result: String,
}

#[test]
fn test_single_string_literal() {
    #[baml_function(client = "test")]
    fn single_string(_text: String) -> TestOutput {
        "Single string prompt"
    }

    let func = single_string();
    assert_eq!(func.prompt_template, "Single string prompt");
}

#[test]
fn test_raw_string_literal() {
    #[baml_function(client = "test")]
    fn raw_string(_text: String) -> TestOutput {
        r#"Raw string with {{ text }}"#
    }

    let func = raw_string();
    assert_eq!(func.prompt_template, "Raw string with {{ text }}");
}

#[test]
fn test_concat_macro() {
    #[baml_function(client = "test")]
    fn concat_prompt(_text: String) -> TestOutput {
        concat!(
            "First part of the prompt. ",
            "Second part of the prompt. ",
            "Third part."
        )
    }

    let func = concat_prompt();
    assert_eq!(
        func.prompt_template,
        "First part of the prompt. Second part of the prompt. Third part."
    );
}

#[test]
fn test_concat_with_raw_strings() {
    #[baml_function(client = "test")]
    fn concat_raw(_text: String) -> TestOutput {
        concat!(
            r#"Line 1: {{ text }}"#,
            "\n",
            r#"Line 2: more content"#
        )
    }

    let func = concat_raw();
    assert_eq!(
        func.prompt_template,
        "Line 1: {{ text }}\nLine 2: more content"
    );
}

#[test]
fn test_nested_concat() {
    #[baml_function(client = "test")]
    fn nested(_text: String) -> TestOutput {
        concat!(
            concat!("Nested ", "inner"),
            " and outer"
        )
    }

    let func = nested();
    assert_eq!(func.prompt_template, "Nested inner and outer");
}