Uses the LLM to parse free text into Atlas constraints, mapping to
machine-checked types wherever possible: "wt must be used" becomes
con_uses(), "mpg should never increase with weight" becomes
con_monotone(), and anything else becomes a prompt-enforced
constraint(). Returns the list for you to inspect (print it!) before
passing to atlas() - the parse is a judgment call, so review it.
Arguments
- text
The brief, in plain language. Sentences, bullets, whatever.
- data
Optional data.frame the constraints are about; its column names are given to the parser, and extracted variable names are validated against them (a constraint naming an unknown column falls back to prompt-only enforcement).
- chat
An ellmer chat object; defaults to
ellmer::chat_anthropic().
Value
A named list of constraint() objects, ready for the
constraints argument of atlas() or atlas_session.
Examples
if (FALSE) { # \dontrun{
cons <- extract_constraints(
"weight must be in the model; predictions can never go up as
horsepower rises; qsec is post-hoc, never use it",
data = mtcars
)
cons # inspect: which became machine checks?
res <- atlas(mtcars, "mpg", constraints = cons)
} # }