Skip to content

Commit a90ef1b

Browse files
Pouyanpimiyoungccursoragent
authored
docs: documentation for langchain decoupling (#1854)
Co-authored-by: Miyoung Choi <miyoungc@nvidia.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 137b425 commit a90ef1b

9 files changed

Lines changed: 714 additions & 119 deletions

File tree

docs/_static/css/custom.css

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,93 @@
2727
.sd-equal-height .sd-card-body {
2828
flex: 1;
2929
}
30+
31+
.table-expand-button {
32+
align-items: center;
33+
background: #76b900;
34+
border: 0;
35+
border-radius: 4px;
36+
color: #fff;
37+
cursor: pointer;
38+
display: inline-flex;
39+
font-weight: 600;
40+
gap: 0.4rem;
41+
margin: 0.25rem 0 0.75rem;
42+
padding: 0.45rem 0.75rem;
43+
}
44+
45+
.table-expand-button:hover,
46+
.table-expand-button:focus {
47+
background: #5f9500;
48+
}
49+
50+
.table-expand-button:focus {
51+
outline: 2px solid #1a1a1a;
52+
outline-offset: 2px;
53+
}
54+
55+
.table-expander-modal {
56+
background: rgba(0, 0, 0, 0.65);
57+
display: none;
58+
inset: 0;
59+
padding: 2rem;
60+
position: fixed;
61+
z-index: 10000;
62+
}
63+
64+
.table-expander-modal.is-open {
65+
display: flex;
66+
}
67+
68+
.table-expander-modal__dialog {
69+
background: #fff;
70+
border-radius: 6px;
71+
box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.35);
72+
display: flex;
73+
flex-direction: column;
74+
max-height: 90vh;
75+
width: min(1200px, 96vw);
76+
}
77+
78+
.table-expander-modal__header {
79+
align-items: center;
80+
border-bottom: 1px solid #d9d9d9;
81+
display: flex;
82+
justify-content: space-between;
83+
padding: 1rem 1.25rem;
84+
}
85+
86+
.table-expander-modal__title {
87+
font-size: 1.2rem;
88+
font-weight: 700;
89+
margin: 0;
90+
}
91+
92+
.table-expander-modal__close {
93+
background: transparent;
94+
border: 0;
95+
cursor: pointer;
96+
font-size: 1.8rem;
97+
line-height: 1;
98+
padding: 0.1rem 0.35rem;
99+
}
100+
101+
.table-expander-modal__body {
102+
overflow: auto;
103+
padding: 1rem 1.25rem 1.25rem;
104+
}
105+
106+
.table-expander-modal__body table {
107+
margin: 0;
108+
min-width: 1000px;
109+
}
110+
111+
body.table-expander-modal-open {
112+
overflow: hidden;
113+
}
114+
115+
@media (max-width: 768px) {
116+
.table-expander-modal {
117+
padding: 0.75rem;
118+
}
119+
}

