Expand description
Cognate Tools — type-safe tool calling and automatic execution.
§Overview
- Define a struct representing your tool’s parameters and derive
Tool. - Implement an
async fn run(&self)method on the struct. - Register it with a
ToolExecutorand let it drive the tool-call loop automatically.
§Example
use cognate_tools::{Tool, ToolExecutor};
use cognate_core::{Request, Message};
use serde::{Deserialize, Serialize};
use schemars::JsonSchema;
#[derive(Tool, Serialize, Deserialize, JsonSchema)]
#[tool(description = "Search the web for a query")]
struct WebSearch {
/// The search query.
query: String,
}
impl WebSearch {
async fn run(&self) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
Ok(format!("Results for: {}", self.query))
}
}Re-exports§
pub use executor::ToolExecutor;
Modules§
- executor
- Automatic tool-call dispatch loop.
Structs§
- Tool
Definition - Serialisable metadata for a tool, used when registering tools with a provider.
Traits§
- Tool
- The core trait for all callable tools.
Derive Macros§
- Tool
- Derive the [
cognate_tools::Tool] trait for a struct.