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
Create Guardrail
from superwise_api.models.application.application import ApplicationAllowedTopicsGuard
from superwise_api.models.application.application import OpenAIModel
allowed_topics_guard = ApplicationAllowedTopicsGuard(
name="Restricted topics guardrail",
tag= "input",
topics=["technology", "science", "education"],
model=OpenAIModel(version="gpt-4o", api_token="REPLACE")
)
)
Add guards to application
app = sw.application.put(
str(app.id),
additional_config=AdvancedAgentConfig(tools=[]),
llm_model=model,
prompt=None,
name="App name",
show_cites = True,
guards=[ApplicationAllowedTopicsGuard]
)
Updated 3 months ago