docs/_static/js/table-expander.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
(function () {
5+
function findNextTable(button) {
6+
let current = button.nextElementSibling;
7+
8+
while (current) {
9+
if (current.tagName && current.tagName.toLowerCase() === "table") {
10+
return current;
11+
}
12+
13+
const nestedTable = current.querySelector ? current.querySelector("table") : null;
14+
if (nestedTable) {
15+
return nestedTable;
16+
}
17+
18+
current = current.nextElementSibling;
19+
}
20+
21+
return null;
22+
}
23+
24+
function createModal() {
25+
const modal = document.createElement("div");
26+
modal.className = "table-expander-modal";
27+
modal.setAttribute("role", "dialog");
28+
modal.setAttribute("aria-modal", "true");
29+
modal.setAttribute("aria-hidden", "true");
30+
31+
const dialog = document.createElement("div");
32+
dialog.className = "table-expander-modal__dialog";
33+
34+
const header = document.createElement("div");
35+
header.className = "table-expander-modal__header";
36+
37+
const title = document.createElement("p");
38+
title.className = "table-expander-modal__title";
39+
40+
const closeButton = document.createElement("button");
41+
closeButton.className = "table-expander-modal__close";
42+
closeButton.type = "button";
43+
closeButton.setAttribute("aria-label", "Close expanded table");
44+
closeButton.textContent = "Close";
45+
46+
const body = document.createElement("div");
47+
body.className = "table-expander-modal__body";
48+
49+
header.append(title, closeButton);
50+
dialog.append(header, body);
51+
modal.append(dialog);
52+
document.body.append(modal);
53+
54+
return { body, closeButton, modal, title };
55+
}
56+
57+
function initializeTableExpanders() {
58+
const buttons = document.querySelectorAll(".table-expand-button");
59+
if (!buttons.length) {
60+
return;
61+
}
62+
63+
const modalParts = createModal();
64+
let activeButton = null;
65+
66+
function closeModal() {
67+
modalParts.modal.classList.remove("is-open");
68+
modalParts.modal.setAttribute("aria-hidden", "true");
69+
document.body.classList.remove("table-expander-modal-open");
70+
modalParts.body.replaceChildren();
71+
72+
if (activeButton) {
73+
activeButton.focus();
74+
activeButton = null;
75+
}
76+
}
77+
78+
function openModal(button, table) {
79+
const clonedTable = table.cloneNode(true);
80+
activeButton = button;
81+
modalParts.title.textContent = button.dataset.tableTitle || "Expanded table";
82+
modalParts.body.replaceChildren(clonedTable);
83+
modalParts.modal.classList.add("is-open");
84+
modalParts.modal.setAttribute("aria-hidden", "false");
85+
document.body.classList.add("table-expander-modal-open");
86+
modalParts.closeButton.focus();
87+
}
88+
89+
buttons.forEach((button) => {
90+
const table = findNextTable(button);
91+
92+
if (!table) {
93+
button.hidden = true;
94+
return;
95+
}
96+
97+
button.setAttribute("aria-label", "Open table in expanded view");
98+
button.addEventListener("click", () => openModal(button, table));
99+
});
100+
101+
modalParts.closeButton.addEventListener("click", closeModal);
102+
modalParts.modal.addEventListener("click", (event) => {
103+
if (event.target === modalParts.modal) {
104+
closeModal();
105+
}
106+
});
107+
document.addEventListener("keydown", (event) => {
108+
if (event.key === "Escape" && modalParts.modal.classList.contains("is-open")) {
109+
closeModal();
110+
}
111+
});
112+
}
113+
114+
if (document.readyState === "loading") {
115+
document.addEventListener("DOMContentLoaded", initializeTableExpanders);
116+
} else {
117+
initializeTableExpanders();
118+
}
119+
})();

docs/about/release-notes.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ For a complete record of changes in a release, refer to the
2525

2626
---
2727

28+
(v0-22-0)=
29+
30+
## 0.22.0
31+
32+
(v0-22-0-features)=
33+
34+
### Key Features
35+
36+
- LangChain is now optional. `pip install nemoguardrails` no longer pulls
37+
LangChain or any provider-specific `langchain-*` packages. The library ships
38+
with a built-in client that talks to OpenAI-compatible endpoints directly
39+
over `httpx`. Engines whose API isn't OpenAI-compatible (Anthropic, Cohere,
40+
Vertex AI, Google Generative AI, in-process Hugging Face, TensorRT-LLM,
41+
and others) keep working through LangChain when you opt in with
42+
`NEMOGUARDRAILS_LLM_FRAMEWORK=langchain` and install the matching provider
43+
package. Most 0.21 configurations keep working unchanged; some shapes need
44+
a YAML rewrite. For recipes, see [Migrating to 0.22](../migration/0.22.md).
45+
46+
- Public extension points for LLM integration. Two new protocols, `LLMModel`
47+
and `LLMFramework` in `nemoguardrails.types`, let you plug in a custom
48+
backend or a whole alternative framework without touching internals.
49+
50+
- Public testing surface. The `nemoguardrails.testing` module exposes
51+
`FakeLLMModel`, `TestChat`, and pytest fixtures for writing tests against a
52+
guardrails configuration without calling a real model.
53+
2854
(v0-21-0)=
2955

3056
## 0.21.0

