Django ORM

All models for the Guardrail app.

class smarter.apps.guardrail.models.Guardrail(*args, **kwargs)[source]

Bases: MetaDataWithOwnershipModel

Implements the Guardrail API model.

Parameters:
  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • name (Unknown) – Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

  • description (Unknown) – Description. A brief description of this resource. Be verbose, but not too verbose.

  • version (Unknown) – Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

  • annotations (Unknown) – Annotations. Key-value pairs for annotating this resource.

  • guardrail_type (Unknown) – Guardrail type

  • category (Unknown) – Category

  • match_strategy (Unknown) – Match strategy

  • pattern (Unknown) – Pattern. Regex, keyword list (newline/comma), or judge prompt template depending on match_strategy.

  • config (Unknown) – Config. Strategy-specific params: similarity_threshold, model_id, temperature, few-shot examples, etc.

  • action (Unknown) – Action

  • severity (Unknown) – Severity. 1=low … 5=critical; drives alerting/escalation thresholds.

  • confidence_threshold (Unknown) – Confidence threshold. Minimum confidence score to trigger action, for model/semantic strategies.

  • is_active (Unknown) – Is active

  • is_blocking (Unknown) – Is blocking. If False, action runs in shadow/log-only mode regardless of action.

  • priority (Unknown) – Priority. Execution order when multiple guardrails match; lower runs first.

  • fallback_message (Unknown) – Fallback message. User-facing message returned when action=BLOCK.

Relationship fields:

Parameters:
  • user_profile (Unknown) – User profile (related name: guardrail)

  • tags (Unknown) – Tags. Tags for categorizing and organizing this resource. (related name: guardrail)

  • tagged_items (Unknown) – Tagged items (related name: +)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

action

CharField

Action

Choices:

  • allow

  • flag

  • redact

  • transform

  • block

  • escalate

Type:

Type

annotations

JSONField

Annotations. Key-value pairs for annotating this resource.

Type:

Type

category

CharField

Category

Choices:

  • pii

  • jailbreak

  • toxicity

  • hallucination

  • off_topic

  • compliance

  • custom

Type:

Type

confidence_threshold

FloatField

Confidence threshold. Minimum confidence score to trigger action, for model/semantic strategies.

Type:

Type

config

JSONField

Config. Strategy-specific params: similarity_threshold, model_id, temperature, few-shot examples, etc.

Type:

Type

created_at

DateTimeField

Created at

Timestamp indicating when the model instance was created.

This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.

Type:

Type

description

TextField

Description. A brief description of this resource. Be verbose, but not too verbose.

Type:

Type

fallback_message

TextField

Fallback message. User-facing message returned when action=BLOCK.

Type:

Type

get_action_display(*, field=<django.db.models.CharField: action>)

Shows the label of the action. See get_FOO_display() for more information.

get_category_display(*, field=<django.db.models.CharField: category>)

Shows the label of the category. See get_FOO_display() for more information.

get_guardrail_type_display(*, field=<django.db.models.CharField: guardrail_type>)

Shows the label of the guardrail_type. See get_FOO_display() for more information.

get_match_strategy_display(*, field=<django.db.models.CharField: match_strategy>)

Shows the label of the match_strategy. See get_FOO_display() for more information.

guardrail_type

CharField

Guardrail type

Choices:

  • input

  • output

  • both

Type:

Type

id

BigAutoField

Primary key: ID

Type:

Type

is_active

BooleanField

Is active

Type:

Type

is_blocking

BooleanField

Is blocking. If False, action runs in shadow/log-only mode regardless of action.

Type:

Type

match_strategy

CharField

Match strategy

Choices:

  • regex

  • keyword

  • semantic

  • model

  • llm_judge

Type:

Type

name

CharField

Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

Type:

Type

pattern

TextField

Pattern. Regex, keyword list (newline/comma), or judge prompt template depending on match_strategy.

Type:

Type

priority

PositiveSmallIntegerField

Priority. Execution order when multiple guardrails match; lower runs first.

Type:

Type

severity

PositiveSmallIntegerField

Severity. 1=low … 5=critical; drives alerting/escalation thresholds.

Type:

Type

tagged_items

Reverse GenericRelation from Guardrail

All + of this tagged item (related name of tagged_items)

Type:

Type

tags = <taggit.managers._TaggableManager object>
updated_at

DateTimeField

Updated at

Timestamp indicating when the model instance was last updated.

This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.

Type:

Type

user_profile

ForeignKey to UserProfile

User profile (related name: guardrail)

Type:

Type

user_profile_id

Internal field, use user_profile instead.

version

CharField

Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

Type:

Type