Skip to content

Commit a06b769

Browse files
committed
add controller and service for chat and embedding data into pgvector
Signed-off-by: adil <alisnagina@gmail.com>
1 parent 7266b7a commit a06b769

14 files changed

Lines changed: 810 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/mvnw text eol=lf
2+
*.cmd text eol=crlf
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionType=only-script
2+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Spring AI RAG with PGVector Example
2+
3+
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.
4+
5+
---
6+
7+
## 🧠 What This Project Does
8+
9+
- Upload a PDF file with paragraphs to the application.
10+
- Extracts content and embeds it using a local embedding model via Ollama.
11+
- Stores the embeddings in a PostgreSQL + PGVector database.
12+
- Enables retrieval and interaction with a local chat LLM (via Ollama).
13+
- Provides a simple RAG flow powered by Spring AI.
14+
15+
---
16+
17+
## 🛠 Prerequisites
18+
19+
Before running the application, make sure you have the following installed and configured:
20+
21+
- **Java 17**
22+
- **Docker** (to run PGVector via `compose.yaml`)
23+
- **Ollama** installed locally with:
24+
- `gemma:3b` (chat model)
25+
- `nomic-embed-text:latest` (embedding model)
26+
- **Postman** or any API testing tool (for uploading PDF files)
27+
- **DBeaver** or another database UI client (optional, for inspecting the database)
28+
29+
---
30+
31+
## ⚙️ Setup Instructions
32+
33+
### 1. Start the PGVector Database
34+
35+
Ensure Docker is running and start the PGVector service using the provided `compose.yaml`:
36+
37+
```bash
38+
docker compose up -d
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
pgvector:
3+
image: 'pgvector/pgvector:pg16'
4+
environment:
5+
- 'POSTGRES_DB=rag-with-pgvector'
6+
- 'POSTGRES_PASSWORD=user'
7+
- 'POSTGRES_USER=user'
8+
labels:
9+
- "org.springframework.boot.service-connection=postgres"
10+
ports:
11+
- '5432:5432'

spring-ai-rag/rag-with-pgvector/mvnw

Lines changed: 295 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)