PG-Jev: Natural Language Querying and AI-Driven Decision Modeling for PostgreSQL

Clip title: PG-Jev: Query Your Database in Plain English with Decision Model Author / channel: Fahd Mirza URL: https://www.youtube.com/watch?v=XiGBCk5MnnY

Summary

This video introduces pg-jev, a PostgreSQL extension designed to enable natural language querying directly within SQL. Distinguishing itself from merely being “yet another decision model,” pg-jev offers a practical, real-world application for filtering, ranking, and classifying database rows using plain English conditions within SQL WHERE clauses. The speaker highlights that this approach allows the database to retain control of the data, while jev handles the semantic understanding that traditional SQL struggles to express, eliminating the need for complex application-level logic or data movement.

The installation and setup process for pg-jev is demonstrated on an Ubuntu 22.04 LTS environment. Key steps include installing PostgreSQL and its Python support (postgresql-plpython3-14), followed by installing the pgxnclient (PostgreSQL Extension Network client), which acts similarly to NPM for PostgreSQL extensions. Once pgxnclient is set up and the jev extension is installed and created within PostgreSQL, users can configure it with an OpenAI-compatible API key and a specific model (e.g., typesafe/jev-1.13) to enable its advanced functionality.

The speaker then illustrates pg-jev’s capabilities through several compelling real-world examples using a customer support ticket database. First, jev is used to rank tickets by “anger or frustration” level, successfully identifying critical issues like “App crashing” and “Charged twice” with high probability scores, while marking “Happy customer” as low priority. Second, jev is tasked with automatically assigning tickets to specific departments (billing, technical, shipping, security) based on natural language, showcasing accurate routing for issues like “Wrong item delivered” to shipping and “Suspicious activity” to security. Finally, a third example demonstrates scoring ticket urgency from “low” to “critical,” with “Suspicious activity” correctly receiving the highest urgency score.

In conclusion, pg-jev empowers users to perform sophisticated data analysis, ranking, and classification directly within their PostgreSQL databases using intuitive plain English queries, effectively replacing potentially complex, custom-built routing or classification engines. The speaker emphasizes the power of these “decision models” in practical applications, noting that while pg-jev offers a seamless integration, similar results could also be achieved by leveraging local AI models with tool-calling mechanisms, highlighting the broader utility and accessibility of natural language processing for database interactions.

Description

This video locally installs and tests pg-jev, which is a PostgreSQL extension powered by TypeSafe’s Jev.

pgjev jev

▶ LinkedIn: / fahdmirza
▶ YouTube: / @fahdmirza

▶ https://github.com/realZachi/pg-jev

All rights reserved © Fahd Mirza

URLs