Prerequisites: Setup optimodel here
Guardrails
Guardrails Setup
How to setup Guardrails with Lytix
Now you’re ready to start adding guardrails to your calls. Here is the general syntax:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
How to setup Guardrails with Lytix
from optimodel import queryModel
response = await queryModel(
....
messages=[
ModelMessage(
role="system",
content="You are a helpful assistant. Always respond in JSON syntax",
),
ModelMessage(role="user", content=prompt),
],
guards=[...] # Optional guards param
)
guards=[MicrosoftPresidioConfig(
guardName="MICROSOFT_PRESIDIO_GUARD",
guardType="preQuery",
entitiesToCheck=["EMAIL_ADDRESS"],
blockRequest=True, # Pass this to block the request
blockRequestMessage="You are not allowed to ask about this email address" # Pass this to give a custom message
)]
guards=[LLamaPromptGuardConfig(
guardName="LLamaPromptGuard",
jailbreakThreshold=0.9999,
guardType="preQuery", # You'll likely only want to guard the input here
)]
guards=[MicrosoftPresidioConfig(
guardName="MICROSOFT_PRESIDIO_GUARD",
guardType="preQuery",
entitiesToCheck=["EMAIL_ADDRESS"], # See the model card for the full list of entities to check
)]
guards=[LytixRegexConfig(
guardName="LYTIX_REGEX_GUARD",
regex="secrets",
guardType="preQuery",
)]