Skip to content

Custom detectors

Custom detectors let you catch data that only your organization cares about: customer account numbers, internal project code names, part numbers, ticket IDs, unreleased product names. Define them in YAML, test them with the CLI, and refer to them in policies like built-in data classes.

apiVersion: promptglass.ai/v1
kind: Detector
metadata:
name: acme-customer-account
spec:
dataClass: acme.customer_account
description: "Acme customer account numbers (AC-########-C)"
pattern: '\bAC-\d{8}-[0-9X]\b'
validator:
type: mod11 # luhn | mod11 | mod97 | iban | custom-wasm
context:
words: [account, customer, acct, "client id"]
window: 60 # characters on either side
required: false # when true, a match without context is dropped
boost: high # confidence when context is present
allowlist: ["AC-00000000-0"]
kind: Detector
metadata: { name: project-codenames }
spec:
dataClass: acme.codename
dictionary:
caseSensitive: false
wholeWord: true
terms: [Bluefin, Kestrel, "Project Atlas", Nightjar]
minCount: 1

Dictionaries can hold hundreds of thousands of terms. They compile to an Aho-Corasick automaton, so lookup cost doesn’t grow with dictionary size.

Finds documents that talk about a sensitive topic without fixed identifiers:

kind: Detector
metadata: { name: unreleased-earnings }
spec:
dataClass: business.financials.unreleased
proximity:
all: [[revenue, EBITDA, "gross margin", guidance], [Q1, Q2, Q3, Q4, FY2026, FY2027]]
any: [draft, "not for distribution", preliminary]
window: 200

Upload labeled examples (at least 50 positive and 50 negative) under Detection → Classifiers → New. PromptGlass fine-tunes a small text classifier inside your tenant. Your examples never leave your deployment, and they are never used to train anyone else’s models. Refer to the classifier as classifier: <name> in a detector.

Terminal window
promptglass detector apply -f detectors/
promptglass detector test acme-customer-account --file samples/ticket.txt
promptglass detector test --all --corpus ./regression-corpus/ # precision/recall report

Keep detector files in Git next to your policies. A CI job that runs promptglass detector test --corpus before apply catches regressions early.