RAG backend using fastAPI with no gui (http://127.0.0.1:8000/docs#/default/)
Run: pip install -r requirements.txt
- Run the docker pgvecto-rs image, download if needed below
docker run \
--name pgvecto-rs-demo \
-e POSTGRES_PASSWORD=mysecretpassword \
-p 5432:5432 \
-d tensorchord/pgvecto-rs:pg16-v0.2.0
-
Setting environmental variables Must set
VECTOR_DB_MODEL=pgvecto_rs
-
Env variables will be set as below for default credentials, modify if needed (no action needed for running docker image above)
DB_HOST = localhost
,DB_USER = postgres
,DB_PASS = mysecretpassword
,DB_NAME = postgres
,DB_PORT = 5432
,
Set Env variables:
VECTOR_DB_MODEL=Qdrant
SERVER_URL="http://localhost:6333/"
- Start Qdrant docker image in port 6333
- Check out http://localhost:6333/dashboard to make sure DB working
- Make sure vector storage is running (see
Setting Up Vector Storage
) - Set env var
OPENAI_API_KEY
to your unique api key - Run
uvicorn main:app --reload
to start fast api server - Rag api access at http://127.0.0.1:8000/docs#/default/
- Use
POST /document
endpoint - For
file
upload a .pdf, .txt, or .docx file - Strongly recommend setting
file_id
for filter key for vector search - Optional
metaJSON
meta data example:{"date":"1/1/2024",...}
- If 200 response, above document now embeded in vector storaged, able to be retrieved
- Go to
GET /rag/
endpoint - Enter
query
will match vectors on meaning similarity - Enter
k
(defaults to 5) number of document chunks returned - Optionally
filterJson
JSON, keys to filter for file_ids
not needed but encouraged, list of file ids tied to documents.- Should return text of document chunks that are most similar to query
- Use
POST /link
endpoint - For
link
paste webpage or youtube URL - Strongly recommend setting
file_id
for filter key for vector search - Optional
metaJSON
meta data example:{"date":"1/1/2024",...}
- If 200 response, above text of webpage or youtube transcript now embeded in vector storaged, able to be retrieved
- Go to
GET /rag/
endpoint - Enter
query
will match vectors on meaning similarity - Enter
k
(defaults to 5) number of document chunks returned - Optionally
filterJson
JSON, keys to filter for file_ids
not needed but encouraged, list of file ids tied to documents.- Should return text of document chunks that are most similar to query
- Use
POST /table
endpoint - For
file
upload an excel (.xslx) or .csv file - set
table_name
to meaningful and relevant table name (used for sql generation) - If 200 response, table is stored locally
- Go to
GET /qa
- Enter
question
- AI will look at table names, column names to generate and execute a SQL statement to answer given question