×
Community Blog AnythingLLM Builds Personal Knowledge Bases with RDS PostgreSQL's PGVector Plug-in

AnythingLLM Builds Personal Knowledge Bases with RDS PostgreSQL's PGVector Plug-in

The article explains how AnythingLLM uses Alibaba Cloud ApsaraDB for PostgreSQL with the PGVector extension to create private, vector-based knowledge bases.

Introduction to AnythingLLM

AnythingLLM is a full-stack application where you can use commercial off-the-shelf LLMs or popular open source LLMs and vectorDB solutions to build a private ChatGPT with no compromises that you can run locally as well as host remotely and be able to chat intelligently with any documents you provide it.

AnythingLLM divides your documents into objects called workspaces. A Workspace functions a lot like a thread, but with the addition of containerization of your documents. Workspaces can share documents, but they do not talk to each other so you can keep your context for each workspace clean.

Install AnythingLLM

Install AnythingLLM through Docker: Pull the latest image and start the container with the pg image. The pg image is the latest version of AnythingLLM, specifically designed for local or remote PostgreSQL databases.

Command to pull the image:

docker pull mintplexlabs/anythingllm:pg  

All AnythingLLM data is stored in a PostgreSQL database. By default, PGVector will be used for vector storage. The PGVector extension needs to be installed on the PostgreSQL database.

View the images that are pulled:

1

RDS PostgreSQL Database Configuration

To create a database and a user:

2
3

Configure the installation of the PGVector extension on the RDS PostgreSQL database.

4
5

If the ECS and RDS PostgreSQL are in the same VPC, it is recommended to connect to the database using an internal network address.

View the database endpoint and port number.

Endpoint: pgm-3nsd23s3655b4bfk.rwlb.rds.aliyuncs.com
Port number: 5432

6

Start the Container in Docker

export STORAGE_LOCATION=$HOME/anythingllm && \
mkdir -p $STORAGE_LOCATION && \
touch "$STORAGE_LOCATION/.env" && \
docker run -d -p 3001:3001 \
--cap-add SYS_ADMIN \
-v ${STORAGE_LOCATION}:/app/server/storage \
-v ${STORAGE_LOCATION}/.env:/app/server/.env \
-e STORAGE_DIR="/app/server/storage" \
-e DATABASE_URL="postgresql://dbuser:dbpassword@pgm-3nsd23s3655b4bfk.rwlb.rds.aliyuncs.com/dbname" \
mintplexlabs/anythingllm:pg

Configure the Model and Vector Database in the Browser Interface

Start the container, map the 3001 to the external port, and access the IP address through the browser: 3001.

7

Configure a general large language model

8

Select the configured RDS PostgreSQL for the vector database

9

Configure the Embedding model

10

Create a Workspace and a Personal Knowledge Base

11
12

Upload documents to verify the setup of the knowledge base

13

Retrieve the content of the knowledge base through natural language questions and answers.

14

The response meets expectations.

0 1 0
Share on

ApsaraDB

548 posts | 174 followers

You may also like

Comments

ApsaraDB

548 posts | 174 followers

Related Products