Favicon of pgai

pgai

A self-hosted Python library for PostgreSQL RAG and semantic search with Ollama support; the open-source project is archived and no longer maintained.

pgai is a Python library for developers building RAG applications and AI agents around PostgreSQL data. The project is archived and no longer maintained or supported.

  • Embedding sync: Creates embeddings from database columns, files and S3 documents, then updates them as the source data changes.
  • Document search: Parses PDF, HTML and Markdown files and splits text into chunks for search with pgvector, with pgvectorscale supporting larger vector workloads.
  • Model comparison: Creates multiple embeddings for the same data with different models and parameters so developers can compare results.
  • Natural language queries: The Semantic Catalog supports text-to-SQL through generated database descriptions that people can review and edit, plus stored SQL examples and business facts.
  • Background processing: Batches embedding jobs and retries failed requests while ordinary database writes remain independent of model endpoint delays or failures.

You can self-host the database components and vectorizer workers. pgai also works with hosted PostgreSQL services, including Timescale Cloud, Amazon RDS and Supabase. Embeddings and text chunks are stored in PostgreSQL. Supported embedding providers include Ollama, OpenAI, Voyage AI, Cohere, Huggingface, Mistral, Azure OpenAI, AWS Bedrock and Vertex AI.

A separate PostgreSQL extension supports model calls directly from SQL for classification, summarization and data enrichment. The code is open source under the PostgreSQL License.

Similar to pgai