Search Shortcut cmd + k | ctrl + k
anofox_decide

Natural-language decisions on your data inside DuckDB — yes/no probabilities, one-of-N choices and ordinal scores with the answer sets written in the query, from hosted (TypeSafe Jev, Liquid AI D1), local-server and in-process ONNX decision models, plus calibration metrics

Maintainer(s): sipemu, jrosskopf

Installing and Loading

INSTALL anofox_decide FROM community;
LOAD anofox_decide;

Example

-- Try the SQL with the built-in test model: no key, no network. It returns
-- constants (0.5, the first option), so it can never pass for a real answer.
SELECT decide_probability('The customer requests a refund.', 'A refund is requested.', model := 'stub') AS p;

-- Real answers: register a hosted model, opt in to remote calls, and ask.
-- (export LIQUID_API_KEY=... before starting DuckDB; a DuckDB secret overrides it)
SET anofox_decide_allow_remote = true;                 -- your text goes to the provider
SELECT decide_register_model('d1:free', 'liquid');
SET anofox_decide_model = 'd1:free';

SELECT id,
       decide_probability(text, 'A refund is requested.')                                    AS p_refund,
       decide_choice(text, 'Which team owns this?', ['billing', 'defect', 'other'])          AS team,
       decide_score(text, 'How frustrated is the writer?', ['calm', 'frustrated', 'angry'])  AS frustration
FROM (VALUES (1, 'I was charged twice for my March invoice, please refund the extra 49 EUR.'),
             (2, 'The app crashes every time I open the export dialog on version 3.2.')) t(id, text);

-- Something not working? One row per check, with the fix for each problem.
SELECT * FROM decide_doctor();

About anofox_decide

anofox_decide turns natural-language questions about text or structured data into SQL functions. Ask a yes/no question, choose one of the options you define, or rate a text on an ordered scale; purpose-built decision models answer with calibrated probabilities, so you choose the threshold and can measure how good the answers are. No training, no prompt engineering, no glue code: the questions and the answer sets are written in the query.

Three kinds of question

  • binary — decide_probability(state, 'A refund is requested.') is the probability that a statement holds; decide_decision(state, question, 0.7) applies an explicit threshold (never guessed for you).
  • choice — decide_choice(state, 'Which team owns this?', ['billing','defect','other']) picks one option from a list you define at query time, with the probability of each.
  • score — decide_score(state, 'How frustrated is the writer?', ['calm','frustrated','angry']) rates a text on an ordered rubric of 2 to 10 levels and returns the expected level.

Several questions about the same text go in one request with decide_many (JSON) or decide_table (one row per question: probability, choice, score, per-option distribution).

Pick the model that fits

One interface, several models, comparable in a single query:

  • Hosted: TypeSafe Jev (typesafe) and Liquid AI D1 (liquid). Calls send the text you score to the provider, so they sit behind an explicit opt-in (anofox_decide_allow_remote), off by default.
  • Local servers: strands-decider (strands, keyless, on loopback), Kev, or any System One compatible endpoint (systemone).
  • In-process and offline: Julia-1 and Laya on ONNX Runtime (local), exported once with the bundled tools/export_julia.
  • stub: a built-in test model that returns constants, so the SQL can be tried with no key.

API keys come from environment variables or DuckDB secrets (CREATE SECRET (TYPE anofox_decide, API_KEY '...', SCOPE 'api.liquid.ai')); a secret always overrides the environment, and a key is only ever sent to the host it was configured for. The extension ships no model weights.

Built for many rows

Scalar calls over a table evaluate a chunk of rows together: identical requests are sent once, up to anofox_decide_max_concurrency remote requests run at the same time (default 8 for hosted providers), connections are reused, and a rate limit makes the query back off. On the real Liquid D1 service, 8 tickets with three questions each took 176.7 s one at a time and 23.1 s this way.

Know how good it is

decide_accuracy, decide_brier_score and decide_ece aggregate over (probability, label) pairs, so comparing models on your own labelled data is one query. A 200-ticket evaluation of every supported model on public data is in the repository (docs/EVALUATION.md).

