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)
Signature
def tool(attr: TokenStream, item: TokenStream) -> TokenStreamParameters
ParamField
TokenStreamNo description available.
ParamField
TokenStreamNo description available.
Returns
ResponseField
TokenStreamThe result of the operation.
Usage
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
parseris_identvalueparseerrornameunwrap_or_elsepathpush_strtrim
Source
View on GitHubpraisonai-derive/src/lib.rs at line 46