docs/about/supported-llms.md

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title:
33
page: "Supported LLMs"
44
nav: "Supported LLMs"
5-
description: "Connect to NVIDIA NIM, OpenAI, Azure, Anthropic, HuggingFace, and LangChain providers."
5+
description: "Connect to NVIDIA NIM, OpenAI, Azure, Anthropic, Hugging Face, and LangChain providers."
66
keywords: ["llm providers", "nvidia nim", "openai", "langchain", "embedding providers"]
77
topics: ["generative_ai", "developer_tools"]
88
tags: ["llms", "ai_inference", "pretrained_models", "nlp"]
@@ -22,40 +22,52 @@ Integrating NeMo Guardrails improves safety and security of an Application LLM,
2222

2323
NeMo Guardrails can also call models for a specific guardrail on behalf of the client. Having guardrail-specific models allows the use of smaller fine-tuned models, which are specialized on the guardrails task. For example the NVIDIA Nemoguard collection of models includes [content-safety](https://build.nvidia.com/nvidia/llama-3_1-nemotron-safety-guard-8b-v3), [topic-control](https://build.nvidia.com/nvidia/llama-3_1-nemoguard-8b-topic-control), and [jailbreak-detect](https://build.nvidia.com/nvidia/nemoguard-jailbreak-detect) models. These models can be accessed on [build.nvidia.com](https://build.nvidia.com/) for rapid prototyping, or on [NGC Catalog](https://catalog.ngc.nvidia.com/) for deployment with NIM Docker containers.
2424

25-
## Application LLM Providers
26-
27-
The NeMo Guardrails library supports major LLM providers, including:
28-
29-
- OpenAI
30-
- Azure OpenAI
31-
- Anthropic
32-
- Cohere
33-
- Google Vertex AI
34-
35-
### Self-Hosted
36-
37-
The NeMo Guardrails library supports the following self-hosted LLM providers:
38-
39-
- HuggingFace Hub
40-
- HuggingFace Endpoints
41-
- vLLM
42-
- Generic
43-
44-
### Providers from LangChain
45-
46-
The NeMo Guardrails library supports LLM providers from the LangChain Community, including both text completion and chat completion providers. Refer to [Chat model integrations](https://docs.langchain.com/oss/python/integrations/chat) in the LangChain documentation. You can also use the [`nemoguardrails find-providers`](find-providers-command) CLI command to discover available providers.
47-
48-
## Embedding Providers
49-
50-
The NeMo Guardrails library supports the following embedding providers:
51-
52-
- NVIDIA NIM
53-
- NVIDIA AI Endpoints
54-
- FastEmbed
55-
- OpenAI
56-
- Azure OpenAI
57-
- Cohere
58-
- SentenceTransformers
59-
- Google
25+
## Inference Providers
26+
27+
Each engine is served by a framework that manages the underlying HTTP or SDK calls. NeMo Guardrails ships with a built-in framework that talks to OpenAI-compatible endpoints over `httpx` with no LangChain dependency. For engines whose API is not OpenAI-compatible, opt into the LangChain framework by setting `NEMOGUARDRAILS_LLM_FRAMEWORK=langchain` and installing the matching `langchain-<provider>` package. To add a custom framework, implement the `LLMFramework` protocol from `nemoguardrails.types`.
28+
29+
```{raw} html
30+
<button type="button" class="table-expand-button" data-table-title="Inference Providers">
31+
<span aria-hidden="true" class="table-expand-button__icon">&#x26F6;</span>
32+
Expand table
33+
</button>
34+
```
35+
36+
| Engine | Framework | Streaming | Tool calls | Reasoning models | Notes |
37+
| --- | --- | --- | --- | --- | --- |
38+
| `anthropic` | LangChain (opt-in) | yes | yes | wrapper-dependent | Requires `pip install langchain langchain-anthropic`. |
39+
| `azure`, `azure_openai` | LangChain (opt-in) | yes | yes | yes | Azure OpenAI is OpenAI-compatible at the wire level. The LangChain path (`langchain-openai`) is the convenient default because it handles the deployment-name URL pattern and `api-version` query string for you. Azure is also reachable through the built-in client by setting `parameters.base_url` to the deployment URL and passing `api-version` via `default_query` and `api-key` via `default_headers`. |
40+
| `cohere` | LangChain (opt-in) | yes | yes | n/a | Requires `pip install langchain langchain-cohere`. |
41+
| `google_genai` | LangChain (opt-in) | yes | yes | n/a | Requires `pip install langchain langchain-google-genai`. |
42+
| `huggingface_endpoint` | LangChain (opt-in) | varies | varies | varies | Default text-generation schema. If your endpoint exposes `/v1/chat/completions`, prefer `engine: openai` with `parameters.base_url` instead. |
43+
| `huggingface_pipeline`, `huggingface_hub`, `trt_llm`, `self_hosted` | LangChain (opt-in) | varies | varies | varies | In-process pipelines and LangChain wrappers without a native HTTP path. |
44+
| `nim` | Built-in | yes | yes | yes | Default base URL `https://integrate.api.nvidia.com/v1`. |
45+
| `nvidia_ai_endpoints` | Built-in | yes | yes | yes | Alias for `nim`. |
46+
| `ollama` | Built-in | yes | yes | yes (where supported) | Default base URL `http://localhost:11434/v1`. |
47+
| `openai` | Built-in | yes | yes | yes | OpenAI public API or any OpenAI-compatible endpoint using `parameters.base_url`. For vLLM, TGI, OpenRouter, Together.ai, Fireworks.ai, Groq, DeepSeek, llama.cpp, NVIDIA Nemotron, and similar providers, use `engine: openai` with `parameters.base_url` and `parameters.api_key`. |
48+
| `vertexai` | LangChain (opt-in) | yes | yes | n/a | Requires `pip install langchain langchain-google-vertexai`. |
49+
| `vllm_openai`, `deepseek` | LangChain (opt-in) | yes | yes | yes | Legacy LangChain provider engines. They continue to work when you opt into LangChain. For new configurations, use `engine: openai` with `parameters.base_url` when the wire protocol is OpenAI-compatible. |
50+
| `<provider_name>` | LangChain (opt-in) | varies | varies | varies | Any community provider exposed through LangChain's chat-model integrations. Use the bare provider name as the engine name. |
51+
52+
For migration recipes between the built-in path and the LangChain path, see [Migrating to 0.22](../migration/0.22.md).
53+
54+
## LangChain-Backed Providers
55+
56+
The NeMo Guardrails library supports LLM providers from the LangChain Community, including both text completion and chat completion providers. Refer to [Chat model integrations](https://python.langchain.com/docs/integrations/chat/) in the LangChain documentation. You can also use the [`nemoguardrails find-providers`](find-providers-command) CLI command to discover available providers.
57+
58+
## Embedding Model Providers
59+
60+
The NeMo Guardrails library uses embedding models for vector similarity search in dialog rails, `embeddings_only` intent matching, and knowledge base retrieval. The following table lists the supported embedding model providers and their corresponding engine names.
61+
62+
| Provider | Engine | Notes |
63+
| --- | --- | --- |
64+
| NVIDIA NIM | `nim` | NVIDIA NIM microservices |
65+
| NVIDIA AI Endpoints | `nvidia_ai_endpoints` | Alias for `nim` |
66+
| FastEmbed | `fastembed` | FastEmbed embedding model provider |
67+
| OpenAI | `openai` | OpenAI embedding model provider |
68+
| Azure OpenAI | `azure` | Azure OpenAI embedding model provider |
69+
| Cohere | `cohere` | Cohere embedding model provider |
70+
| SentenceTransformers | `sentence_transformers` | SentenceTransformers embedding model provider |
71+
| Google | `google` | Google embedding model provider |
6072

6173
For more information on configuring embedding providers, refer to [Embedding Search Providers](../configure-rails/other-configurations/embedding-search-providers.md).

docs/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@
258258
html_copy_source = False
259259
html_show_sourcelink = False
260260
html_show_sphinx = False
261+
html_static_path = ["_static"]
262+
html_css_files = ["css/custom.css"]
263+
html_js_files = ["js/table-expander.js"]
261264

262265
html_domain_indices = False
263266
html_use_index = False

0 commit comments

Comments
 (0)