Skip to content

Bug/add hf token#107

Merged
nishika26 merged 4 commits intomainfrom
bug/add_hf_token
May 7, 2026
Merged

Bug/add hf token#107
nishika26 merged 4 commits intomainfrom
bug/add_hf_token

Conversation

@nishika26
Copy link
Copy Markdown
Contributor

@nishika26 nishika26 commented May 7, 2026

Summary

Target issue is #108

Notes

Summary by CodeRabbit

  • Chores
    • Added Hugging Face authentication token configuration
    • Optimized container startup by pre-downloading models during build
    • Enabled pre-installation of Guardrails Hub validators in Docker

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Warning

Rate limit exceeded

@nishika26 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 55 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 87599fbd-06fc-4ebf-b6b2-21503f13e9ec

📥 Commits

Reviewing files that changed from the base of the PR and between 3e5be97 and a55d939.

📒 Files selected for processing (3)
  • .env.example
  • backend/Dockerfile
  • docker-compose.yml
📝 Walkthrough

Walkthrough

This PR adds Hugging Face token support and Guardrails Hub API key forwarding to the Docker build pipeline. The .env.example template defines the HF_TOKEN placeholder, the backend/Dockerfile declares these as build arguments, pre-downloads a toxicity-classifier model, and pre-installs Guardrails validators, while docker-compose.yml routes environment variables as build arguments to both services.

Changes

HF Token and Guardrails Pre-configuration

Layer / File(s) Summary
Environment Configuration
.env.example
HF_TOKEN placeholder is added for Hugging Face authentication.
Dockerfile Build Configuration
backend/Dockerfile
HuggingFace cache directory HF_HOME=/app/hf_cache is set; build arguments HF_TOKEN and GUARDRAILS_HUB_API_KEY are declared; a RUN step pre-downloads the textdetox/xlmr-large-toxicity-classifier model; a second RUN step pre-installs Guardrails Hub validators via install_guardrails_from_hub.sh with ENABLE_METRICS=false and ENABLE_REMOTE_INFERENCING=true.
Compose Build Arguments
docker-compose.yml
build.args forwarding HF_TOKEN and GUARDRAILS_HUB_API_KEY are added to both the prestart and backend service configurations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 HuggingFace tokens hop along,
Pre-download guards our startup song,
No more delays when containers wake,
Guardrails validators bake, bake, bake! 🎂

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Bug/add hf token' is vague and uses non-descriptive terms. It lacks clarity about what is being added or fixed, using abbreviations without context. Provide a more descriptive title that clearly explains the purpose, such as 'Add HuggingFace token support to Docker builds and environment configuration' or 'Configure HuggingFace authentication for model pre-downloads in Docker'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bug/add_hf_token

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.env.example:
- Line 26: Remove the stray space after the equals sign in the HF_TOKEN
environment variable declaration in .env.example so the token value doesn't
include a leading space; update the HF_TOKEN line (the entry named HF_TOKEN) to
have no space between '=' and the quoted placeholder so dotenv parsers will read
the token correctly.

In `@backend/Dockerfile`:
- Around line 54-65: The Dockerfile currently uses ARG HF_TOKEN and ARG
GUARDRAILS_HUB_API_KEY and interpolates them into RUN commands (the two RUN
blocks that call python to preload transformers and
/app/scripts/install_guardrails_from_hub.sh); replace those ARG-based secrets
with BuildKit secret mounts by changing the RUN lines to use
--mount=type=secret,id=HF_TOKEN (and id=GUARDRAILS_HUB_API_KEY) so the tokens
are read from the secret files during the RUN and not baked into layers, and
update your docker-compose build configuration to declare these secrets at the
top level and reference them under each service’s build:secrets so the secrets
are provided to the build with no args: exposure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 01c5d084-1465-455c-ac2e-1dfe19266c5d

📥 Commits

Reviewing files that changed from the base of the PR and between b519e43 and 3e5be97.

📒 Files selected for processing (3)
  • .env.example
  • backend/Dockerfile
  • docker-compose.yml

Comment thread .env.example Outdated
Comment thread backend/Dockerfile Outdated
@nishika26 nishika26 requested a review from Ayush8923 May 7, 2026 13:25
@nishika26 nishika26 self-assigned this May 7, 2026
@nishika26 nishika26 added bug Something isn't working ready-for-review labels May 7, 2026
@nishika26 nishika26 merged commit 3395096 into main May 7, 2026
2 checks passed
@nishika26 nishika26 deleted the bug/add_hf_token branch May 7, 2026 13:31
@nishika26 nishika26 linked an issue May 11, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload Process: Speed up model uploads

2 participants