tool • Rust AI Agent SDK

tool: The `#[tool]` attribute macro for defining tools. This macro transforms a function into a tool that can be used by agents. # Attributes -…

tool

Function

</div>

This function is defined in the praisonai_derive module.

The #[tool] attribute macro for defining tools. This macro transforms a function into a tool that can be used by agents. # Attributes – description: A description of what the tool does (required for LLM understanding) – name: Override the tool name (defaults to function name)

Diagram

uses

returns

Agent

Tool: tool

Result

Signature

python
def tool(attr: TokenStream, item: TokenStream) -> TokenStream

Parameters

ParamField TokenStream

No description available.

ParamField TokenStream

No description available.

Returns

ResponseField TokenStream

The result of the operation.

Usage

python
use praisonai::tool;

#[tool(description = "Search the web")]
async fn search(query: String) -> String {
format!("Results for: {}", query)
}

// With custom name
#[tool(name = "web_search", description = "Search the internet")]
async fn my_search_fn(query: String, max_results: u32) -> Vec<String> {
vec![format!("Result for: {}", query)]
}

Uses

  • parser
  • is_ident
  • value
  • parse
  • error
  • name
  • unwrap_or_else
  • path
  • push_str
  • trim

Source

View on GitHub

praisonai-derive/src/lib.rs at line 46


Related Documentation