Overview

Latitude’s prompt editor allows you to define tools in your prompts. Tools are function calls made available to the AI model during the conversation, enabling it to perform tasks beyond its built-in capabilities.

Tools may not be available for all providers or models. Check the documentation of your provider to see if tools are supported.


Available Tools

In Latitude, you can specify a list of available tools to the AI model, which will be able to request its executions in order to accomplish a task. Although you can define your own custom tools, Latitude provides a set of built-in tools that can be used in your prompts.

Currently, only Latitude Tools are supported. The following tools are available:

  • latitude/code
  • latitude/search
  • latitude/extract

Take a look at the Latitude Tools Section for more information on how to use them.


Defining Custom Tools

You can define custom tools as a list of functions. These functions will not run in Latitude, but instead will be requested to your client through the SDK when the AI model calls them.

Each tool must include:

  • A name
  • A description
  • An optional list of parameters
---
provider: <your-provider-name>
model: <your-model>
tools:
  - <tool-name>:
      description: <tool-description>
      parameters:
        type: object
        properties:
          <parameter-name>:
            type: <parameter-type>
            description: <parameter-description>
        required: [<required-parameter-name>]
        additionalProperties: false
---

When adding parameters to a tool, they must be defined using a JSON object schema, specifying the structure, type, and constraints.

Once defined, the AI may respond with a tool call request. To handle these requests, refer to the Latitude SDK guide here.


JSON Schema

A JSON schema defines the structure and constraints for tool parameters. It ensures the AI knows what inputs are expected and validates them accordingly.

For more details, refer to the official JSON Schema documentation.

General Guidelines:

  • Required Properties: type (mandatory), description (optional but recommended).
  • Flexibility: Additional properties like minLength, enum, or pattern can be added depending on the parameter type.

Object

An object is a collection of key-value pairs. It is defined with type: object and can include:

  • properties: Specifies the expected key-value pairs.
  • required: Lists required properties.
  • additionalProperties: Determines if extra properties are allowed (default: true).

Example:

type: object
properties:
  name:
    type: string
    description: The user’s name.
  age:
    type: integer
    description: The user’s age.
required: [name]
additionalProperties: false

String

A string is a sequence of characters. Optional properties include:

  • enum: Predefined list of acceptable text values.
  • minLength/maxLength: Minimum/maximum string length.
  • pattern: Regular expression for string validation.

Example:

type: string
enum: [red, green, blue]

Number

A number can include:

  • enum: Predefined list of acceptable numeric values.
  • minimum/maximum: Value constraints.

To define integers, use type: integer.

Example:

type: integer
minimum: 0
maximum: 100

Boolean

A boolean is a true/false value.

Example:

type: boolean

Array

An array is a list of values. Properties include:

  • items: Schema for array elements.
  • minItems/maxItems: Minimum/maximum number of elements.

Example:

type: array
items:
  type: string
minItems: 1
maxItems: 3

Example

Here’s an example of how you might define a tool to get the current weather for a specified location:

---
provider: OpenAI
model: gpt-4o
tools:
  - get_weather:
      description: Get the current weather for a specified location.
      parameters:
        type: object
        properties:
          location:
            type: string
            description: The name of the location to get the weather for.
        required: [location]
        additionalProperties: false
---

You're a weather bot! Respond to any user's request
about the weather in a specific location.

<user>
  What's the weather in {{ location }}?
</user>

Handling Tool Calls

To handle the tool call response using the Latitude SDK, refer to the Latitude SDK Guide for implementation details.