pgai  by timescale

SDK for building RAG and agent applications with PostgreSQL

created 1 year ago
5,094 stars

Top 10.0% on sourcepulse

GitHubView on GitHub
Project Summary

pgai is a Python library designed to transform PostgreSQL into a robust retrieval engine for RAG and agentic applications. It simplifies the creation and synchronization of vector embeddings from PostgreSQL data and S3 documents, automatically updating them as the underlying data changes. This empowers developers to build AI applications with semantic search and retrieval capabilities directly within their PostgreSQL databases.

How It Works

pgai employs a declarative approach where users define a vectorizer configuration specifying data sources, chunking strategies, and embedding models. Stateless worker processes then read this configuration, queue data for embedding, and write the resulting embeddings and text chunks back to PostgreSQL. This architecture decouples embedding generation from core data operations, enhancing resilience against embedding service failures. It leverages pgvector for vector storage and search, and pgvectorscale for high-performance ANN search.

Quick Start & Requirements

  • Install via pip: pip install pgai
  • Prerequisites: PostgreSQL database (Docker instructions available), OpenAI API key (or other supported providers).
  • Setup requires creating a .env file with OPENAI_API_KEY and DB_URL.
  • Quickstart example code and requirements are available for download.
  • Official quickstart guides: OpenAI, Ollama, VoyageAI.

Highlighted Details

  • Automatically creates and synchronizes vector embeddings from PostgreSQL data and S3 documents.
  • Supports batch processing with built-in error handling for model failures, rate limits, and latency.
  • Integrates with pgvector and pgvectorscale for semantic and ANN search.
  • Offers a configurable pipeline for data loading, parsing, chunking, formatting, and embedding.
  • Supports multiple embedding providers including Ollama, OpenAI, Cohere, and Huggingface.

Maintenance & Community

  • Project is actively developed by Timescale.
  • Community support available via Discord.
  • Open to contributions; roadmap and discussions are available.
  • Discord

Licensing & Compatibility

  • Apache 2.0 License.
  • Compatible with commercial use and closed-source applications.

Limitations & Caveats

The project is described as being in an "early stage," indicating potential for rapid changes and evolving features. While designed for production, users should be aware of the implications of adopting a rapidly developing library.

Health Check
Last commit

1 day ago

Responsiveness

1 day

Pull Requests (30d)
13
Issues (30d)
4
Star History
347 stars in the last 90 days

Explore Similar Projects

Starred by Jared Palmer Jared Palmer(Ex-VP of AI at Vercel; Founder of Turborepo; Author of Formik, TSDX).

pgvector-node by pgvector

0.8%
399
Node.js library for pgvector support
created 4 years ago
updated 2 weeks ago
Starred by Elie Bursztein Elie Bursztein(Cybersecurity Lead at Google DeepMind), Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), and
1 more.

NeumAI by NeumTry

0%
858
Data platform for retrieval-augmented generation (RAG)
created 1 year ago
updated 1 year ago
Starred by Jared Palmer Jared Palmer(Ex-VP of AI at Vercel; Founder of Turborepo; Author of Formik, TSDX).

chatgpt-pgvector by gannonh

0%
938
Domain-specific chat completions app
created 2 years ago
updated 2 years ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems) and Elie Bursztein Elie Bursztein(Cybersecurity Lead at Google DeepMind).

LightRAG by HKUDS

1.0%
19k
RAG framework for fast, simple retrieval-augmented generation
created 10 months ago
updated 20 hours ago
Feedback? Help us improve.