Skip to main content

Crate cognate_tools

Crate cognate_tools 

Source
Expand description

Cognate Tools — type-safe tool calling and automatic execution.

§Overview

  1. Define a struct representing your tool’s parameters and derive Tool.
  2. Implement an async fn run(&self) method on the struct.
  3. Register it with a ToolExecutor and 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§

ToolDefinition
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.