Classify text into exactly one of the given categories via a registered chat model.
AI_CLASSIFY(model_name, text, category1 [, category2 ...])
AI_CLASSIFY(text USE MODEL model_name, category1 [, category2 ...])
## 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.
| Name | Type | Description |
|---|---|---|
model_name | The registry name of a MODEL_TYPE = CHAT model. Must be constant within a query. | |
text | The text to classify. NULL produces NULL without calling the provider. | |
category1..N | One or more category labels (string constants). The model is instructed to respond with exactly one of them, verbatim. |
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';