Tool use and function calling

5 concepts · 10 practice questions

Tool definitions

A tool is a function you describe to the model with a name, a description and a JSON schema for its arguments. The model never runs anything: it returns a request to call the tool, your code runs it and sends the result back. The description is the model's only documentation, so say what the tool does, when to use it, and what each argument means. Vague descriptions are the usual cause of wrong tool choices.

tools = [{
    "name": "get_order",
    "description": "Look up one order by its id. Use it when the user asks "
                   "about an order's status, items or delivery date.",
    "input_schema": {"type": "object",
                     "properties": {"order_id": {"type": "string",
                                                 "description": "e.g. ORD-10293"}},
                     "required": ["order_id"]},
}]

Also covered

The tool loop
Errors as results
Guardrails on actions
Designing a tool set

Sign in to read the rest and take the 10-question test.

Sign in to continue