## Overview

In the first four modules of this lab, you'll work with multiple heterogeneous data stores (such as MySQL, Milvus, and ElasticSearch) to address different requirements in a GenAI application. This will require several Python packages, allowing you to experience the challenges of development and maintenance. In Module 5, you'll use just one Python package - pytidb - and one data store - TiDB - as the unified data storage for GenAI. Here, you'll see firsthand how much simpler and more efficient it is to power your GenAI applications with TiDB.

<!-- markdownlint-disable MD032 -->
> [!IMPORTANT]
> Please be sure to read the following information before starting the lab.
> + This lab only supports Chrome browser.
> + This lab will grant you temporary access to Amazon Bedrock for invoking necessary models. Please adhere strictly to the usage guidelines outlined in the lab materials and refrain from utilizing this access in any other contexts. We reserve the right to hold users legally accountable for any misuse of Amazon Bedrock permissions that results in financial loss.
> + Currently, TiDB Full-Text Search with SQL is only available in TiDB Cloud Starter Frankfurt (eu-central-1) and Singapore (ap-southeast-1). If you use your own free-tier TiDB Cloud database for this lab, make sure your TiDB cluster is deployed in either Frankfurt or Singapore.

![70%](https://lab-static.pingcap.com/quick-demo/Demo_422_SplashImage_20250625.png)

Generative AI is currently a cutting-edge field that has attracted many developers eager to explore it. However, several barriers often hinder their entry into this domain, such as:

- A lack of foundational AI knowledge, leaving them unsure where to begin.
- The absence of comprehensive, step-by-step, and interactive guides for building generative AI applications.
- Limited access to essential infrastructure needed for learning, such as databases and large model APIs.

To address these challenges, we developed a series of labs, including this one, through which you will learn:

- How to write an AI application in a traditional way, based on these storages below to build a full-featured application:

  - Relational Database: e.g. `MySQL`
  - Vector Database: e.g. `Milvus`
  - Full-Text Search Engine: e.g. `ElasticSearch`

- How to use `pytidb` to leverage **TiDB Cloud Starter** as a unified data storage layer to simplify your AI application.

> [!NOTE]
> In this lab, we'll use Streamlit as a rapid application development framework to streamline and accelerate data application building.
> Whether you choose your own TiDB Cloud Starter cluster or the sandbox TiDB Cloud Starter option to start the lab, a dedicated database will be created for this hands-on lab.

### Tasks

1. Build your first simple AI application: Call the LLM and provide an answer to a question.
2. Improve your AI application using RAG, giving your application a memory:

    - Use MySQL as storage for text chunks.
    - Use Milvus as a vector storage and search engine.

3. Enhance your AI application's performance by introducing an additional retrieval channel. Full-text search is a good choice, as it will provide your AI application with a different search perspective:

    - Use ElasticSearch as the full-text search engine.

4. **Rewrite your application using TiDB to simplify your overall architecture.**

> [!TIP]
> Click **Start** to launch the lab environment.
> Once the environment is ready, the resources assigned to your hands-on session will be populated with the actual values, so you can follow the lab guide step-by-step to complete the practice.
