fix(docs): remove HF_TOKEN dependency from RAG pipeline cell#5
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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.ipynbUnexpected 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
docs/OpenDataLoaderPDFReaderDemo.ipynb
…wn text Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
docs/OpenDataLoaderPDFReaderDemo.ipynb
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Objective
Running the demo notebook on Google Colab fails with
ValueError: You must provide an api_key to work with auto APIbecause 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-apifrom the pip installcell since it is no longer required.
Evidence
Ran the notebook on Google Colab before the fix:
ValueError: You must provide an api_keyllama-index-llms-huggingface-apiremovedSummary by CodeRabbit