Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import error #24

Open
fraz-prod opened this issue Jan 7, 2025 · 0 comments
Open

import error #24

fraz-prod opened this issue Jan 7, 2025 · 0 comments

Comments

@fraz-prod
Copy link

I am trying to run readme code of python after installing it like this

!guardrails hub install hub://tryolabs/restricttotopic

then 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 fails

I am getting below error

 ImportError: cannot import name 'RestrictToTopic' from 'guardrails.hub' (/usr/local/lib/python3.10/dist-packages/guardrails/hub/__init__.py)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant