generated from guardrails-ai/validator-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
I am trying to run readme code of python after installing it like this
!guardrails hub install hub://tryolabs/restricttotopicthen run the code example
# Import Guard and Validator
from guardrails.hub import RestrictToTopic
from guardrails import Guard
# Setup Guard
guard = Guard().use(
RestrictToTopic(
valid_topics=["sports"],
invalid_topics=["music"],
disable_classifier=True,
disable_llm=False,
on_fail="exception"
)
)
guard.validate("""
In Super Bowl LVII in 2023, the Chiefs clashed with the Philadelphia Eagles in a fiercely contested battle, ultimately emerging victorious with a score of 38-35.
""") # Validator passes
guard.validate("""
The Beatles were a charismatic English pop-rock band of the 1960s.
""") # Validator failsI am getting below error
ImportError: cannot import name 'RestrictToTopic' from 'guardrails.hub' (/usr/local/lib/python3.10/dist-packages/guardrails/hub/__init__.py)
Metadata
Metadata
Assignees
Labels
No labels