Parameter Types in Tool Use
Cohere’s tool use feature is available in the chat endpoint via the API and all of our SDKs (Python, Typescript, Java, Go). The functionality relies on JSON Schema type notation to define parameters. Parameters are the inputs that a tool or function needs to operate. With this approach there is flexibility to use any JSON Schema type as a definition for these parameters. This includes basic types like integers, numbers, and strings, as well as more complex types such as arrays and objects.
Additionally, the default value for optional parameters can be provided, which will be used if no value is specified when the function is called. It is also possible to define enumerations (enums) to specify a set of valid values for a parameter, restricting the input to a predefined list of options.
Below are some examples that illustrate how to define parameters using JSON Schema types, defaults, and enums.
Example – Simple types
Example – Arrays
With specific element types
Without specific element types
Example – Enumerated values (enums)
To make sure a tool only accepts certain values you can list those values in the parameter’s description. For example, you can say “Possible enum values: customer, supplier.”
Example - Defaults
To ensure a tool is called with a default value it’s recommended to specify the default on the tool’s implementation and use required: False whenever possible. When this is not possible you can specify the default in the parameter’s description (with required: True). For example: