ai_actions 0.1.1

Macros for ai actions
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 4.48 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 115.71 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mevratFinebee

AI Function Crate

The ai_action crate provides a Rust procedural macro that allows you to transform any function into a function that returns its own definition as a string. This is useful for sending the function's code to a large language model for further processing.

Installation

Add the following to your Cargo.toml file:

[dependencies]
ai_action = "0.1.0"

Then run cargo build to download and compile the ai_action crate.

Usage

To use the ai_action macro, simply annotate your function with #[ai_action].

use ai_action::ai_action;

#[ai_action]
fn example_function(arg: i32) -> i32 {
  arg \* 2
}

When you call example_function(), instead of returning arg * 2, it will return a string containing the source code of the example_function.

Limitations

The #[ai_action] macro currently does not support functions with complex control flow like loops or conditionals. It only supports simple function definitions.

use ai_actions::ai_action;

#[ai_action]
fn add(a: i32, b: i32) -> i32 {
    a + b
}

fn main() {
    assert_eq!(add(2, 3), "fn add(a: i32, b: i32) -> i32 {\n    a + b\n}");
}