This example demonstrates how to use the LlamaIndex and TiDB Serverless to build a simple RAG(Retrival-Augmented Generation) application with simple UI.
- A running TiDB Serverless cluster with vector search enabled
- Python 3.8 or later
- OpenAI API key
git clone https://github.com/pingcap/tidb-vector-python.git
cd tidb-vector-python/examples/llamaindex-tidb-vector-with-ui
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Get the OPENAI_API_KEY
from OpenAI
Get the TIDB_HOST
, TIDB_USERNAME
, and TIDB_PASSWORD
from the TiDB Cloud console, as described in the Prerequisites section.
export OPENAI_API_KEY="sk-*******"
export TIDB_HOST="gateway01.*******.shared.aws.tidbcloud.com"
export TIDB_USERNAME="****.root"
export TIDB_PASSWORD="****"
# prepare the data
python app.py prepare
# runserver
python app.py runserver
Now you can visit http://127.0.0.1:3000/ to interact with the RAG application.