Python Conference APAC 2024

Building AI Agent Bot with RAG, Langchain and Reasoning Engine
2024-10-25 , Workshop Class #1
Language: English

In this workshop, participants will embark on a comprehensive journey to build an AI agent using advanced tools and techniques such as Retrieval-Augmented Generation (RAG), Langchain, and Reasoning Engine. Over the course of 90 minutes, attendees will gain hands-on experience and valuable insights into the following key areas:

  1. Preparing Documents for RAG: Learn how to prepare documents for Retrieval-Augmented Generation by embedding, chunking, and storing them in a vector database. We will utilize the pgvec extension in PostgreSQL to efficiently manage and query our document vectors.

  2. Creating a Document Retriever Tool: Discover how to develop a powerful document retriever tool that performs efficient searches and retrievals from the vector database. This tool will be crucial for augmenting prompts with relevant information, enhancing the AI agent's responses.

  3. Developing API Tools for Third-Party Interaction: Explore the process of creating API tools that enable the AI agent to interact seamlessly with third-party systems API. These tools will expand the agent's capabilities, allowing it to execute complex tasks and retrieve external data.

  4. Building an Agent in Langchain: Dive into the creation of an intelligent agent using Langchain. Participants will learn how to manage chat histories through session stores (both in-memory and persistent storage like Redis) and leverage various tools to empower the agent to make decisions and perform actions autonomously.

  5. Deploying the AI Agent to the Cloud with Reasoning Engine: Gain practical knowledge on deploying the AI agent to the cloud using the Reasoning Engine. This section will demonstrate how to transition from development to a production-ready prototype swiftly, ensuring the agent's scalability and reliability.

By the end of this workshop, participants will have a robust understanding of building and deploying an AI agent, equipped with the skills to create intelligent systems that can autonomously interact with users and third-party services. This workshop will provide a comprehensive guideline, empowering attendees to innovate and implement AI solutions effectively in their own projects.


In this workshop, we will build an AI agent bot designed to answer questions about an online course it promotes and sells. This intelligent agent will have a comprehensive understanding of the course content, enabling users to interact with it and ask detailed questions about the material. The agent will be capable of providing accurate and informative responses based on the data it has been trained on.

Moreover, our AI agent will go beyond just answering questions. It will have the capability to accept orders, generate payment URLs, and check the status of orders, allowing users to make purchases directly through natural language interaction with the agent. This hands-on experience will demonstrate the agent's ability to perform complex tasks autonomously.

Participants are encouraged to use any Large Language Models (LLMs) they are familiar with. However, for this workshop, I will be using Google Gemini 1.5 Pro. There will be $5 GCP credit that will be provided for the participants so that they can use Gemini model. For other LLM, they must provide their API Key as the credits will not be provided.

Additionally, if participants have a Google Cloud Platform (GCP) account, they will be able to follow along with the deployment process, as we will be deploying the AI agent to the cloud using Google Cloud's Reasoning Engine.

By the end of this workshop, participants will have hands-on experience and a clear understanding of how to build and deploy a robust AI agent capable of interacting with users and performing complex tasks, all using open-source software and cloud technologies.

Prerequisites

  • Docker installed
  • Docker compose installed
  • Jupyter notebook installed locally
  • Google Cloud account created
  • Google Cloud CLI installed locally
  • VS Code (optional)
See also: Sample of slides used in Google IOX to introduce simplified concept about AI Agent and Reasoning Engine (842.7 KB)

Tech Lead, GoTo Financial