Automatic AI JavaScript Tool Function Calling
AI tool function calling (often just called “tool use”) is a feature where an AI model can invoke external functions or APIs during a conversation to get real data or perform actions—rather than just generating text.
The core idea
Instead of guessing or fabricating answers, the model can:
- Recognize when a tool is needed (e.g., “What’s the weather?” → needs a weather API)
- Output a structured function call (JSON with function name + arguments)
- Let your application execute the function
- Receive the result and continue the response
Automatic JavaScript Tool Functions
- Application provides JavaScript functions that run within the Chilkat.Js embedded JavaScript engine.
- The tool registry and permissions are provided in the JavaScript.
- Chilkat internally handles tool calls by finding the matching JavaScript function(s), calling them, and sending results back to the AI model.
- The JavaScript code has full access to Chilkat classes, but only with application allowed permissions.
Simple example flow
Application:
Call Chilkat's
Askfunction to ask "What’s my horoscope? I’m an Aquarius."
Model decides:
I should call
get_horoscope(sign="Aquarius")
Chilkat:
- (witin the
Askfunction) finds yourget_horoscopeJavaScript function and calls it. - Sends the tool call result back to the AI.
Model:
Uses that result to produce the final answer
Chilkat:
Askreturns the final answer
Key points
- The model does NOT execute code itself → Chilkat finds and runs your JavaScript function(s).
- The model chooses when and how to call tools
- Inputs/outputs are structured (usually JSON)