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
//! Provider system for framework-specific tool formatting
//!
//! This module provides a trait-based system for converting Composio tools
//! to framework-specific formats (OpenAI, Anthropic, etc.).
//!
//! # Overview
//!
//! The provider system enables the SDK to work with different AI frameworks
//! by providing a common interface for tool conversion. Each provider implements
//! the `Provider` trait and defines how to convert Composio's universal tool
//! format to the framework's specific format.
//!
//! # Example
//!
//! ```no_run
//! use composio_sdk::{ComposioClient, providers::OpenAIProvider};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Use default OpenAI provider
//! let client = ComposioClient::builder()
//! .api_key("your_key")
//! .build()?;
//!
//! // Or specify provider explicitly
//! let client = ComposioClient::with_provider(OpenAIProvider::new())
//! .api_key("your_key")
//! .build()?;
//! # Ok(())
//! # }
//! ```
use ;
use crateToolSchema;
/// Provider trait for converting Composio tools to framework-specific formats
///
/// This trait enables the SDK to work with different AI frameworks by providing
/// a common interface for tool conversion. Implementations define how to convert
/// Composio's universal tool format to the framework's specific format.
///
/// # Type Parameters
///
/// * `Tool` - The framework-specific tool type (e.g., `ChatCompletionToolParam` for OpenAI)
/// * `ToolCollection` - The collection type returned by `wrap_tools`
///
/// # Example
///
/// ```rust
/// use composio_sdk::providers::Provider;
/// use composio_sdk::models::response::ToolSchema;
/// use serde::{Serialize, Deserialize};
///
/// #[derive(Debug, Clone, Serialize, Deserialize)]
/// struct MyTool {
/// name: String,
/// description: String,
/// }
///
/// struct MyProvider;
///
/// impl Provider for MyProvider {
/// type Tool = MyTool;
/// type ToolCollection = Vec<MyTool>;
///
/// fn name(&self) -> &str {
/// "my_provider"
/// }
///
/// fn wrap_tool(&self, tool: &ToolSchema) -> Self::Tool {
/// MyTool {
/// name: tool.slug.clone(),
/// description: tool.description.clone(),
/// }
/// }
///
/// fn wrap_tools(&self, tools: Vec<ToolSchema>) -> Self::ToolCollection {
/// tools.iter().map(|t| self.wrap_tool(t)).collect()
/// }
/// }
/// ```
/// OpenAI provider implementation
/// Anthropic provider implementation
// Re-export providers for convenience
pub use OpenAIProvider;
pub use AnthropicProvider;