Serverless RAG Chat with AppSync Events and Bedrock Knowledge Bases

Listen to this Post

Featured Image
In this blog post, Zied Ben Tahar explores AppSync Events and how they simplify building WebSocket APIs for a RAG-based chat application using Bedrock Knowledge Bases. The article covers:
– Using PostgreSQL as a vector store for the Knowledge Base.
– Leveraging AppSync’s Data Source feature.
– Simplifying AppSync Events integration with Lambda Powertools.

Read the full article here: Serverless RAG Chat with AppSync Events and Bedrock Knowledge Bases

Check out the source code here: GitHub Repository

You Should Know:

1. Setting Up PostgreSQL as a Vector Store

To use PostgreSQL with Amazon Bedrock, you need to:
1. Install PostgreSQL on your server or use Amazon RDS:

sudo apt update && sudo apt install postgresql postgresql-contrib 

2. Enable the pgvector extension:

CREATE EXTENSION vector; 

3. Create a table for vector embeddings:

CREATE TABLE document_embeddings ( 
id SERIAL PRIMARY KEY, 
content TEXT, 
embedding VECTOR(1536) -- Adjust dimensions based on your model 
); 

2. Configuring AWS AppSync with WebSocket