guardrails icon indicating copy to clipboard operation
guardrails copied to clipboard

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

Open musharaf-intellixcore opened this issue 1 year ago • 5 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)

musharaf-intellixcore avatar Mar 25 '24 08:03 musharaf-intellixcore

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

zsimjee avatar Mar 25 '24 12:03 zsimjee

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

musharaf-intellixcore avatar Mar 26 '24 06:03 musharaf-intellixcore

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)

CalebCourier avatar Mar 26 '24 13:03 CalebCourier

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.

musharaf-intellixcore avatar Mar 26 '24 14:03 musharaf-intellixcore

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

april980123 avatar May 06 '24 17:05 april980123

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Aug 22 '24 03:08 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Sep 05 '24 03:09 github-actions[bot]