Restricted topics
The Restricted topics guardrail can be applied to both user messages (Input) and the model's responses (Output).
- Restricted topics (Input) - Identifies and filters out user messages that contain restricted topics, preventing the model from engaging in those discussions.
- Restricted topics (Output) - Ensures that any model-generated response does not include prohibited topics, keeping interactions appropriate and within guidelines
Example:
In the following example, we've set the restricted topic to be "UFOs":
Configuration:
Parameters required to set up a Restricted topics guardrail:
- List of Topics: Specify the topics you want to restrict from discussions.
- OpenAI-Compatible Model: An OpenAI-compatible model is used to enforce the restricted topics test.
Using the UI
Using the SDK
from superwise_api.models.agent.agent import AgentRestrictedTopicsGuard
from superwise_api.models.agent.agent import OpenAIModel
restricted_topics_guard = AgentRestrictedTopicsGuard(
name="Rule name",
tags={"input", "output"}, # A Set containing "input", "output", or both
topics=["politics", "religion", "adult_content"],
model=OpenAIModel(version="gpt-4o", api_token="REPLACE")
)Updated 5 days ago