1use std::{borrow::Cow, sync::Arc};
2
3use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8use super::JsonObject;
9
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13pub struct Tool {
14    pub name: Cow<'static, str>,
16    pub description: Cow<'static, str>,
18    pub input_schema: Arc<JsonObject>,
20}
21
22impl Tool {
23    pub fn new<N, D, S>(name: N, description: D, input_schema: S) -> Self
25    where
26        N: Into<Cow<'static, str>>,
27        D: Into<Cow<'static, str>>,
28        S: Into<Arc<JsonObject>>,
29    {
30        Tool {
31            name: name.into(),
32            description: description.into(),
33            input_schema: input_schema.into(),
34        }
35    }
36
37    pub fn schema_as_json_value(&self) -> Value {
39        Value::Object(self.input_schema.as_ref().clone())
40    }
41}