SDK reference · Python SDK

prov.trace.patterns.update

prov.trace.patterns.update in Python SDK.

Signature

prov.trace.patterns.update(pattern_id: str, name: str, definition: dict, description: Optional[str] = …) -> Any

Parameters

pattern_idstrRequired
namestrRequired
definitiondictRequired
descriptionOptional[str]

Request fields

namestringRequired
The pattern's name.
descriptionstring | null
What it looks for.
definitionobjectRequired
Rules combined with any or all.
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.
familystring
family: the canary family.
min_scorenumber
family: match at or above this score. Default: when it tripped.
refsarray of strings
neurons: neuron refs, L<layer>.<idx>.<pos|neg>.
querystring
label: a case-insensitive part of a registry label.
minnumber
activation: the activation to reach.
layersarray of integers
activation: an inclusive [from, to] layer range.
poleenum
activation: one pole only. One of pos, neg.
min_activationnumber
neurons and label: the activation to reach.
min_countinteger
Neuron rules: how many neurons must match. Default 1.

Returns

Any The pattern, at its new version.

HTTP operation

PATCH /v1/trace/patterns/{id}: Update a pattern

Errors

Example

const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/trace/patterns`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "name": "Wire instructions in late layers",
    "description": "A wire-transfer label active past layer 12, with the injection family tripped.",
    "definition": {
      "match": "all",
      "rules": [
        {
          "kind": "family",
          "family": "prompt_injection"
        },
        {
          "kind": "activation",
          "min": 1.5,
          "layers": [
            12,
            23
          ]
        }
      ]
    }
  }),
})).json();
const patternId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/trace/patterns/${patternId}`, {
  method: "PATCH",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "name": "Wire instructions in late layers",
    "definition": {
      "match": "all",
      "rules": [
        {
          "kind": "family",
          "family": "prompt_injection"
        },
        {
          "kind": "activation",
          "min": 2,
          "layers": [
            12,
            23
          ]
        }
      ]
    }
  }),
})).json();

Was this page helpful? Send us feedback

LLM? Read llms.txt.