AI_CLASSIFY

Classify text into exactly one of the given categories via a registered chat model.

Category: aiReturns: STRINGDialect: DeltaForgeDeltaForge extension

Syntax

AI_CLASSIFY(model_name, text, category1 [, category2 ...])
AI_CLASSIFY(text USE MODEL model_name, category1 [, category2 ...])

Description

## Overview Task sugar over AI_GENERATE: the instruction names the categories and demands exactly one of them as the whole response, composed after the model's SYSTEM_PROMPT. Identical texts within a batch classify once, and the per-session response memo makes re-runs free. ## Reliability The instruction demands the category verbatim, and low temperature (set on the model's PARAMETERS) makes conformance highly reliable, but an LLM is not a constraint engine: guard downstream logic with an IN (...) check when a stray answer must not slip through. The USE MODEL sugar form is accepted and rewritten to the leading-model-argument form.

Parameters

NameTypeDescription
model_nameThe registry name of a MODEL_TYPE = CHAT model. Must be constant within a query.
textThe text to classify. NULL produces NULL without calling the provider.
category1..NOne or more category labels (string constants). The model is instructed to respond with exactly one of them, verbatim.

Examples

SELECT ticket_id,
       AI_CLASSIFY('support_triage', body, 'billing', 'outage', 'feature_request') AS category
FROM support.bronze.tickets;
-- Route rows by classification
SELECT * FROM support.bronze.tickets
WHERE AI_CLASSIFY('support_triage', body, 'billing', 'outage', 'feature_request') = 'outage';

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →