@@ -10,7 +10,7 @@ be taken externally. Most common tools include the following searching the web,
1010querying a public API, executing a shell command, and more.
1111
1212Here 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
1616use 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
127127appends 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
131131let 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 ;
0 commit comments