Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spring-ai-rag/rag-with-pgvector/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf
33 changes: 33 additions & 0 deletions spring-ai-rag/rag-with-pgvector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
38 changes: 38 additions & 0 deletions spring-ai-rag/rag-with-pgvector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Spring AI RAG with PGVector Example

This is an example project demonstrating **Retrieval-Augmented Generation (RAG)** using **Spring AI**, with **PGVector** as the vector database and **Ollama** for running LLM and embedding models. This setup uses **Docker** for running the PGVector database locally.

---

## 🧠 What This Project Does

- Upload a PDF file with paragraphs to the application.
- Extracts content and embeds it using a local embedding model via Ollama.
- Stores the embeddings in a PostgreSQL + PGVector database.
- Enables retrieval and interaction with a local chat LLM (via Ollama).
- Provides a simple RAG flow powered by Spring AI.

---

## 🛠 Prerequisites

Before running the application, make sure you have the following installed and configured:

- **Java 17**
- **Docker** (to run PGVector via `compose.yaml`)
- **Ollama** installed locally with:
- `gemma:3b` (chat model)
- `nomic-embed-text:latest` (embedding model)
- **Postman** or any API testing tool (for uploading PDF files)
- **DBeaver** or another database UI client (optional, for inspecting the database)

---

## ⚙️ Setup Instructions

### 1. Start the PGVector Database

Ensure Docker is running and start the PGVector service using the provided `compose.yaml`:

```bash
docker compose up -d
11 changes: 11 additions & 0 deletions spring-ai-rag/rag-with-pgvector/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
pgvector:
image: 'pgvector/pgvector:pg16'
environment:
- 'POSTGRES_DB=rag-with-pgvector'
- 'POSTGRES_PASSWORD=user'
- 'POSTGRES_USER=user'
labels:
- "org.springframework.boot.service-connection=postgres"
ports:
- '5432:5432'
295 changes: 295 additions & 0 deletions spring-ai-rag/rag-with-pgvector/mvnw

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading