Skip to content

Commit 3cfa396

Browse files
committed
chore: add docs for overriding tool args
1 parent fdf8e0b commit 3cfa396

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

apps/docs/content/docs/concepts/tools.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ takes a single argument of type `serde_json::Value` which is the json input prov
5050
which is the output of the tool. If the tool fails, you can return an error message as `Err(String)` which can
5151
also be helpful for the AI model to understand what went wrong.
5252

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+
use crate::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+
pub fn get_weather(location: String) {
61+
let weather = match location.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+
5374
## Using the structs
5475

5576
You can define your own tools in aisdk by instantiating the `Tool` and related structs and passing

0 commit comments

Comments
 (0)