← Index

CHOOSEData & productivity

PostgreSQL Extension for TypeSafe AI Jev Integration

Project photo 1

This project is a PostgreSQL extension that allows SQL queries to directly call TypeSafe AI's Jev for classifying rows within a database table, avoiding the need to export data for external processing.

SignalThe extension now packs those distinct texts into one TypeSafe request, evaluates them together and joins the labels back. 1000 rows, 38 strings in about 0.8 seconds.

I built a PostgreSQL extension that calls @typesafeai Jev from SQL. You classify rows that already live in a table, instead of shipping them out to a Python job. It looks like any other PG function: typesafe_noul(resolution, 'Does this say the condition could not be found, or that access was unavailable?') Jev fits that kind of question very well and returns a probability over a closed set. The obvious implementation is a trap. Each call is synchronous HTTPS from one backend, so Postgres waits. I loaded a thousand real closed NYC 311 complaints to see how bad that was. They collapse to 38 distinct resolution strings (311 uses canned language) and going one by one still took 23 seconds. Almost none of that time was to be attributed to Postgres. The extension now packs those distinct texts into one TypeSafe request, evaluates them together and joins the labels back. 1000 rows, 38 strings in about 0.8 seconds. Keep the api key out of the query. Set TYPESAFE_API_KEY on the server process. github.com/giuliosmall/pg_typesafe