Skip to main content

AI workflows in your PostgreSQL database

Project description

pgai

Power your RAG and Agentic applications with PostgreSQL


A Python library that transforms PostgreSQL into a robust, production-ready retrieval engine for RAG and Agentic applications.

  • 🔄 Automatically create and synchronize vector embeddings from PostgreSQL data and S3 documents. Embeddings update automatically as data changes.

  • 🔍 Powerful vector and semantic search with pgvector and pgvectorscale.

  • 🛡️ Production-ready out-of-the-box: Supports batch processing for efficient embedding generation, with built-in handling for model failures, rate limits, and latency spikes.

  • 🐘 Works with any PostgreSQL database, including Timescale Cloud, Amazon RDS, Supabase and more.

Getting Started

Install:

pip install pgai
pgai install -d "postgresql://postgres:postgres@localhost:5432/postgres"

The key "secret sauce" of pgai Vectorizer is its declarative approach to embedding generation. Simply define your pipeline and let Vectorizer handle the operational complexity of keeping embeddings in sync, even when embedding endpoints are unreliable. You can define a simple version of the pipeline as follows:

SELECT ai.create_vectorizer(
     'wiki'::regclass,
     loading => ai.loading_column(column_name=>'text'),
     embedding => ai.embedding_openai(model=>'text-embedding-ada-002', dimensions=>'1536'),
     destination => ai.destination_table(target_table=>'wiki_embedding_storage')
    )

The vectorizer will automatically create embeddings for all the rows in the wiki table, and, more importantly, will keep the embeddings synced with the underlying data as it changes. Think of it almost like declaring an index on the wiki table, but instead of the database managing the index datastructure for you, the vectorizer is managing the embeddings.

Checkout our full quick start on github

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

pgai-0.12.1.tar.gz (18.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgai-0.12.1-py3-none-any.whl (3.9 MB view details)

Uploaded Python 3

File details

Details for the file pgai-0.12.1.tar.gz.

File metadata

  • Download URL: pgai-0.12.1.tar.gz
  • Upload date:
  • Size: 18.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pgai-0.12.1.tar.gz
Algorithm Hash digest
SHA256 c73008713301995345bfa1e3f8fa93628ed46991cd4ccbcee6696c0838208b10
MD5 79bce44f419702eea9d3c5ae06629d27
BLAKE2b-256 5e6495e53a596ab1cbaa6662c3b447b25bdeb3cc05ff46b7941553cb95b4df50

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgai-0.12.1.tar.gz:

Publisher: release-please.yml on timescale/pgai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgai-0.12.1-py3-none-any.whl.

File metadata

  • Download URL: pgai-0.12.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pgai-0.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16f38e891d251472c69cc34aea5177d5c0f5309ddf1a6f79699eb3ec6310a2ee
MD5 02e4b8db97a5e012bd5a70baa849b939
BLAKE2b-256 c60dadca8d6416954232641a93708bc3b4e1caa7b5fa866aa9f61f94faefa7c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgai-0.12.1-py3-none-any.whl:

Publisher: release-please.yml on timescale/pgai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page