LLMClientGuardrails Model

class smarter.apps.llmclient.models.LLMClientGuardrails(*args, **kwargs)[source]

Bases: TimestampedModel

The Guardrails that protect a LLMClient’s prompts.

Each record links an LLMClient to a Guardrail, as listed in the LLMClient manifest’s spec.guardrails. On each prompt, the linked, active guardrails run on the user’s message and the LLM’s reply, in order of their priority.

Usage Example

LLMClientGuardrails.objects.create(llmclient=my_llmclient, guardrail=my_guardrail)
guardrails = LLMClientGuardrails.guardrails_for(my_llmclient)
Parameters:
  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

Relationship fields:

Parameters:
  • llmclient (Unknown) –

    Llmclient (related name: llmclientguardrails)

    The LLMClient that the guardrail protects.

  • guardrail (Unknown) – Guardrail. The Guardrail. (related name: llmclient_guardrails)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

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

guardrail

ForeignKey to Guardrail

Guardrail. The Guardrail. (related name: llmclient_guardrails)

Type:

Type

guardrail_id

Internal field, use guardrail instead.

classmethod guardrails_for(llmclient)[source]

Return the active Guardrails of a LLMClient, in order of priority and then id.

Parameters:

llmclient (LLMClient) – The LLMClient.

Returns:

The LLMClient’s active guardrails.

Return type:

list[Guardrail]

id

BigAutoField

Primary key: ID

Type:

Type

llmclient

ForeignKey to LLMClient

Llmclient (related name: llmclientguardrails)

The LLMClient that the guardrail protects.

Type:

Type

llmclient_id

Internal field, use llmclient instead.

objects = <django.db.models.Manager 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