HomeGuidesAPI ReferenceRelease notes
Log In
Guides

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.application.application import ApplicationRestrictedTopicsGuard
from superwise_api.models.application.application import OpenAIModel

restricted_topics_guard = ApplicationRestrictedTopicsGuard(
    name="Rule name",
    tag= "input",
    topics=["politics", "religion", "adult_content"],
    model=OpenAIModel(version="gpt-4o", api_token="REPLACE")
)