Tool
The ToolType
is the fundamental type for defining tools and functions that can be called by LLM providers in Adaline. It provides a structured way to define function schemas that language models can use for tool calling capabilities.
Overview
A ToolType
consists of the following main components:
The type of tool.
Constraints: Must be one of the defined tool types.
The tool definition containing the schema.
Constraints: Must contain a valid schema.
Tool Types
The type
field uses a discriminated union of predefined tool types.
ToolTypesType
Function-based tools.
Usage: Used for defining callable functions with parameters.
Currently, only one tool type is supported:
Function Tool
FunctionToolType
Represents a function that can be called by the LLM.
Tool type discriminator.
Constraints: Must be "function"
.
Contains the function schema.
Constraints: Must contain valid function schema.
FunctionToolDefinition
The function schema definition.
Constraints: Must be a valid function schema.
Function Schema
FunctionType
Defines the structure and behavior of a callable function.
Function name.
Constraints: 1-64 characters, alphanumeric and underscore only.
Function description.
Constraints: Maximum 4096 characters.
Function parameters schema.
Constraints: Flexible parameter definition.
Whether to enforce strict parameter validation.
Constraints: Optional field.
Name Validation
The function name must follow these rules:
- Length: 1-64 characters
- Characters: Only letters (a-z, A-Z), numbers (0-9), and underscores (_)
- Pattern:
^[a-zA-Z0-9_]{1,64}$
Function Parameters
FunctionParametersType
Defines the structure for function parameters using JSON Schema-like definitions.
Parameter container type.
Constraints: Must be "object"
.
Optional title for the parameters.
Constraints: Optional field.
Schema definitions for reusable components.
Constraints: Optional field.
Parameter property definitions.
Constraints: Optional field.
List of required parameter names.
Constraints: Optional field.
FunctionParameterType
Defines individual parameter properties with comprehensive JSON Schema support.
Union type definitions.
Constraints: Optional field.
Parameter data type
Constraints: Optional, see supported types below.
Default value for the parameter.
Constraints: Optional field.
Parameter title.
Constraints: Optional field.
Parameter description.
Constraints: Maximum 4096 characters.
Nested object properties
Constraints: Optional, for object types.
Required nested properties.
Constraints: Optional, for object types.
Minimum array length.
Constraints: Optional, for array types, non-negative
Maximum array length.
Constraints: Optional, for array types
Array item schema.
Constraints: Optional, for array types
Allowed values.
Constraints: Optional field.
Minimum numeric value.
Constraints: Optional, for number types
Maximum numeric value.
Constraints: Optional, for number types
Minimum string length.
Constraints: Optional, for string types, non-negative
Maximum string length.
Constraints: Optional, for string types
FunctionParameterTypesType
Supported parameter data types:
Object/dictionary type.
Usage: For complex nested structures.
Array type.
Usage: For lists of items.
Numeric type.
Usage: For integers and floating-point numbers.
String type.
Usage: For text values.
Boolean type.
Usage: For true/false values.
Null type.
Usage: For null values.
Complete Examples
Simple Function Tool
Complex Function Tool with Advanced Parameters
Function with String Constraints
Function with Nested Objects and Arrays
Best Practices
- Descriptive Names: Use clear, descriptive function names that indicate the action being performed
- Comprehensive Descriptions: Provide detailed descriptions for both functions and parameters to help the LLM understand usage
- Appropriate Constraints: Use parameter constraints (min/max, length limits, enums) to ensure valid inputs
- Required vs Optional: Clearly mark which parameters are required vs optional
- Default Values: Provide sensible defaults for optional parameters when appropriate
- Nested Structure: Use nested objects and arrays when dealing with complex data structures