Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 1.36 KB

File metadata and controls

56 lines (38 loc) · 1.36 KB

LlamaIndex RAG Example with Simple UI

This example demonstrates how to use the LlamaIndex and TiDB Serverless to build a simple RAG(Retrival-Augmented Generation) application with simple UI.

Prerequisites

  • A running TiDB Serverless cluster with vector search enabled
  • Python 3.8 or later
  • OpenAI API key

Run the example

Clone this repo

git clone https://github.com/pingcap/tidb-vector-python.git

Create a virtual environment

cd tidb-vector-python/examples/llamaindex-tidb-vector-with-ui
python3 -m venv .venv
source .venv/bin/activate

Install dependencies

pip install -r requirements.txt

Set the environment variables

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 data and run the server

# 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.