Skip to content

Commit 42e3eca

Browse files
committed
Explain multiple concurrent tool calls
1 parent 8f43009 commit 42e3eca

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ const result = await session.prompt("What is the weather in Seattle?");
179179

180180
In this example, the `tools` array defines a `getWeather` tool, specifying its name, description, input schema, and `execute` implementation. When the language model determines that a tool call is needed, the user agent invokes the `getWeather` tool's `execute()` function with the provided arguments and returns the result to the model, which can then incorporate it into its response.
181181

182+
Developers should be aware that the model might call their tool multiple times, concurrently. For example, code such as
183+
184+
```js
185+
const result = await session.prompt("Which of these locations currently has the highest temperature? Seattle, Tokyo, Berlin");
186+
```
187+
188+
might call the above `"getWeather"` tool's `execute()` function three times. The model would wait for all tool call results to return, using the equivalent of `Promise.all()` internally, before it composes its final response.
189+
182190
### Multimodal inputs
183191

184192
All of the above examples have been of text prompts. Some language models also support other inputs. Our design initially includes the potential to support images and audio clips as inputs. This is done by using objects in the form `{ type: "image", content }` and `{ type: "audio", content }` instead of strings. The `content` values can be the following:

0 commit comments

Comments
 (0)