SAMGuardrail
smarter.models.sam.guardrail
SAM model of the Guardrail kind, generated from the Smarter platform’s JSON Schema.
Do not edit: run scripts/generate_sam_models.py. See smarter.models.sam.
- class smarter.models.sam.guardrail.SAMDependency
Bases:
smarter.models.sam.base.SAMModelA resource that depends on the resource that a manifest describes.
- class smarter.models.sam.guardrail.SAMGuardrailMetadata
Bases:
smarter.models.sam.base.SAMModelSmarter API Guardrail Manifest - Metadata class.
- annotations: None | list[dict[str, str | int | float | bool | datetime.date | datetime.datetime | Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern='^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$')] | uuid.UUID | bytes | list | dict[str, Any]]]
The manifest annotations.
- Used for storing arbitrary metadata as
key-value pairs. Example: [{‘smarter.sh/test-manifest/project-name’: ‘Scooby dooby do’}]. The key should be a valid url-friendly string. The value accepts multi-line string values (YAML block scalars) and various scalar types including str, int, float, bool, datetime.date, datetime.datetime, decimal.Decimal, uuid.UUID, bytes, list, dict.
- class smarter.models.sam.guardrail.SAMGuardrailSpecConfig
Bases:
smarter.models.sam.base.SAMModelSmarter API Guardrail Manifest Guardrail.spec.config.
- action: str
Guardrail.spec.config.action[str]: what the guardrail does when it triggers.
One of: [‘log’, ‘flag’, ‘redact’, ‘transform’, ‘block’, ‘escalate’].
- caseSensitive: bool | None
Guardrail.spec.config.caseSensitive[bool]: whether the keyword strategy is case sensitive.
- categories: list[str] | None
Guardrail.spec.config.categories[list]: the moderation strategy’s categories.
Empty means all. Any of: [‘harassment’, ‘harassment/threatening’, ‘hate’, ‘hate/threatening’, ‘illicit’, ‘illicit/violent’, ‘self-harm’, ‘self-harm/intent’, ‘self-harm/instructions’, ‘sexual’, ‘sexual/minors’, ‘violence’, ‘violence/graphic’].
- category: str | None
Guardrail.spec.config.category[str]: the risk the guardrail addresses.
One of: [‘pii’, ‘secrets’, ‘prompt_injection’, ‘jailbreak’, ‘toxicity’, ‘self_harm’, ‘hallucination’, ‘off_topic’, ‘compliance’, ‘formatting’, ‘custom’].
- detectors: list[str] | None
Guardrail.spec.config.detectors[list]: the detector strategy’s detectors.
Any of: [‘credit_card’, ‘us_ssn’, ‘email’, ‘phone_number’, ‘ip_address’, ‘iban’, ‘aws_access_key’, ‘private_key’, ‘api_key’, ‘jwt’, ‘password_assignment’].
- failClosed: bool | None
Guardrail.spec.config.failClosed[bool]: if true, block when the check itself fails, e.g. because the LLM provider is unavailable.
If false, the failure is recorded, and the prompt continues.
- flags: list[str] | None
Guardrail.spec.config.flags[list]: the regex strategy’s flags.
Any of: [‘IGNORECASE’, ‘MULTILINE’, ‘DOTALL’].
- judgePrompt: str | None
Guardrail.spec.config.judgePrompt[str]: the llm_judge strategy’s prompt, with a {text} placeholder for the text to judge.
Any other braces must be doubled, e.g. {{ and }}.
- keywords: list[str] | None
Guardrail.spec.config.keywords[list]: the keyword strategy’s words and phrases.
- message: str | None
Guardrail.spec.config.message[str]: what block returns to the user, instead of the LLM’s reply.
- mode: str | None
Guardrail.spec.config.mode[str]: enforce, to take the action, or monitor, to only record what the action would have been.
- model: str | None
Guardrail.spec.config.model[str]: the model of the semantic, moderation and llm_judge strategies.
- priority: Optional
Guardrail.spec.config.priority[int]: the order in which guardrails run.
Lower runs first.
- provider: str | None
Guardrail.spec.config.provider[str]: the name of the Smarter LLM Provider that the semantic, moderation and llm_judge strategies call.
Defaults to openai.
- referenceTexts: list[str] | None
Guardrail.spec.config.referenceTexts[list]: the semantic strategy’s examples of what to detect.
- replacement: str | None
Guardrail.spec.config.replacement[str]: what redact and transform replace each match with.
Defaults to [REDACTED], which an empty replacement also means. {label} is replaced with what matched, e.g. credit_card. For the regex strategy, transform may refer to groups, e.g. .
- severity: Optional
Guardrail.spec.config.severity[int]: from 1 (low) to 5 (critical), for reporting and review.
- stage: str
Guardrail.spec.config.stage[str]: when the guardrail runs.
One of: [‘input’, ‘output’, ‘both’].
- strategy: str
Guardrail.spec.config.strategy[str]: how the guardrail detects.
One of: [‘regex’, ‘keyword’, ‘detector’, ‘semantic’, ‘moderation’, ‘llm_judge’].
- threshold: Optional
Guardrail.spec.config.threshold[float]: the minimum confidence, from 0 to 1, at which the semantic, moderation and llm_judge strategies trigger.
Defaults to 0.8.
- class smarter.models.sam.guardrail.SAMGuardrailStatus
Bases:
smarter.models.sam.base.SAMModelSmarter API Guardrail Manifest - Status class.
Read only. Besides ownership, it reports the guardrail’s events of the last 30 days. The LLMClients that use it are reported in
dependencies.- accountNumber: str
Guardrail.status.account_number: The account owner of this Guardrail.
Read only.
- blocked: int | None
Guardrail.status.blocked: how many prompts this Guardrail blocked in the last 30 days.
Read only.
- created: datetime
The date in which this resource was created.
Read only.
- dependencies: list[smarter.models.sam.guardrail.SAMDependency] | None
Dependencies[List]: The resources that depend on this resource, and that must be deleted, or stop referring to it, before it can be deleted.
Lists only the resources that you can read. Read only.
- errors: int | None
Guardrail.status.errors: how many times this Guardrail failed to run in the last 30 days.
Read only.
- lastTriggered: datetime.datetime | None
Guardrail.status.lastTriggered: when this Guardrail last triggered.
Read only.
- modified: datetime
The date in which this resource was most recently changed.
Read only.
- recordLocator: str
RecordLocator[String]: An optional identifier used to locate the resource record associated with this manifest.
Read only.
- class smarter.models.sam.guardrail.SAMGuardrailSpec
Bases:
smarter.models.sam.base.SAMModelSmarter API Guardrail Manifest Guardrail.spec.
- config: SAMGuardrailSpecConfig
Guardrail.spec.config[object].
The configuration for the Guardrail.
- class smarter.models.sam.guardrail.SAMGuardrail
Bases:
smarter.models.sam.base.SAMModelSmarter API Manifest - Guardrail.
- metadata: SAMGuardrailMetadata
Guardrail.metadata[obj]: Required, the Guardrail metadata.
- spec: SAMGuardrailSpec
Guardrail.spec[obj]: Required, the Guardrail specification.
- status: smarter.models.sam.guardrail.SAMGuardrailStatus | None
Guardrail.status[obj]: Optional, Read-only.
Stateful status information about the Guardrail.