You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docs/content/docs/concepts/tools.mdx
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,27 @@ takes a single argument of type `serde_json::Value` which is the json input prov
50
50
which is the output of the tool. If the tool fails, you can return an error message as `Err(String)` which can
51
51
also be helpful for the AI model to understand what went wrong.
52
52
53
+
You can optionally override the `name` and `description` of the tool by passing them as arguments to the `#[tool]` macro.
54
+
55
+
```rust
56
+
usecrate::core::{tool, Tool};
57
+
58
+
#[tool(name ="get-weather", description ="Get the weather information given a location")]
59
+
/// A tool that returns the weather information given a location
60
+
pubfnget_weather(location:String) {
61
+
letweather=matchlocation.as_str() {
62
+
// Some logic to query a weather API
63
+
"New York"=>75,
64
+
"Tokyo"=>80,
65
+
_=>70,
66
+
};
67
+
Ok(weather.to_string())
68
+
}
69
+
```
70
+
71
+
This will make the tool name and description configurable. name will be `get-weather` and description will be `Get the weather information given a location`.
72
+
73
+
53
74
## Using the structs
54
75
55
76
You can define your own tools in aisdk by instantiating the `Tool` and related structs and passing
0 commit comments