Amazon Nova models support the functionality of tool choice. Tool choice allows you, as the developer, to control the manner in which a tool is called. There are three supported parameter options for tool choice: tool
, any
, and auto
.
-
Tool - The specified tool will be called once.
-
Any - One of the provided tools will be called at least once.
-
Auto - The model will decide whether to call a tool and multiple tools will be called if required.
Using tool
as the tool choice allows you to control the specific tool that the model calls. The example below highlights this with a structured output use case where the response is required to be formatted in a consistent manner.
tool_config = {
"toolChoice": {
"tool": { "name" : "extract_recipe"}
},
"tools": [
{
"toolSpec": {
"name": "extract_recipe",
"description": "Extract recipe for cooking instructions",
"inputSchema": {
"json": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the recipe"
},
"description": {
"type": "string",
"description": "Brief description of the dish"
},
"ingredients": {
"type": "array",
"items": {
"type": "string",
"description": "Name of ingredient"
}
}
},
"required": ["name", "description", "ingredients"]
}
}
}
}
]
}