LocalStack extension to enable pgvector automatically
Project description
LocalStack pgvector Extension 🚀
localstack-extension-pgvector is a professional extension for LocalStack designed to simplify the development of AI-driven applications and Vector Search. This extension automatically enables pgvector on every PostgreSQL instance running in LocalStack and provides a web interface via pgweb.
✨ Key Features
- Auto-Enable pgvector: Automatically executes
CREATE EXTENSION IF NOT EXISTS vector;when a PostgreSQL container starts. - pgweb Integration: Automatically launches a
pgweb(Web UI) instance as a sidecar to visualize your vector data. - Seamless Integration: Supports standard RDS and PostgreSQL instances in LocalStack.
- Health Check Endpoint: Verify extension status via a dedicated HTTP endpoint.
🛠️ Installation
Using LocalStack Dashboard (Recommended)
Click the badge above or open the LocalStack Extensions Dashboard and enter this repository URL:
https://github.com/Nocturnailed-Community/localstack-extension-pgvector
Using CLI
Use the following command to install the extension locally:
localstack extensions install "https://github.com/Nocturnailed-Community/localstack-extension-pgvector"
Local Development (Editable Mode)
- Clone this repository.
- Run:
pip install -e .
- Restart LocalStack.
🐳 Using Docker Compose
For easy local development, you can use the provided docker-compose.yml:
- Start LocalStack:
docker compose up -d
- The extension will be installed automatically. Check status:
curl http://localhost:4566/pgvector-status
🛠️ Usage
- Start LocalStack:
localstack start - Launch PostgreSQL/RDS:
Use AWS CLI or SDK to create a database instance. Example:
awslocal rds create-db-instance --db-instance-identifier mydb --engine postgres --allocated-storage 20
- Access pgweb:
Open your browser and navigate to
http://localhost:8081to view your data. - Check Status:
Verify if the extension is active:
http://localhost:4566/pgvector-status
📡 API Reference (v0.2.0)
All endpoints are accessible via http://localhost:4566/pgvector/...
Status
curl http://localhost:4566/pgvector/status
Table Management
List tables:
curl http://localhost:4566/pgvector/tables
Create a table (with vector column):
curl -X POST http://localhost:4566/pgvector/tables \
-H "Content-Type: application/json" \
-d '{
"table_name": "documents",
"columns": [
{"name": "id", "type": "SERIAL PRIMARY KEY"},
{"name": "content", "type": "TEXT"},
{"name": "embedding", "type": "vector(3)"}
]
}'
Get table schema:
curl http://localhost:4566/pgvector/tables/documents/schema
Drop a table:
curl -X DELETE http://localhost:4566/pgvector/tables/documents
Data Operations
Insert rows:
curl -X POST http://localhost:4566/pgvector/tables/documents/data \
-H "Content-Type: application/json" \
-d '{
"rows": [
{"content": "Hello AI", "embedding": "[1,2,3]"},
{"content": "Vector DB", "embedding": "[4,5,6]"}
]
}'
Get rows (with pagination):
curl "http://localhost:4566/pgvector/tables/documents/data?limit=10&offset=0"
Update rows:
curl -X PUT http://localhost:4566/pgvector/tables/documents/data \
-H "Content-Type: application/json" \
-d '{"set": {"content": "Updated"}, "where": "id = 1"}'
Delete rows:
curl -X DELETE http://localhost:4566/pgvector/tables/documents/data \
-H "Content-Type: application/json" \
-d '{"where": "id = 1"}'
Raw SQL Query
curl -X POST http://localhost:4566/pgvector/query \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT * FROM pg_extension WHERE extname = '\''vector'\'';"}'
🔍 Vector Similarity Search
curl -X POST http://localhost:4566/pgvector/search \
-H "Content-Type: application/json" \
-d '{
"table_name": "documents",
"column": "embedding",
"query_vector": [1, 2, 3],
"distance": "cosine",
"limit": 5
}'
Supported distance metrics: cosine, l2, inner_product
👨💻 Contributors
- Muhammad Ikhwan Fathulloh (@Muhammad-Ikhwan-Fathulloh)
- Email:
muhammadikhwanfathulloh17@gmail.com
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by Noc Lab as part of the LocalStack ecosystem.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file localstack_extension_pgvector-0.2.0.tar.gz.
File metadata
- Download URL: localstack_extension_pgvector-0.2.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6732826dc22db7ddc7c8077fe5edfe2baeff0309cb4c962c227280c2b42e528
|
|
| MD5 |
958848980b7e9a31ad2fd77566cf20af
|
|
| BLAKE2b-256 |
ae192861bdac141b52ff2e82bcaddcc41244f59a05da0bffff7bea433091c215
|
File details
Details for the file localstack_extension_pgvector-0.2.0-py3-none-any.whl.
File metadata
- Download URL: localstack_extension_pgvector-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ec130749c4a21b37179cd6c1a706f7ae5d884837b225e73e3e63d77d3665006
|
|
| MD5 |
0e2a701e5f40895eacb3271a5257a870
|
|
| BLAKE2b-256 |
3fb751c551da7197e544f39e729fbc1f4e1f20badc49588c593c907adaa1e042
|