Filter Postgres rows in plain .
Write the condition the way you would say it. Postgres does the rest.
SELECT * FROM reviews
WHERE jev(reviews, 'the customer is angry');Four functions. Same row, different answer.
SELECT *
FROM people
WHERE jev(people, 'the name is European')
AND age > 40;A boolean predicate. It composes with every other condition, join and index in the query.
One scan, a handful of requests.
Every row goes to the API, by design. Filter with indexed predicates first when the table is large.
Read ahead
On the first call for a table and condition, the extension reads the table up front instead of judging row by row.
Batch
Rows are packed 40 per request into one shared state with a yes/no question per row.
Judge in parallel
Jev evaluates every question over that state at once. Six requests run concurrently by default.
Cache
Answers are cached per row content for the session. Changing the threshold or sorting by probability costs nothing.
- First run, 2,000 rows
- <2 s
- Cost of that run
- ~$0.009
- Second run, cached
- 6 ms
Plain SQL functions.
All functions and settingsjev(row, condition [, threshold])booleanThe WHERE predicate. True when the probability clears the threshold, 0.5 by default.
jev_prob(row, condition)float8Probability from 0 to 1 that the row satisfies the condition.
jev_score(row, question, levels)float8Probability-weighted position on an ordered list of levels.
jev_choice(row, question, options)textThe most likely option for the row.
jev_eval(row, question, kind, options)jsonbThe full raw answer: probabilities, legend and confidence.
jev_stats()jsonbRequests, tokens, estimated cost and cache hits for this session.
Install in two commands.
Requires PostgreSQL 14 to 17 with plpython3u and a TypeSafe API key. A Docker image is included for trying it out.
git clone https://github.com/realZachi/pg-jev.git && cd pg-jev
make installCREATE EXTENSION jev;
SET jev.api_key = 'your-typesafe-key';