Skip to main content

cetai_macros/
lib.rs

1//! Procedural macros for the `cetai` crate: the `#[ai]` attribute and the
2//! `prompt!` expression macro. See the repository `PLAN.md` for the design
3//! baseline this crate implements.
4
5mod ai_attr;
6mod options;
7mod paths;
8mod prompt_fn;
9mod template;
10
11use proc_macro::TokenStream;
12
13/// Marks an `async fn` whose whole body is a single `prompt!` call.
14///
15/// The attribute accepts `thinking = <path>`, `http_retries = <0..=10>` and
16/// `repair_retries = <0..=10>`; the values are forwarded to the inner
17/// `prompt!` call.
18#[proc_macro_attribute]
19pub fn ai(attr: TokenStream, item: TokenStream) -> TokenStream {
20    ai_attr::expand(attr, item)
21}
22
23/// Builds an AI prompt expression returning a future of `cetai::Result<T>`.
24#[proc_macro]
25pub fn prompt(input: TokenStream) -> TokenStream {
26    prompt_fn::expand(input)
27}