SDK reference · Python SDK
prov.trace.patterns.preview
prov.trace.patterns.preview in Python SDK. How many of your latest runs an unsaved definition matches.
Signature
prov.trace.patterns.preview(definition: dict, limit: Optional[int] = …) -> AnyParameters
definitiondictRequiredlimitOptional[int]
Request fields
definitionobjectRequired- Rules combined with
anyorall.Show child attributes
matchenum- Whether one rule is enough or all must match. One of
any,all. rulesarray of objectsRequired- The rules.
Show child attributes
kindenumRequired- The rule kind. One of
family,neurons,label,activation. familystringfamily: the canary family.min_scorenumberfamily: match at or above this score. Default: when it tripped.refsarray of stringsneurons: neuron refs,L<layer>.<idx>.<pos|neg>.querystringlabel: a case-insensitive part of a registry label.minnumberactivation: the activation to reach.layersarray of integersactivation: an inclusive [from, to] layer range.poleenumactivation: one pole only. One ofpos,neg.min_activationnumberneuronsandlabel: the activation to reach.min_countinteger- Neuron rules: how many neurons must match. Default 1.
limitinteger- Latest runs to scan.
Returns
Any The preview.
HTTP operation
POST /v1/trace/patterns/preview: Preview a pattern
Errors
Example
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/trace/patterns/preview`, {
method: "POST",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"definition": {
"rules": [
{
"kind": "family",
"family": "prompt_injection"
}
]
},
"limit": 1
}),
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/trace/patterns/preview", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"definition": {
"rules": [
{
"kind": "family",
"family": "prompt_injection"
}
]
},
"limit": 1
}).json()