Skip to main content

View Source Code

Check out the full source code for this example on GitHub.
This tutorial demonstrates how to build an Agent with Tool Calling using Tensorlake and the Anthropic API. This agent orchestrates a multi-step workflow where Claude decides which tools to call and in what order to answer user queries effectively.

Overview

The Agent with Tool Calling follows this pattern:
  1. User Query: The user asks a question that requires external data or actions (e.g., “What’s the weather like at my current location?”).
  2. Tool Selection: Claude analyzes the query and selects the appropriate tool(s) to call (e.g., get_ip_address, get_location_info).
  3. Tool Execution: The selected tool functions are executed within Tensorlake’s isolated environment.
  4. Information Synthesis: The tool outputs are fed back to Claude, which then synthesizes a final answer or decides to call more tools.

Prerequisites

  • Python 3.11+
  • Tensorlake Account and CLI installed.
  • Anthropic API Key

Implementation (app.py)

Here is the complete implementation for the Agent with Tool Calling.

Running Locally

To test the agent locally, add this code block to the end of app.py:
Then run the script:

Deploying to Tensorlake

Deploy your agent to the cloud for production use:
Your agent is now live! It can autonomously chain tool calls to solve complex user requests, all running within secure, scalable Tensorlake functions.