The OpenAITool class represents a tool that can be called by the OpenAI model during a conversation. Tools allow the AI to perform specific functions and interact with external systems or retrieve information.
See OpenAIMessage to see how to responds to a tool call.
Note: The tool calls are handled automatically when using OpenAIChatHelper with
autoHandleToolCallsenabled.
| Property | Type | Default | Description |
|---|---|---|---|
type |
Text | "function" |
The type of tool. Currently supports "function", "custom", and other built-in types. |
strict |
Boolean | False |
Whether to enforce strict schema validation for function parameters. |
| Property | Type | Description |
|---|---|---|
name |
Text | The name of the tool, which works as an identifier. |
description |
Text | Description of the tool to help the LLM decide when to use it. |
| Property | Type | Description |
|---|---|---|
parameters |
Object | Parameters definition for the function using JSON schema format. |
new(object : Object) : OpenAITool
| Parameter | Type | Description |
|---|---|---|
| object | Object | Configuration object for the tool |
| Result | OpenAITool | New instance of OpenAITool |
Creates a new OpenAITool instance. The constructor accepts both simplified format and OpenAI API format.
Simplified format:
var $tool := cs.AIKit.OpenAITool.new({ \
name: "get_weather"; \
description: "Get current weather for a location"; \
parameters: { \
type: "object"; \
properties: { \
location: {type: "string"; description: "City name"} \
}; \
required: ["location"] \
} \
})OpenAI API format:
var $tool := cs.AIKit.OpenAITool.new({ \
type: "function"; \
strict: True; \
function: { \
name: "get_weather"; \
description: "Get current weather for a location"; \
parameters: { \
type: "object"; \
properties: { \
location: {type: "string"; description: "City name"} \
}; \
required: ["location"] \
} \
} \
})Tools are typically used with the OpenAIChatCompletionsParameters.tools property:
var $parameters := cs.AIKit.OpenAIChatCompletionsParameters.new({ \
model: "gpt-4o-mini"; \
tools: [$tool1; $tool2; $tool3] \
})Note: You can pass plain objects directly - they will be automatically converted to
OpenAIToolinstances. There's no need to explicitly createOpenAIToolobjects.
- OpenAIChatCompletionsParameters - For tool configuration
- OpenAIChatHelper - For automatic tool call handling
- OpenAIMessage - For tool call responses