Skip to content

Commit 67903cd

Browse files
committed
refactor(deps): demote LangChain and LangChain-providers from core to 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).
1 parent fe06537 commit 67903cd

2 files changed

Lines changed: 16 additions & 22 deletions

File tree

poetry.lock

Lines changed: 7 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ onnxruntime = [
5858
]
5959
httpx = ">=0.24.1"
6060
jinja2 = ">=3.1.6"
61-
langchain = ">=0.2.14,<2.0.0"
62-
langchain-core = ">=0.2.14,<2.0.0"
63-
langchain-community = ">=0.2.5,<2.0.0"
6461
lark = ">=1.1.7"
6562
nest-asyncio = ">=1.5.6,"
6663
# NOTE:
@@ -77,15 +74,14 @@ starlette = ">=0.49.1"
7774
typer = ">=0.8"
7875
uvicorn = ">=0.23"
7976
watchdog = ">=3.0.0,"
77+
78+
# server (openai SDK types used by server/schemas and server/api)
8079
openai = { version = ">=1.0.0,<3.0.0", optional = true }
8180

8281
# tracing
8382
opentelemetry-api = { version = ">=1.27.0,<2.0.0", optional = true }
8483
aiofiles = { version = ">=24.1.0", optional = true }
8584

86-
# openai
87-
langchain-openai = { version = ">=0.1.0", optional = true }
88-
8985
# eval
9086
tqdm = { version = ">=4.65,<5.0", optional = true }
9187
streamlit = { version = "^1.37.0", optional = true, python = ">=3.10,<3.14" }
@@ -103,9 +99,6 @@ numpy = [
10399
presidio-analyzer = { version = ">=2.2", optional = true, python = "<3.13" }
104100
presidio-anonymizer = { version = ">=2.2", optional = true, python = "<3.13" }
105101

106-
# nim
107-
langchain-nvidia-ai-endpoints = { version = ">= 0.2.0", optional = true }
108-
109102
# gpc
110103
google-cloud-language = { version = ">=2.14.0", optional = true }
111104

@@ -118,10 +111,8 @@ fast-langdetect = { version = ">=1.0.0", optional = true }
118111
[tool.poetry.extras]
119112
sdd = ["presidio-analyzer", "presidio-anonymizer"]
120113
eval = ["tqdm", "numpy", "streamlit", "tornado"]
121-
openai = ["langchain-openai"]
122114
gcp = ["google-cloud-language"]
123115
tracing = ["opentelemetry-api", "aiofiles"]
124-
nvidia = ["langchain-nvidia-ai-endpoints"]
125116
jailbreak = ["yara-python"]
126117
multilingual = ["fast-langdetect"]
127118
server = ["aiofiles", "openai"]
@@ -134,12 +125,10 @@ all = [
134125
"tqdm",
135126
"numpy",
136127
"streamlit",
137-
"langchain-openai",
138128
"openai",
139129
"google-cloud-language",
140130
"opentelemetry-api",
141131
"aiofiles",
142-
"langchain-nvidia-ai-endpoints",
143132
"yara-python",
144133
"fast-langdetect",
145134
]
@@ -165,6 +154,13 @@ fast-langdetect = ">=1.0.0"
165154
openai = ">=1.0.0,<3.0.0"
166155
pyright = "^1.1.405"
167156
ruff = "0.14.6"
157+
# LangChain integration is now opt-in at runtime (DefaultFramework replaces it for chat).
158+
# These dev deps keep the LangChain-specific tests and the NIM embeddings test path working.
159+
langchain = ">=0.2.14,<2.0.0"
160+
langchain-core = ">=0.2.14,<2.0.0"
161+
langchain-community = ">=0.2.5,<2.0.0"
162+
langchain-openai = ">=0.1.0"
163+
langchain-nvidia-ai-endpoints = ">=0.2.0"
168164

169165
# Directories in which to run Pyright type-checking
170166
[tool.pyright]

0 commit comments

Comments
 (0)