Skip to content

Commit 13a1218

Browse files
committed
chore: add registering tool for macro method
1 parent 3cfa396 commit 13a1218

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ be taken externally. Most common tools include the following searching the web,
1010
querying a public API, executing a shell command, and more.
1111

1212
Here is the recommended and less verbose way to define a tool. It allows you to annotate native
13-
Rust functions with the `#[tool]` macro, which will generate the `Tool` struct for you.
13+
Rust functions with the `#[tool]` macro, which will generate a `Tool` struct for you.
1414

1515
```rust
1616
use crate::core::{tool, Tool};
@@ -127,12 +127,26 @@ To register the tool with the AI model, you need to add it to text generation bu
127127
appends the tool to the list of tools that the AI model will use to generate text.
128128

129129
```rust
130-
// call the model with the tool
130+
// call the model with the `#[tool]` macro
131131
let result = LanguageModelRequest::builder()
132132
.model(OpenAI::new("gpt-4o"))
133133
.system("You are a helpful assistant with access to tools.")
134134
.prompt("What is the weather in New York?")
135-
.with_tool(get_weather_tool) // you don't need to call it with.
135+
.with_tool(get_weather())
136+
.build()
137+
.generate_text()
138+
.await;
139+
```
140+
141+
or if you are using the structs
142+
143+
```rust
144+
// call the model with `Tool` struct
145+
let result = LanguageModelRequest::builder()
146+
.model(OpenAI::new("gpt-4o"))
147+
.system("You are a helpful assistant with access to tools.")
148+
.prompt("What is the weather in New York?")
149+
.with_tool(get_weather_tool) // you don't need to call it if using structs.
136150
.build()
137151
.generate_text()
138152
.await;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"scripts": {
55
"build": "turbo run build",
66
"dev": "turbo run dev",
7-
"format-and-lint": "biome check .",
8-
"format-and-lint:fix": "biome check . --write",
7+
"format-and-lint": "npx biome check .",
8+
"format-and-lint:fix": "npx biome check . --write",
99
"check-types": "turbo run check-types"
1010
},
1111
"devDependencies": {

0 commit comments

Comments
 (0)