tool use

Allows LLMs to call defined external functions or APIs to retrieve data, run code, search the web, or take actions beyond text generation.

Syntax

prompt-engineering
// Define tools, model decides when to call them
tools: [{ name, description, parameters }]

Example

prompt-engineering
// Tool definition:
{
  name: "get_weather",
  description: "Get current weather for a city",
  parameters: {
    city: { type: "string", required: true }
  }
}

// Model response:
{ tool_call: "get_weather", args: { city: "London" } }

// App calls API, returns result to model
// Model incorporates result in final answer