Errors that say what to do

Every error is <function>: <what went wrong>. Fix: <what to run> and echoes the value that caused it. decide_doctor() checks the whole setup, and decide_models() shows which models can be called right now and why not.

Surface

  • decide_probability / decide_decision / decide_choice / decide_score — evaluate one question
  • decide_many / decide_table — several questions about one text, as JSON or rows
  • decide_accuracy / decide_brier_score / decide_ece — quality metrics (aggregates)
  • decide_register_model / decide_unregister_model / decide_models / decide_doctor — models and diagnostics
  • SET anofox_decide_* settings (default model, remote opt-in, concurrency, timeout, retries)

Every function is also available as anofox_decide_*. See the project repository for the full SQL API, examples and troubleshooting.

Added Functions

function_name function_type description comment examples
anofox_decide_accuracy aggregate Fraction of rows where thresholding the probability reproduces the outcome. The two-argument form uses the documented 0.5 boundary; the three-argument form takes an explicit threshold in [0, 1] (NaN or out-of-range thresholds raise an error). NULL inputs are skipped; empty input returns NULL. NULL [SELECT decide_accuracy(p, y) FROM labeled;]
anofox_decide_accuracy aggregate Fraction of rows where thresholding the probability reproduces the outcome. The two-argument form uses the documented 0.5 boundary; the three-argument form takes an explicit threshold in [0, 1] (NaN or out-of-range thresholds raise an error). NULL inputs are skipped; empty input returns NULL. NULL [SELECT decide_accuracy(p, y, 0.7) FROM labeled;]
anofox_decide_accuracy aggregate Fraction of rows where thresholding the probability reproduces the outcome. The two-argument form uses the documented 0.5 boundary; the three-argument form takes an explicit threshold in [0, 1] (NaN or out-of-range thresholds raise an error). NULL inputs are skipped; empty input returns NULL. NULL [SELECT decide_accuracy(p, y::BIGINT) FROM labeled;]
anofox_decide_brier_score aggregate Brier score of predicted probabilities against observed outcomes: mean squared difference between the probability and the 0/1 outcome (lower is better; 0 is perfect, 0.25 is a constant 0.5). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_brier_score(p, y) FROM labeled;]
anofox_decide_brier_score aggregate Brier score of predicted probabilities against observed outcomes: mean squared difference between the probability and the 0/1 outcome (lower is better; 0 is perfect, 0.25 is a constant 0.5). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_brier_score(p, y::BIGINT) FROM labeled;]
anofox_decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_choice('Invoice charged twice', 'Primary issue?', ['billing','defect','other']);]        
anofox_decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_choice('Invoice charged twice', 'Primary issue?', ['billing','defect']);]        
anofox_decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [SELECT decide_choice('Invoice charged twice', 'Primary issue?', ['billing','defect'], model := 'stub');]
anofox_decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [SELECT decide_choice(body, 'Which team owns this?', ['billing','defect','other'], model := 'jev-latest') FROM tickets;]
anofox_decide_decision scalar Boolean decision: true when the probability that question holds for state reaches threshold (0 to 1, inclusive). NULL state or question returns NULL; NaN or out-of-range thresholds raise an error instead of clamping. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_decision('The customer requests a refund.', 'A refund is requested.', 0.7);]        
anofox_decide_decision scalar Boolean decision: true when the probability that question holds for state reaches threshold (0 to 1, inclusive). NULL state or question returns NULL; NaN or out-of-range thresholds raise an error instead of clamping. NULL [SELECT decide_decision(body, 'A refund is requested.', 0.7, model := 'jev-latest') FROM tickets;]
anofox_decide_doctor table Check whether the setup is ready and say how to fix what is not: the default model, the registered models, the remote opt-in, one row per registered model (files readable, API key found and from where, endpoint) and the telemetry state. Columns: item, status (ok / warn / fail), detail, fix. Run it first when a call does not work. NULL [SELECT * FROM decide_doctor();]
anofox_decide_ece aggregate Expected calibration error over ten equal-width probability bins: the bin-weighted gap between average confidence and accuracy (lower is better). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_ece(p, y) FROM labeled;]
anofox_decide_ece aggregate Expected calibration error over ten equal-width probability bins: the bin-weighted gap between average confidence and accuracy (lower is better). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_ece(p, y::BIGINT) FROM labeled;]
anofox_decide_many scalar Evaluate several questions against one state in a single provider call. questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects; returns a JSON object {model, results: […]} with one answer per question, in order: id, kind and probability; a choice adds choice and the per-option probabilities; a score adds score (the expected 0-based level) and the per-level probabilities. Remote providers receive one request for the whole batch. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_many('The bill is wrong.', '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]');]        
anofox_decide_many scalar Evaluate several questions against one state in a single provider call. questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects; returns a JSON object {model, results: […]} with one answer per question, in order: id, kind and probability; a choice adds choice and the per-option probabilities; a score adds score (the expected 0-based level) and the per-level probabilities. Remote providers receive one request for the whole batch. NULL [SELECT decide_many(body, '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]', model := 'jev-latest') FROM tickets;]
anofox_decide_models table List the models registered on this database instance and whether each can be called now. Columns: model, provider, mode ('test' / 'local' / 'remote'), path, is_default, ready, hint (what to do when it is not ready), profile, endpoint, wire_model. The built-in 'stub' test model is always present; register more with decide_register_model. NULL [SELECT * FROM decide_models();]
anofox_decide_probability scalar Probability (0 to 1) that the statement question holds for state, scored by the named model (model :=, or the anofox_decide_model setting; with neither the call fails and says how to choose one). NULL state or question returns NULL; unknown models, remote calls without opt-in and missing API keys raise errors that name the fixing call. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_probability('The customer requests a refund.', 'A refund is requested.');]        
anofox_decide_probability scalar Probability (0 to 1) that the statement question holds for state, scored by the named model (model :=, or the anofox_decide_model setting; with neither the call fails and says how to choose one). NULL state or question returns NULL; unknown models, remote calls without opt-in and missing API keys raise errors that name the fixing call. NULL [SELECT decide_probability(body, 'A refund is requested.', model := 'jev-latest') FROM tickets;]
anofox_decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('jev-latest', 'typesafe');]
anofox_decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('julia-1', 'local', '/models/julia1.onnx');]
anofox_decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('julia-1', 'local', '/models/julia1.onnx', '/models/tokenizer/tokenizer.json');]
anofox_decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('kev-latest', 'systemone', MAP {'endpoint': 'http://127.0.0.1:8009'});]
anofox_decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('laya', 'local', '/models/laya.onnx', '/models/tokenizer/tokenizer.json', 'laya');]
anofox_decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('my-stub');]
anofox_decide_score scalar Rate state on an ordered rubric of 2 to 10 level descriptions (lowest first) and return the expected level index (0-based) as a DOUBLE, e.g. 1.4 between 'frustrated' (1) and 'angry' (2). Per-level probabilities and confidence are available through decide_many and decide_table. NULL state, question or levels returns NULL; empty, repeated, NULL or out-of-range levels raise an actionable error. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_score('Help! My payouts failed for 3 days!', 'How frustrated is the writer?', ['calm','frustrated','angry']);]        
anofox_decide_score scalar Rate state on an ordered rubric of 2 to 10 level descriptions (lowest first) and return the expected level index (0-based) as a DOUBLE, e.g. 1.4 between 'frustrated' (1) and 'angry' (2). Per-level probabilities and confidence are available through decide_many and decide_table. NULL state, question or levels returns NULL; empty, repeated, NULL or out-of-range levels raise an actionable error. NULL [SELECT decide_score(body, 'How urgent is this?', ['can wait','this week','today'], model := 'jev-latest') FROM tickets;]
anofox_decide_table table Score several questions against one state and return one row per answer (question id, kind, probability, choice, confidence, model, plus score and distribution). questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects. With constant arguments it is one request for all questions; in LATERAL over a table of states it scores every row, one request per row and one row at a time (for many rows use the scalar functions, which run concurrently). Name the model with model := or the third argument. NULL [SELECT * FROM decide_table('The bill is wrong.', '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]', model := 'stub');]
anofox_decide_table table Score several questions against one state and return one row per answer (question id, kind, probability, choice, confidence, model, plus score and distribution). questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects. With constant arguments it is one request for all questions; in LATERAL over a table of states it scores every row, one request per row and one row at a time (for many rows use the scalar functions, which run concurrently). Name the model with model := or the third argument. NULL [SELECT * FROM tickets, LATERAL (SELECT * FROM decide_table(tickets.body, '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]', model := 'jev-latest')) dt;]
anofox_decide_unregister_model scalar Remove a registered model by id and return true, e.g. to re-register it with different settings. The built-in 'stub' test model cannot be removed. An unknown id raises an error that suggests a close match. NULL [SELECT decide_unregister_model('my-model');]
decide_accuracy aggregate Fraction of rows where thresholding the probability reproduces the outcome. The two-argument form uses the documented 0.5 boundary; the three-argument form takes an explicit threshold in [0, 1] (NaN or out-of-range thresholds raise an error). NULL inputs are skipped; empty input returns NULL. NULL [SELECT decide_accuracy(p, y) FROM labeled;]
decide_accuracy aggregate Fraction of rows where thresholding the probability reproduces the outcome. The two-argument form uses the documented 0.5 boundary; the three-argument form takes an explicit threshold in [0, 1] (NaN or out-of-range thresholds raise an error). NULL inputs are skipped; empty input returns NULL. NULL [SELECT decide_accuracy(p, y, 0.7) FROM labeled;]
decide_accuracy aggregate Fraction of rows where thresholding the probability reproduces the outcome. The two-argument form uses the documented 0.5 boundary; the three-argument form takes an explicit threshold in [0, 1] (NaN or out-of-range thresholds raise an error). NULL inputs are skipped; empty input returns NULL. NULL [SELECT decide_accuracy(p, y::BIGINT) FROM labeled;]
decide_brier_score aggregate Brier score of predicted probabilities against observed outcomes: mean squared difference between the probability and the 0/1 outcome (lower is better; 0 is perfect, 0.25 is a constant 0.5). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_brier_score(p, y) FROM labeled;]
decide_brier_score aggregate Brier score of predicted probabilities against observed outcomes: mean squared difference between the probability and the 0/1 outcome (lower is better; 0 is perfect, 0.25 is a constant 0.5). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_brier_score(p, y::BIGINT) FROM labeled;]
decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_choice('Invoice charged twice', 'Primary issue?', ['billing','defect','other']);]        
decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_choice('Invoice charged twice', 'Primary issue?', ['billing','defect']);]        
decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [SELECT decide_choice('Invoice charged twice', 'Primary issue?', ['billing','defect'], model := 'stub');]
decide_choice scalar Choose the single best answer for question from a runtime-defined list of options given state. Returns the winning option; the score distribution is available through decide_many and decide_table. An empty or NULL option list raises an actionable error. NULL [SELECT decide_choice(body, 'Which team owns this?', ['billing','defect','other'], model := 'jev-latest') FROM tickets;]
decide_decision scalar Boolean decision: true when the probability that question holds for state reaches threshold (0 to 1, inclusive). NULL state or question returns NULL; NaN or out-of-range thresholds raise an error instead of clamping. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_decision('The customer requests a refund.', 'A refund is requested.', 0.7);]        
decide_decision scalar Boolean decision: true when the probability that question holds for state reaches threshold (0 to 1, inclusive). NULL state or question returns NULL; NaN or out-of-range thresholds raise an error instead of clamping. NULL [SELECT decide_decision(body, 'A refund is requested.', 0.7, model := 'jev-latest') FROM tickets;]
decide_doctor table Check whether the setup is ready and say how to fix what is not: the default model, the registered models, the remote opt-in, one row per registered model (files readable, API key found and from where, endpoint) and the telemetry state. Columns: item, status (ok / warn / fail), detail, fix. Run it first when a call does not work. NULL [SELECT * FROM decide_doctor();]
decide_ece aggregate Expected calibration error over ten equal-width probability bins: the bin-weighted gap between average confidence and accuracy (lower is better). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_ece(p, y) FROM labeled;]
decide_ece aggregate Expected calibration error over ten equal-width probability bins: the bin-weighted gap between average confidence and accuracy (lower is better). Rows with a NULL probability or outcome are skipped; empty input returns NULL. NULL [SELECT decide_ece(p, y::BIGINT) FROM labeled;]
decide_many scalar Evaluate several questions against one state in a single provider call. questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects; returns a JSON object {model, results: […]} with one answer per question, in order: id, kind and probability; a choice adds choice and the per-option probabilities; a score adds score (the expected 0-based level) and the per-level probabilities. Remote providers receive one request for the whole batch. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_many('The bill is wrong.', '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]');]        
decide_many scalar Evaluate several questions against one state in a single provider call. questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects; returns a JSON object {model, results: […]} with one answer per question, in order: id, kind and probability; a choice adds choice and the per-option probabilities; a score adds score (the expected 0-based level) and the per-level probabilities. Remote providers receive one request for the whole batch. NULL [SELECT decide_many(body, '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]', model := 'jev-latest') FROM tickets;]
decide_models table List the models registered on this database instance and whether each can be called now. Columns: model, provider, mode ('test' / 'local' / 'remote'), path, is_default, ready, hint (what to do when it is not ready), profile, endpoint, wire_model. The built-in 'stub' test model is always present; register more with decide_register_model. NULL [SELECT * FROM decide_models();]
decide_probability scalar Probability (0 to 1) that the statement question holds for state, scored by the named model (model :=, or the anofox_decide_model setting; with neither the call fails and says how to choose one). NULL state or question returns NULL; unknown models, remote calls without opt-in and missing API keys raise errors that name the fixing call. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_probability('The customer requests a refund.', 'A refund is requested.');]        
decide_probability scalar Probability (0 to 1) that the statement question holds for state, scored by the named model (model :=, or the anofox_decide_model setting; with neither the call fails and says how to choose one). NULL state or question returns NULL; unknown models, remote calls without opt-in and missing API keys raise errors that name the fixing call. NULL [SELECT decide_probability(body, 'A refund is requested.', model := 'jev-latest') FROM tickets;]
decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('jev-latest', 'typesafe');]
decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('julia-1', 'local', '/models/julia1.onnx');]
decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('julia-1', 'local', '/models/julia1.onnx', '/models/tokenizer/tokenizer.json');]
decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('kev-latest', 'systemone', MAP {'endpoint': 'http://127.0.0.1:8009'});]
decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('laya', 'local', '/models/laya.onnx', '/models/tokenizer/tokenizer.json', 'laya');]
decide_register_model scalar Register a model id for this database instance and return true. Providers: 'stub' (deterministic), 'local' (ONNX graph and tokenizer paths, optional profile 'julia-1' or 'laya'), and the remote providers 'typesafe', 'liquid', 'systemone' and 'strands' (optional options MAP with endpoint, path, model, key_env, criteria). Duplicate ids, unsupported providers and unreadable files raise actionable errors. NULL [SELECT decide_register_model('my-stub');]
decide_score scalar Rate state on an ordered rubric of 2 to 10 level descriptions (lowest first) and return the expected level index (0-based) as a DOUBLE, e.g. 1.4 between 'frustrated' (1) and 'angry' (2). Per-level probabilities and confidence are available through decide_many and decide_table. NULL state, question or levels returns NULL; empty, repeated, NULL or out-of-range levels raise an actionable error. NULL [– uses the session default model: SET anofox_decide_model = '';
SELECT decide_score('Help! My payouts failed for 3 days!', 'How frustrated is the writer?', ['calm','frustrated','angry']);]        
decide_score scalar Rate state on an ordered rubric of 2 to 10 level descriptions (lowest first) and return the expected level index (0-based) as a DOUBLE, e.g. 1.4 between 'frustrated' (1) and 'angry' (2). Per-level probabilities and confidence are available through decide_many and decide_table. NULL state, question or levels returns NULL; empty, repeated, NULL or out-of-range levels raise an actionable error. NULL [SELECT decide_score(body, 'How urgent is this?', ['can wait','this week','today'], model := 'jev-latest') FROM tickets;]
decide_table table Score several questions against one state and return one row per answer (question id, kind, probability, choice, confidence, model, plus score and distribution). questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects. With constant arguments it is one request for all questions; in LATERAL over a table of states it scores every row, one request per row and one row at a time (for many rows use the scalar functions, which run concurrently). Name the model with model := or the third argument. NULL [SELECT * FROM decide_table('The bill is wrong.', '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]', model := 'stub');]
decide_table table Score several questions against one state and return one row per answer (question id, kind, probability, choice, confidence, model, plus score and distribution). questions is a JSON array of {id, kind: 'binary'|'choice'|'score', instruction[, options | levels]} objects. With constant arguments it is one request for all questions; in LATERAL over a table of states it scores every row, one request per row and one row at a time (for many rows use the scalar functions, which run concurrently). Name the model with model := or the third argument. NULL [SELECT * FROM tickets, LATERAL (SELECT * FROM decide_table(tickets.body, '[{"id":"refund","kind":"binary","instruction":"A refund is requested."}]', model := 'jev-latest')) dt;]
decide_unregister_model scalar Remove a registered model by id and return true, e.g. to re-register it with different settings. The built-in 'stub' test model cannot be removed. An unknown id raises an error that suggests a close match. NULL [SELECT decide_unregister_model('my-model');]

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

