refactor(deps): demote LangChain and LangChain-providers from core to dev - #1806
Conversation
Greptile SummaryThis PR demotes
|
| Filename | Overview |
|---|---|
| nemoguardrails/imports.py | Corrected OPTIONAL_DEPENDENCIES: langchain_openai → None, langchain_nvidia_ai_endpoints → None, and openai → "server"; resolves stale extra references from previous review |
| pyproject.toml | Removes langchain*, langchain-openai, langchain-nvidia-ai-endpoints from core deps; drops openai and nvidia extras; adds all five LangChain packages to dev group; server extra correctly retains openai SDK |
| docs/getting-started/installation-guide.md | Removes references to dropped nvidia and openai extras from quick-start commands and the extras table; aligns documentation with new dependency layout |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["pip install nemoguardrails"] --> B["Core only: httpx, jinja2, lark, etc."]
A --> C{"Need extras?"}
C -->|server| D["pip install nemoguardrails server extra + openai SDK"]
C -->|LangChain integration| E["pip install langchain langchain-core langchain-community langchain-openai"]
C -->|NIM embeddings| F["pip install langchain-nvidia-ai-endpoints"]
C -->|eval / sdd / tracing| G["pip install nemoguardrails with eval/sdd/tracing extras"]
B --> H["DefaultFramework httpx-based chat"]
D --> I["nemoguardrails server"]
E --> J["NEMOGUARDRAILS_LLM_FRAMEWORK=langchain"]
Reviews (7): Last reviewed commit: "docs: drop langchain-nvidia install hint..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
09d369f to
35ad699
Compare
d3de475 to
d7c5d3e
Compare
35ad699 to
67903cd
Compare
67903cd to
a82c5e9
Compare
📝 WalkthroughWalkthroughLangChain-related packages ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 `@pyproject.toml`:
- Around line 157-163: Tighten the provider package constraints in
pyproject.toml so they remain compatible with langchain==0.2.14 and
langchain-core <0.3.0: update the langchain-openai requirement to add an upper
bound (e.g., restrict to <0.2.0) and add an upper bound to
langchain-nvidia-ai-endpoints (e.g., restrict to <1.0.0) so they cannot pull
newer major versions that require langchain-core >=0.3.x or >=1.x; adjust the
version strings for the langchain-openai and langchain-nvidia-ai-endpoints
entries accordingly while keeping the existing langchain and langchain-core
constraints.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: dd993b57-4e8a-4ede-b212-bde52a82758b
⛔ Files ignored due to path filters (1)
poetry.lockis excluded by!**/*.lock
📒 Files selected for processing (1)
pyproject.toml
tgasser-nv
left a comment
There was a problem hiding this comment.
Looks good! Just a few comments to address before merging:
- Docs updates:
a) CONTRIBUTING.md tries to install theopenaiextra which is now gone.
b) The Getting Started guide installs the nvidia extra to use NVCF in the examples. - The migration note is unchecked in the description.
- Greptile pointed out the
OPTIONAL_DEPENDENCIESin imports.py needs updating. - Are there any CI workflows which use these extras?
|
Thanks @tgasser-nv ! I addressed your comments, only keeping CONTRIBUTING-GUIDE.md for a follow-up PR as docs need more changes given this decoupling. |
… dev Now that DefaultFramework handles OpenAI-compatible chat via httpx, LangChain is no longer needed for basic operation. Moving it out of core slims the mandatory install substantially and makes the LangChain integration genuinely opt-in. Core dependencies (removed): - langchain, langchain-core, langchain-community: only imported lazily inside nemoguardrails/integrations/langchain/ and in conditional paths in llm/frameworks.py and rails/llm/llmrails.py (raw-LangChain- LLM path). - langchain-openai: not imported anywhere in src; only referenced by test skipif guards. - langchain-nvidia-ai-endpoints: imported conditionally in embeddings/providers/nim.py (NIM embeddings) and in LangChain-NIM adapter. Users who need these paths install the package directly. Extras (removed): - openai (was -> langchain-openai): obsolete, DefaultFramework uses httpx directly. - nvidia (was -> langchain-nvidia-ai-endpoints): obsolete for chat; NIM embeddings users should install langchain-nvidia-ai-endpoints directly. Extras (kept and adjusted): - server: still includes openai because server/schemas and server/api import openai.types.chat at module scope (server won't start without the openai SDK). - all: updated to drop the removed extras. Dev group additions: - langchain, langchain-core, langchain-community: needed by the LangChain integration tests under tests/integrations/langchain/. - langchain-openai, langchain-nvidia-ai-endpoints: skip-guarded by tests today; installed in dev so those guards activate. Runtime behavior unchanged: code that used these packages always imported them lazily or conditionally. Users on NEMOGUARDRAILS_LLM_FRAMEWORK=langchain now need to install langchain-* themselves; an upgrade note in the migration guide is appropriate (follow-up).
d327c88 to
0a3b096
Compare
Description
Now that DefaultFramework handles OpenAI-compatible chat via httpx, LangChain is no longer needed for basic operation. Moving it out of core slims the mandatory install substantially and makes the LangChain integration genuinely opt-in.
Core dependencies (removed):
Extras (removed):
Extras (kept and adjusted):
Dev group additions:
Runtime behavior unchanged: code that used these packages always imported them lazily or conditionally. Users on
NEMOGUARDRAILS_LLM_FRAMEWORK=langchain now need to install langchain-* themselves; an upgrade note in the migration guide is appropriate (follow-up).
TODO
Related Issue(s)
#1580
Checklist
Summary by CodeRabbit