1use serde::{Deserialize, Serialize};
2
3#[doc = include_str!("docs/tools.md")]
4#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
5pub struct ToolDefinition {
6 pub name: String,
7 pub description: String,
8 pub parameters: String,
9 pub server: Option<String>,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14pub struct ToolCallRequest {
15 pub id: String,
16 pub name: String,
17 pub arguments: String,
18}
19
20#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
22pub struct ToolCallResult {
23 pub id: String,
24 pub name: String,
25 pub arguments: String,
26 pub result: String,
27}
28
29#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
31pub struct ToolCallError {
32 pub id: String,
33 pub name: String,
34 pub arguments: Option<String>,
35 pub error: String,
36}
37
38impl ToolCallError {
39 pub fn from_request(request: &ToolCallRequest, error: impl Into<String>) -> Self {
40 Self {
41 id: request.id.clone(),
42 name: request.name.clone(),
43 arguments: Some(request.arguments.clone()),
44 error: error.into(),
45 }
46 }
47}