name description input_type scope aliases
anofox_decide_allow_remote Off by default. When on, remote models (typesafe, liquid, systemone, strands) may be called, which sends the text you score to their endpoints BOOLEAN GLOBAL []
anofox_decide_api_key Legacy API key for the typesafe provider, kept in plain text and readable with current_setting(); prefer CREATE SECRET (TYPE anofox_decide, API_KEY '…') or the TYPESAFE_API_KEY environment variable VARCHAR GLOBAL []
anofox_decide_endpoint Legacy endpoint for the typesafe provider (default https://api.typesafe.ai); other remote providers take a per-model endpoint (the options MAP of decide_register_model) VARCHAR GLOBAL []
anofox_decide_head_length Tokens reserved for the question and its options in local models (default 512); must stay below anofox_decide_max_length BIGINT GLOBAL []
anofox_decide_max_concurrency How many remote requests one query sends at the same time (0 to 64, default 0 = automatic: 8 for hosted providers, 1 for the local strands server). 1 sends them one after another. Lower it if the service rate limits you BIGINT GLOBAL []
anofox_decide_max_length Maximum tokens a julia-1 local model reads per question (default 8192); longer text is cut off. Laya models use the limit in their rl_agent_config.json instead BIGINT GLOBAL []
anofox_decide_max_questions Maximum questions per decide_many / decide_table call (default 100, at most 1000) BIGINT GLOBAL []
anofox_decide_max_retries Retries after a rate limit (429), server error (5xx) or connection failure for remote calls (default 3, at most 10) BIGINT GLOBAL []
anofox_decide_model Model id used when a decide_* call names no model (must be registered, see decide_models()). Unset by default: name a model per call or SET it. 'stub' is a built-in test model that returns constants VARCHAR GLOBAL []
anofox_decide_timeout_ms Per-request timeout for remote model calls, in milliseconds (default 30000) BIGINT GLOBAL []
anofox_telemetry_enabled Enable or disable anonymous usage telemetry BOOLEAN GLOBAL []
anofox_telemetry_key PostHog API key for telemetry VARCHAR GLOBAL []
datazoo_banner Show the DataZoo feedback banner when an extension is loaded in an interactive terminal (at most once a day per extension). BOOLEAN GLOBAL []