Quickstart - Workbench
Get started with xpander.ai and build your first AI agent
What you will achieve in this quickstart guide:
- Design an AI Agent in the Workbench, including: The AI Agent state machine, tools (API function calling), and system instructions.
- Use the visual tester to test the behavior and tool calling.
- Chat to the AI Agent from an external source (fully hosted Chainlit).
- Apply the design and configuration to an AI Agent in code.
Using the AI Agent Workbench
Log in to the xpander.ai platform.
Go to https://app.xpander.ai and sign in with your credentials.
Open the AI Agent Workbench.
In the left navigation menu, go to AI Agents, then click the New AI Agent button.
Use the Planner to automatically design your AI Agent via a single prompt
For this quickstart, use the following prompt: “Build an AI Agent that is able to get the top stories and their item details from Hacker News”
Your result should be similar to:
Manually add another operation (tool) to the AI Agent: Hover over the bottom operation in the graph -> click the + button. Then, go to xpander functions -> send email -> click Done.
Save your AI Agent configuration by clicking the Deploy button.
Use the Agent Tester (left pane) to prompt your AI Agent and view its behavior live
Insert a test prompt such as: Get the top 3 news items from hackernews and send them over to <your email>
You will see the decision making process in the graph indicated by the moving Purple dot, as well as the request/response process and payloads in the left pane.
“if asked to send an email, use the send_email operation”
You successfully used the AI Agent Workbench to build and test your agent!
Continue the tutorial to trigger and use your AI Agent from external sources.
Chat to you AI Agent from a fully-managed Chainlit instance.
Open Chainlit
Click the Chat trigger node at the top of the graph, and click the URL for your hosted Chainlit instance.
You can continue prompting your AI Agent from this external source.
You successfully chatted to your AI Agent from an external source.
xpander-sdk in your AI Agent code
The magic of the xpander.ai Agent Platform starts here
The state machine, tools, instructions and other configurations will now be enforced by the xpander SDK
in your own AI Agent code.
Set up Python virtual environment, install packages, and add environment variables.
To start using the xpander SDK in your AI Agent code, let’s set up a virtual environment.
Create a project and virtual environment
Create a new project directory and set up a Python virtual environment:
Activate the virtual environment
Do this every time you start a new terminal session:
Install the xpander SDK
Install the following packages:
Set up environment variables in .env file
Grab these two API keys and the AI Agent ID and place them in your .env
file:
- OpenAI Key from https://platform.openai.com
- Your AI Agent ID — by clicking the SDK trigger node at the top of the graph in the AI Agent Workbench
- Your default API key From the same screen, also check the box next to the default API key and copy the API key
Make sure the three parameters are correctly added to the .env file.
AI Agent code setup
Load packages and environment variables, and initialize the clients
Create your agent.py file, and let’s start building it step by step. The following code will load the packages and keys, and initialize the clients:
Create a task and initialize state
This code creates an immutable task for the agent. Tasks are immutable by design, allowing you to track state changes throughout execution:
Add the AI Agent loop
Add the following code to your agent.py file.
The is_finished()
API checks the execution state of the agent, enabling you to control the execution loop programmatically. This approach gives you full visibility into the agent’s execution process.
Retrieve execution results
Once execution is complete, this code retrieves the immutable execution result:
The execution result is immutable, meaning it can be safely retrieved at any point during or after execution without affecting the agent’s state. This design allows you to monitor progress or record results while the agent continues processing.
Run the agent.py file in your IDE or via the command line by running python agent.py
Example output:
You successfully used the xpander SDK to run an AI Agent using the configuration you designed in the AI Agent Workbench!