Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Chapter 09: LLM Tools

Define tools that LLMs can call from your BASIC scripts.

Overview

Tools are BASIC scripts with PARAM declarations that become callable functions for the LLM. This enables AI-driven automation with structured inputs.

Tool Structure

' weather.bas - A tool the LLM can invoke
PARAM city AS STRING LIKE "London" DESCRIPTION "City name"
PARAM units AS STRING LIKE "celsius" DESCRIPTION "Temperature units"

DESCRIPTION "Gets current weather for a city"

data = GET "api.weather.com/current?city=" + city
TALK "Weather in " + city + ": " + data.temperature + "°"

How It Works

  1. PARAM declarations define inputs
  2. DESCRIPTION explains the tool’s purpose
  3. LLM decides when to call the tool
  4. Parameters collected through conversation
  5. Tool executes with validated inputs

PARAM Declaration

PARAM name AS type LIKE "example" DESCRIPTION "explanation"
ComponentPurpose
nameVariable name
typeSTRING, INTEGER, DATE, etc.
LIKEExample value for LLM
DESCRIPTIONWhat this parameter is for

Tool Formats

Tools compile to multiple formats:

FormatUse Case
MCPModel Context Protocol
OpenAIFunction calling
InternalBASIC runtime

Chapter Contents

See Also