How to Integrate External Data Sources into Vertex AI Agent Builder

Technology
Try Google Cloud
Get in touch with our knowledgeable Google Experts to learn more.
Alex Shahbazfar
Premier Cloud
November 26, 2024

1. Introduction

Real-world applications often require access to dynamic and constantly changing information. This tutorial focuses on integrating external data sources, specifically APIs, into Vertex AI Agent Builder, unlocking possibilities for truly intelligent conversational experiences. By doing so, your agents can access real-time information, stay relevant, and provide accurate responses.

2. Understanding the Basics

What is Vertex AI Agent Builder?

Vertex AI Agent Builder is a platform for creating AI agents capable of interacting with and understanding the world. It supports natural language queries, integrates enterprise data, and becomes even more powerful with external data sources like APIs.

Static vs. Dynamic Data

Static data, such as PDFs or CSV files, quickly becomes outdated, limiting its use. For example, an e-commerce support agent relying on static data can’t provide live updates on product availability or shipping timelines. Dynamic sources, like APIs, offer real-time information, enabling agents to respond effectively to evolving needs.

3. Preparing for Integration

API Setup

To illustrate dynamic data integration, we use a Warehouse Address API. This API retrieves a warehouse’s address based on its ID, offering real-time updates. It is implemented using Flask and deployed on Cloud Run.

The configuration is defined in a YAML file, which acts as a blueprint for the API. It includes details like API paths, request parameters, and response formats. You can check the YAML file given below:

openapi: 3.0.0
info:
 title: Warehouse Address API
 version: v1
servers:
 - url: 'https://my-warehouse-api-zycua53bta-uc.a.run.app'
paths:
 /warehouses/{warehouseId}/address:
   get:
     summary: Get Warehouse Address
     description: Retrieves the address of a warehouse by its ID.
     parameters:
       - in: path
         name: warehouseId
         schema:
           type: integer
           format: int64
         required: true
         description: The ID of the warehouse.
     responses:
       '200':f
         description: Successful response with the warehouse address.
         content:
           application/json:
             schema:
               type: string
               description: The full address of the warehouse.
       '404':
         description: Warehouse not found.

This YAML file is crucial for integrating the API with Vertex AI Agent Builder.

Connecting Your API

  1. Open the Agent Builder console.
  2. Navigate to Tools and create a new tool.
  3. Enter the tool’s name, type (OPENAPI), and description.
  4. Paste the YAML file content and save it.
  5. Proceed to create your agent.

4. Building and Testing Your Agent

Agent Setup

  1. Create a new agent in Vertex AI.
  2. Define its name, goal, and step-by-step instructions.
  3. Reference the tool created earlier using the format: ${TOOL: Tool_name}.

Test your Agent

Just like any software, agents need thorough testing. This helps identify bugs in their code, understand their current capabilities, and most important, simulate real interactions with users to refine the overall customer experience. 

While you are in the console, go ahead and select the appropriate agent and select the generative model of your choice and you now ask questions to the agent and the response will be coming from the API.

5. Publishing the Chat App

Now that the Chat App is up and running, it’s time to publish it and embed it into our website. To publish your Chat App, click on the Publish button which will prompt you with the following:

You have to specify the agent environment, followed by the Access type and the UI Style that you want. Once you have all of this set, go ahead and click on Enable the unauthenticated API.

6. Conclusion

This tutorial demonstrated how to integrate external data sources into Vertex AI Agent Builder, using APIs to create dynamic conversational agents. By following these steps, you can build intelligent chat applications that adapt to real-time data and deliver superior user experiences.

By Aryan Irani

RECENT ARTICLE

Take your cloud journey to the next level

Newsletter
Subscribe for the latest updates from Premier Cloud, including new products, services, and exclusive offers.

Follow our Blog

|

© 2024 Premier Cloud Inc. All Rights Reserved.

We use cookies to deliver services and analyze traffic.