guardrails-ai / guardrails

Adding guardrails to large language models.

Home Page:https://www.guardrailsai.com/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import Error - Cannot import name 'SensitiveTopic' from 'guardrails.hub'

musharaf-intellixcore opened this issue · comments

I installed Guardrails version 0.4.2 and configured it with a token. Next, I attempted to install the Sensitive Topics Guard using the following command:
guardrails hub install hub://guardrails/sensitive_topics

Although the installation of the Sensitive Topics Guard was successful, when I tried to import SensitiveTopic from Guardrails Hub using the command:
from guardrails.hub import SensitiveTopic

I encountered the following error:
Cannot import name 'SensitiveTopic' from 'guardrails.hub' (/usr/local/lib/python3.10/dist-packages/guardrails/hub/init.py)

Library version:
Version (0.4.2)

can you please paste the contents of the file located at /usr/local/lib/python3.10/dist-packages/guardrails/hub/init.py?

Here is the contents of the required file.

""" Should contain imports for all validators """
""" Will be auto-populated by the installation script """

from guardrails.hub.tryolabs.restricttotopic.validator import RestrictToTopic
from guardrails.hub.guardrails.sensitive_topics.validator import SensitiveTopic
from guardrails.hub.guardrails.secrets_present.validator import SecretsPresent

I am unable to reproduce this issue when following the standard installation procedure.

@musharaf-intellixcore could you please provide some additional information such as:

  1. The logs from the guardrails hub install command
  2. The stack trace of the error you're encountering
  3. The location of the guardrails installation: (which guardrails on mac and linux, where guardrails on windows)

I'm working on the Linux operating system, installing three validators: Detect_PII, sensitive_topics, and secrets. After installing all three validators, when I tried to import Detect PII, it worked fine. However, when I attempted to import SensitiveTopic from the Guardrails Hub, an error was thrown, as mentioned above.

I think there's some error in the documentation.

It's supposed to be guardrails hub install hub://guardrails/regex_match not gudardrails hub install hub://guardrails/regex_match.

Once this is fixed, you should be able to import any guardrail from the hub