Description

The Toolbox View enables users to create custom tools for design agents to use. Toolboxes function follows the MCP format that expose specific functionality through defined interfaces. The view consists of three panes: the left pane contains the summary. The middle pane contains the code editor. The right pane serves as the testing area.

Creating Custom Tools

Toolboxes allow you to create specialized functions that design agents can use to accomplish tasks. Each toolbox can expose multiple tools, each with specific parameters and functionality. For example, you might create a WeatherDataTool that provides weather alerts and forecasts by interacting with external APIs.

Tool Structure

A typical toolbox contains:
  1. Constants and Configuration - API endpoints, credentials, etc.
  2. Helper Functions - Functions that support the main tool operations
  3. Tool Functions - The actual functions exposed to agents which are marked with the davinci.tool() decorator.
  4. Documentation - Clear descriptions of what the toolbox as a whole does and its purpose.
  5. Status - Toggle to enable/disable the toolbox from the agent access. All active tools can be seen in the project area under the tools section.

Code Editor

The code editor enables you to modify tool code, and all changes are automatically saved as you edit. It works just like the normal code editor in Davinci. For more information about code editor operations, see the Code Editor documentation.

Testing Tools

The testing area allows you to validate your tool’s functionality. Enter test instructions in the input field and click the Run Test button to execute your tool with those parameters. The output will show the results of your tool execution.
Thoroughly test your tools with different inputs to ensure they handle errors gracefully and return expected results. Once ready toggle the status to enable the tool for the agent to use.

Example

Below is an example of a toolbox that provides weather information from the National Weather Service API:
from typing import Any
import httpx

# Constants
NWS_API_BASE = "https://api.weather.gov"
USER_AGENT = "weather-app/1.0"

davinci.tool()
async def make_nws_request(url: str) -> dict[str, Any] | None:
    """Make a request to the NWS API with proper error handling."""
    headers = {
        "User-Agent": USER_AGENT,
        "Accept": "application/geo+json"
    }
    
    async with httpx.AsyncClient() as client:
        try:
            response = await client.get(url, headers=headers, timeout=30.0)
            response.raise_for_status()
            return response.json()
        except Exception:
            return None

In the code above each tool is defined with the davinci.tool() decorator. This decorator is used to mark the function as a tool. The list on the left panel will display each tool as gathered by the decorators. This toolbox could be used by design agents to fetch and format weather data for various locations. To have data passed directly from the tool to the database, you can use the save() and update() functions as in regular code.