subako-function-sdk 0.2.0

Write Subako function packages in Rust: typed functions become tools, and the program prints its own manifest.
Documentation

subako-function-sdk

Write Subako function packages in Rust. Each #[function] becomes a tool an agent can call:

  • the function's name is the tool's name;
  • its doc comment is the description the model reads;
  • its input and output types, which derive JsonSchema, become the tool's schemas.
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use subako_function_sdk::{ToolError, function, package};

#[derive(Deserialize, JsonSchema)]
struct GreetInput {
    /// Who to greet.
    name: String,
}

#[derive(Serialize, JsonSchema)]
struct Greeting {
    message: String,
}

/// Greet someone by name.
#[function]
fn greet(input: GreetInput) -> Result<Greeting, ToolError> {
    Ok(Greeting { message: format!("Hello, {}!", input.name) })
}

package! {
    name: "hello",
    description: "Says hello.",
    functions: [greet],
}

Build the module for wasm32-wasip1. The same crate built for your machine prints the package's subako-package.json with cargo run -- --subako-manifest.

To start a new package, use the template, which also packages the bundle Subako takes:

cargo generate subako-ai/subako-function-template-rust

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.