-
Notifications
You must be signed in to change notification settings - Fork 76
Description
When originally designing the tool calling API in #7 (comment), I said
I like the Vercel AI SDK's use of object literals instead of an array of named items, e.g. I think
tools: { weather: { description, parameters, execute } }would be nicer than the above. However, nobody else does that. And in the future, if we wanted to offer built-in tools, the above design is more flexible, since the built-in tools could be entries in the array such as"builtin:toolname"orLanguageModel.ToolName. So, I am inclined to stick with the array version.
However, the Chrome team had some more discussion on the subject of built-in tools and want to revisit this.
In particular, we think it's probably important to let web developers provide the names for tools, even built-in tools. This is because they might write prompts that refer to the tools by name.
If we use the tools: { toolName1: { ... }, toolName2: { ... }, ... } syntax, then built-in tools can be provided, without their name, via objects exposed somewhere like LanguageModel.CalculatorTool or LanguageModelTools.Calculator or similar. Ideally, those objects can be normal objects with developer-visible description, inputSchema, and execute properties. If for some reason we need them to be opaque objects, that would be possible too.
(As a bonus, if web developers provide a name for all the tools, then we don't have to worry about conflicts between built-in tool names and developer-provided tool names. We can avoid those conflicts by reserving a namespace, e.g. "builtin:", but it's nicer to just not have to deal with it.)
Full-ish example:
const session = new LanguageModelSession({
tools: {
getWeather: {
description: "Get the weather in a location.",
inputSchema: { ... },
async execute() { ... }
},
calculator: LanguageModel.CalculatorTool
}
});
const result = await session.prompt(
`Get the temperature in Celsius in Seattle using the "getWeather" tool,
then convert it to Fahrenheit using the F = (C*1.8) + 32 formula and the "calculator" tool.
`);@FrankLi-MSFT @sushraja-msft how does this sound to you and your team?