guardrails-ai / guardrails

Adding guardrails to large language models.
https://www.guardrailsai.com/docs
Apache License 2.0
4k stars 304 forks source link

[bug]401 Unauthorized when installing the Toxic Language validator #1087

Closed listeven975 closed 4 weeks ago

listeven975 commented 4 weeks ago

Describe the bug The Toxic Language validator cannot be downloaded without specifying an API key even if we're intending to running it locally only. However, other validators (Secrets Present and Web Sanitization) can be installed correctly. Please find below logs detailing the failure.

#15 [guardrails 10/10] RUN /usr/local/bin/install_validators.sh
#15 0.703 [nltk_data] Downloading package punkt to /root/nltk_data...
#15 1.869 [nltk_data]   Unzipping tokenizers/punkt.zip.
#15 2.700 Installing hub://guardrails/toxic_language...
#15 3.059 ERROR:guardrails-cli:401
#15 3.059 ERROR:guardrails-cli:Unauthorized
#15 3.059 ERROR:guardrails-cli:Your token is invalid. Please run `guardrails configure`to update your token.
#15 3.059 You can find a new token at https://hub.guardrailsai.com/keys
#15 3.060 ERROR:guardrails-cli:
#15 4.164 Installing hub://guardrails/secrets_present...
#15 4.208 Installing hub://guardrails/web_sanitization...
#15 4.660   Running command git clone --filter=blob:none --quiet https://github.com/guardrails-ai/web_sanitization.git /tmp/pip-req-build-4e5mzu8m
#15 4.788   Running command git clone --filter=blob:none --quiet https://github.com/guardrails-ai/secrets_present.git /tmp/pip-req-build-9xd07l8o
#15 7.056 WARNING: typer 0.12.5 does not provide the extra 'all'
#15 7.096 WARNING: typer 0.12.5 does not provide the extra 'all'
#15 7.695 ✅Successfully installed guardrails/secrets_present!
#15 7.695 
#15 7.695 
#15 7.696 Import validator:
#15 7.696 from guardrails.hub import SecretsPresent
#15 7.696 
#15 7.696 Get more info:
#15 7.696 https://hub.guardrailsai.com/validator/guardrails/secrets_present
#15 7.696 
#15 7.811 ✅Successfully installed guardrails/web_sanitization!
#15 7.811 
#15 7.811 
#15 7.811 Import validator:
#15 7.811 from guardrails.hub import WebSanitization
#15 7.811 
#15 7.811 Get more info:
#15 7.811 https://hub.guardrailsai.com/validator/guardrails/web_sanitization
#15 7.811 
#15 7.960 All guardrails have been successfully installed.

Here's what we're running within a docker step

#!/bin/bash

# Run commands in parallel and capture their PIDs
guardrails hub install hub://guardrails/toxic_language --install-local-models
guardrails hub install hub://guardrails/secrets_present &
pids[0]=$!
guardrails hub install hub://guardrails/web_sanitization &
pids[1]=$!

# Wait for all background processes to complete
for pid in ${pids[*]}; do
    if ! wait $pid; then
        echo "One or more guardrail installations failed."
        exit 1
    fi
done

echo "All guardrails have been successfully installed."

To Reproduce Run guardrails hub install hub://guardrails/toxic_language or guardrails hub install hub://guardrails/toxic_language --install-local-models without an API key set.

Expected behavior We should be able to run guardrails hub install hub://guardrails/toxic_language without running into a 401 Unauthorized error. Instead, the error should show up if and only if we attempt to do remote inference without an API key.

Library version: Tested on:

michael-long88 commented 4 weeks ago

I'm also receiving the same error for the Restrict to Topic validator on 0.5.10. I thought it was an issue with docker at first, but it's happening if I just run it locally as well.

JosephCatrambone commented 4 weeks ago

There's a message on the Discord bulletin board. I didn't see it on the site, but I feel like it should be copied or moved there. https://discord.com/channels/1085077079697150023/1263201695228493875/1285686929442213899

Zayd — 09/17/2024 12:40 PM ✏️ Update 📄

To provide better user experience and support, we’re rolling out mandatory authentication for installing validators from the guardrails hub.

This has already been rolled out to the ProfanityFree validator, and will be rolled out to the rest by the end of the month.

What you need to change: Authenticating into guardrails is done by getting a free key from https://guardrailsai.com/keys. If you’ve logged in to the guardrails hub via your terminal, you’re good to go! If you have not logged in before, run guardrails configure

For CI/CD workflows, please use a headless login on the same command after getting a key from https://hub.guardrailsai.com/keys. guardrails configure token [YOUR_TOKEN] Why is auth now required? With our new inference endpoints, some of our most popular validators run more quickly and reliably. These inference endpoints require authentication and we think it is a better user experience to require off initially so that these work by default. We want to better understand our users and how validators are being used together. Requiring validators, and failure/success rates. We still do not collect or log payloads, and there is a way to turn off client-side telemetry through the same configure command. We only collect non-anonymized data regarding validation installations and requests to inference endpoints. We’ve also had feature requests for private validators and team-scoped guards, and bringing auth in helps prepare for those features.

If you have any questions, please let us know!

maryam123errami commented 1 week ago

I'm also receiving the same error for the Restrict to Topic validator on 0.5.10. I thought it was an issue with docker at first, but it's happening if I just run it locally as well.

hello I have the same erreur how are you resove this please