Skip to content

fix(docs): remove HF_TOKEN dependency from RAG pipeline cell#5

Merged
hyunhee-jo merged 4 commits into
mainfrom
docs/fix-rag-cell-hf-token
Apr 13, 2026
Merged

fix(docs): remove HF_TOKEN dependency from RAG pipeline cell#5
hyunhee-jo merged 4 commits into
mainfrom
docs/fix-rag-cell-hf-token

Conversation

@hyunhee-jo
Copy link
Copy Markdown
Collaborator

@hyunhee-jo hyunhee-jo commented Apr 12, 2026

Objective

Running the demo notebook on Google Colab fails with
ValueError: You must provide an api_key to work with auto API
because the RAG pipeline cell requires a HuggingFace API token
that is not configured by default.

Approach

Replace the LLM query with a retriever-only demonstration — index
building and semantic search work without any API token. The LLM
query is kept as a commented-out option for users who have HF_TOKEN.
Also remove llama-index-llms-huggingface-api from the pip install
cell since it is no longer required.

Evidence

Ran the notebook on Google Colab before the fix:

Scenario Expected Actual
RAG cell without HF_TOKEN (before) Query result ValueError: You must provide an api_key
RAG cell without HF_TOKEN (after) Retrieved chunks displayed Pending Colab re-run after merge
Setup cell (after) Fewer dependencies installed llama-index-llms-huggingface-api removed

Summary by CodeRabbit

  • Documentation
    • Demo notebook now demonstrates retrieval-only workflows instead of running a live LLM query.
    • Removed the external LLM dependency and related setup steps from the example to simplify getting started.
    • Shows how to retrieve and inspect document chunks, including top-k relevance scores and metadata.
    • The previous full LLM query is retained as commented optional code for users who want to enable it.

Objective: RAG pipeline cell in the demo notebook fails on Colab with
ValueError because HuggingFaceInferenceAPI requires HF_TOKEN, which
is not configured by default.

Approach: Replace LLM query with retriever-only demonstration — index
building and semantic search work without any API token. LLM query
is kept as a commented-out option for users who have HF_TOKEN.
Also remove llama-index-llms-huggingface-api from pip install.

Evidence: Cannot verify locally (requires Colab runtime). The retriever
API (index.as_retriever().retrieve()) does not call any external LLM
service, so it cannot hit the same auth error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5158b0cc-7ca9-4765-8d72-c7b9de6d97c6

📥 Commits

Reviewing files that changed from the base of the PR and between fc99db4 and 24e552e.

📒 Files selected for processing (1)
  • docs/OpenDataLoaderPDFReaderDemo.ipynb

Walkthrough

The Jupyter notebook removes the HuggingFace LLM dependency/import and changes the RAG example from performing an LLM-backed query to a retrieval-only flow that prints retrieved chunk texts, per-node scores, and metadata; LLM query code remains commented out.

Changes

Cohort / File(s) Summary
Notebook RAG Example Update
docs/OpenDataLoaderPDFReaderDemo.ipynb
Removed llama-index-llms-huggingface-api pip install and HuggingFaceInferenceAPI import/HF token wiring. Replaced index.as_query_engine(llm=llm).query(...) usage with index.as_retriever(similarity_top_k=3).retrieve(...), printing top chunk texts (first 200 chars), per-node scores, and metadata. LLM-based query example retained only as commented optional code.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing HF_TOKEN dependency from the RAG pipeline cell by replacing LLM queries with retriever-only demonstration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Ruff (0.15.9)
docs/OpenDataLoaderPDFReaderDemo.ipynb

Unexpected end of JSON input


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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/OpenDataLoaderPDFReaderDemo.ipynb`:
- Line 52: The notebook's pip install line no longer includes the HuggingFace
LLM package but the optional LLM section still imports HuggingFaceInferenceAPI,
causing ImportError; restore the package in the install command by adding the
appropriate package (llama-index-llms-huggingface-api) to the pip install
string, or alternatively update the optional LLM block to import the currently
provided LLM class if the package name changed—specifically reconcile the
install line and the import for HuggingFaceInferenceAPI so the optional block
can be uncommented without error.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: df378cad-ec9f-432b-9d14-69a817ff6086

📥 Commits

Reviewing files that changed from the base of the PR and between 4aae3bc and 4519e77.

📒 Files selected for processing (1)
  • docs/OpenDataLoaderPDFReaderDemo.ipynb

Comment thread docs/OpenDataLoaderPDFReaderDemo.ipynb Outdated
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/OpenDataLoaderPDFReaderDemo.ipynb`:
- Around line 553-562: The Colab RAG example currently fetches the HF token via
os.getenv("HF_TOKEN") which fails in Colab; update the token retrieval used when
constructing HuggingFaceInferenceAPI so it first attempts
google.colab.userdata.get("HF_TOKEN") (if running in Colab) and falls back to
os.getenv("HF_TOKEN"); modify the llm instantiation (HuggingFaceInferenceAPI
token=...) to use this combined lookup so
index.as_query_engine(llm=llm).query(QUERY) can authenticate in both Colab and
non-Colab environments.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 287cf975-f2a0-40f8-9103-f52a43b70880

📥 Commits

Reviewing files that changed from the base of the PR and between 4519e77 and fc99db4.

📒 Files selected for processing (1)
  • docs/OpenDataLoaderPDFReaderDemo.ipynb

Comment thread docs/OpenDataLoaderPDFReaderDemo.ipynb
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hyunhee-jo hyunhee-jo merged commit 2687979 into main Apr 13, 2026
7 checks passed
@hyunhee-jo hyunhee-jo deleted the docs/fix-rag-cell-hf-token branch April 13, 2026 04:40
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

Successfully merging this pull request may close these issues.

1 participant