SAMGuardrail
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(*, kind: str, name: str, **extra_data: Any)[source]
Bases:
SAMModelA resource that depends on the resource that a manifest describes.
- kind: str
Kind[String]: The SAM kind of the resource that depends on this resource, e.g. LLMClient.
Read only.
- model_config = {'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'regex_engine': 'python-re', 'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
- class smarter.models.sam.guardrail.SAMGuardrailMetadata(*, annotations: None | list[dict[str, str | int | float | bool | date | datetime | UUID | bytes | list | dict[str, Any]]] = None, description: str | None, name: str, tags: list[str] | None = None, version: str | None, **extra_data: Any)[source]
Bases:
SAMModelSmarter API Guardrail Manifest - Metadata class.
- annotations: None | list[dict[str, str | int | float | bool | date | datetime | 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.
- tags: list[str] | None
The tags of the manifest.
Used for generic resource categorization and search. Example: [‘tag1’, ‘tag2’]
- model_config = {'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'regex_engine': 'python-re', 'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
- class smarter.models.sam.guardrail.Action(*values)[source]
Bases:
EnumGuardrail.spec.config.action[str]: what the guardrail does when it triggers.
One of: [‘log’, ‘flag’, ‘redact’, ‘transform’, ‘block’, ‘escalate’].
- class smarter.models.sam.guardrail.Category(*values)[source]
Bases:
EnumGuardrail.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’].
- class smarter.models.sam.guardrail.Mode(*values)[source]
Bases:
EnumGuardrail.spec.config.mode[str]: enforce, to take the action, or monitor, to only record what the action would have been.
- class smarter.models.sam.guardrail.Stage(*values)[source]
Bases:
EnumGuardrail.spec.config.stage[str]: when the guardrail runs.
One of: [‘input’, ‘output’, ‘both’].
- class smarter.models.sam.guardrail.Strategy(*values)[source]
Bases:
EnumGuardrail.spec.config.strategy[str]: how the guardrail detects.
One of: [‘regex’, ‘keyword’, ‘detector’, ‘semantic’, ‘moderation’, ‘llm_judge’].
- class smarter.models.sam.guardrail.SAMGuardrailSpecConfig(*, action: Action, caseSensitive: bool | None = False, categories: list[str] | None = None, category: Category | None = 'custom', detectors: list[str] | None = None, failClosed: bool | None = False, flags: list[str] | None = None, isActive: bool | None = True, judgePrompt: str | None = None, keywords: list[str] | None = None, message: str | None = None, mode: Mode | None = 'enforce', model: str | None = None, pattern: str | None = None, priority: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = 100, provider: str | None = None, referenceTexts: list[str] | None = None, replacement: str | None = None, severity: Annotated[int, None, Interval(gt=None, ge=1, lt=None, le=5), None] | None = 3, stage: Stage, strategy: Strategy, threshold: Annotated[float, None, Interval(gt=None, ge=0.0, lt=None, le=1.0), None, None] | None = None, wholeWord: bool | None = True, **extra_data: Any)[source]
Bases:
SAMModelSmarter API Guardrail Manifest Guardrail.spec.config.
- action: Action
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: Category | 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: Mode | 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: conint(ge=0) | None
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.
- model_config = {'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'regex_engine': 'python-re', 'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
- 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: conint(ge=1, le=5) | None
Guardrail.spec.config.severity[int]: from 1 (low) to 5 (critical), for reporting and review.
- stage: Stage
Guardrail.spec.config.stage[str]: when the guardrail runs.
One of: [‘input’, ‘output’, ‘both’].
- strategy: Strategy
Guardrail.spec.config.strategy[str]: how the guardrail detects.
One of: [‘regex’, ‘keyword’, ‘detector’, ‘semantic’, ‘moderation’, ‘llm_judge’].
- class smarter.models.sam.guardrail.SAMGuardrailStatus(*, accountNumber: str, blocked: int | None = None, created: datetime, dependencies: list[SAMDependency] | None = None, errors: int | None = None, lastTriggered: datetime | None = None, modified: datetime, recordLocator: str, triggered: int | None = None, username: str, **extra_data: Any)[source]
Bases:
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.- model_config = {'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'regex_engine': 'python-re', 'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
- 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[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 | 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(*, config: SAMGuardrailSpecConfig, **extra_data: Any)[source]
Bases:
SAMModelSmarter API Guardrail Manifest Guardrail.spec.
- model_config = {'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'regex_engine': 'python-re', 'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
- config: SAMGuardrailSpecConfig
Guardrail.spec.config[object].
The configuration for the Guardrail.
- class smarter.models.sam.guardrail.SAMGuardrail(*, apiVersion: str, kind: str, metadata: SAMGuardrailMetadata, spec: SAMGuardrailSpec, status: SAMGuardrailStatus | None = None, **extra_data: Any)[source]
Bases:
SAMModelSmarter API Manifest - Guardrail.
- model_config = {'extra': 'allow', 'populate_by_name': True, 'protected_namespaces': (), 'regex_engine': 'python-re', 'use_attribute_docstrings': True}
Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].
- metadata: SAMGuardrailMetadata
Guardrail.metadata[obj]: Required, the Guardrail metadata.
- spec: SAMGuardrailSpec
Guardrail.spec[obj]: Required, the Guardrail specification.
- status: SAMGuardrailStatus | None
Guardrail.status[obj]: Optional, Read-only.
Stateful status information about the Guardrail.