Allowed topics
The Allowed topics guardrail can be applied to both user messages (Input) and the model's responses (Output).
- Allowed topics (Input): Ensures user messages remain centered around approved topics, focusing on relevant discussions.
- Allowed topics (Output): Guarantees that responses provided to users are strictly based on allowed topics, ensuring relevant and appropriate
Example:
In the following example, we've set the allowed topic to be "Food":
Configuration:
Parameters required to set up a Allowed topics guardrail:
- List of Topics: Specify the topics to focus the discussion on.
- OpenAI-Compatible Model: An OpenAI-compatible model is used to enforce the allowed topics test.
Using the UI
Using the SDK
from superwise_api.models.agent.agent import AgentAllowedTopicsGuard
from superwise_api.models.agent.agent import OpenAIModel
restricted_topics_guard = AgentAllowedTopicsGuard(
name="Rule name",
tags={"input", "output"}, # A Set containing "input", "output", or both
topics=["technology", "science", "education"],
model=OpenAIModel(version="gpt-4o", api_token="REPLACE")
)Updated 5 days ago