1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! # serdes-ai-tools
//!
//! Tool system for serdes-ai agents.
//!
//! This crate provides the infrastructure for defining, registering, and
//! executing tools that agents can use during conversations.
//!
//! ## Core Concepts
//!
//! - **[`Tool`]**: Trait for callable tools with typed parameters
//! - **[`ToolRegistry`]**: Manage and lookup registered tools
//! - **[`ToolDefinition`]**: JSON Schema-based tool descriptions for LLMs
//! - **[`RunContext`]**: Execution context with dependencies passed to tools
//! - **[`ToolReturn`]**: Return values from tool execution
//!
//! ## Defining Tools
//!
//! Tools can be defined by implementing the [`Tool`] trait:
//!
//! ```rust
//! use async_trait::async_trait;
//! use serdes_ai_tools::{
//! SchemaBuilder, Tool, ToolDefinition,
//! RunContext, ToolResult, ToolReturn,
//! };
//!
//! struct WeatherTool;
//!
//! #[async_trait]
//! impl Tool for WeatherTool {
//! fn definition(&self) -> ToolDefinition {
//! ToolDefinition::new("get_weather", "Get current weather for a location")
//! .with_parameters(
//! SchemaBuilder::new()
//! .string("location", "City name", true)
//! .build()
//! .unwrap()
//! )
//! }
//!
//! async fn call(
//! &self,
//! _ctx: &RunContext,
//! args: serde_json::Value,
//! ) -> ToolResult {
//! let location = args["location"].as_str().unwrap_or("Unknown");
//! Ok(ToolReturn::text(format!("Weather in {}: 72°F, sunny", location)))
//! }
//! }
//! ```
//!
//! ## Using the Registry
//!
//! ```rust
//! use serdes_ai_tools::{ToolRegistry, Tool, RunContext};
//!
//! # struct WeatherTool;
//! # use async_trait::async_trait;
//! # use serdes_ai_tools::{SchemaBuilder, ToolDefinition, ToolResult, ToolReturn};
//! # #[async_trait] impl Tool for WeatherTool {
//! # fn definition(&self) -> ToolDefinition {
//! # ToolDefinition::new("weather", "Get weather")
//! # .with_parameters(SchemaBuilder::new().build().unwrap())
//! # }
//! # async fn call(&self, _: &RunContext, _: serde_json::Value) -> ToolResult { Ok(ToolReturn::empty()) }
//! # }
//!
//! let mut registry = ToolRegistry::new();
//! registry.register(WeatherTool);
//!
//! // Get all definitions for the model
//! let definitions = registry.definitions();
//!
//! // Check if a tool exists
//! assert!(registry.contains("weather"));
//! ```
//!
//! ## Builtin Tools
//!
//! The crate provides builtin tools for common operations:
//!
//! - [`builtin::WebSearchTool`]: Search the web for information
//! - [`builtin::CodeExecutionTool`]: Execute code in a sandbox
//! - [`builtin::FileSearchTool`]: Vector-based file search
//!
//! ## Common Tools (Third-Party Integrations)
//!
//! With the `common-tools` feature, additional third-party tool integrations are available:
//!
//! ```toml
//! serdes-ai-tools = { version = "0.1", features = ["common-tools"] }
//! ```
//!
//! - `common::DuckDuckGoTool`: Web search using DuckDuckGo (no API key required)
//! - `common::TavilyTool`: AI-optimized search using Tavily's API
// Re-export core types
pub use RunContext;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Delete old files if they exist