Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
30cb595
Add deepagents submodule
dagardner-nv May 5, 2026
4c491fc
Bump version of deepagents, adding the checkout to gitignore. TODO: t…
dagardner-nv May 5, 2026
b3e22a6
Bump the version of langchain-core
dagardner-nv May 5, 2026
9acab27
Update comment
dagardner-nv May 5, 2026
5e65255
Update patch for langchain-core v1.3.3
dagardner-nv May 5, 2026
19e154a
Bump langgraph to v1.1.10
dagardner-nv May 5, 2026
98623b5
Bump version of langchain-nvidia from pre-release commit to v1.2.1
dagardner-nv May 5, 2026
56d420b
Bump langgraph version
dagardner-nv May 5, 2026
617b6e8
Pin against release tag for langgraph-prebuilt v1.0.13
dagardner-nv May 6, 2026
f293efc
Merge branch 'main' of github.com:NVIDIA/NeMo-Flow into david-lcda
dagardner-nv May 6, 2026
afb3fd6
WIP: langchain-core middleware, currently not working
dagardner-nv May 6, 2026
bdb40e9
WIP
dagardner-nv May 6, 2026
8b8b048
Ignore vscode ssettings
dagardner-nv May 6, 2026
eeb2b03
WIP
dagardner-nv May 6, 2026
76c6e7d
Widen the version dependencies for langchain
dagardner-nv May 6, 2026
96ebf5c
Move the run_sync method into the python wrapper for nemo_flow as lik…
dagardner-nv May 6, 2026
3cd1741
WIP
dagardner-nv May 7, 2026
a92e263
Slim down uneeded code
dagardner-nv May 7, 2026
6553cc2
Slim down
dagardner-nv May 7, 2026
8684819
Slim down
dagardner-nv May 7, 2026
88d69f8
Merge branch 'main' of github.com:NVIDIA/NeMo-Flow into david-lcda
dagardner-nv May 7, 2026
fea8c11
WIP
dagardner-nv May 7, 2026
0f91ab0
WIP
dagardner-nv May 7, 2026
44afddd
Formatting
dagardner-nv May 7, 2026
3a1b175
Set parent scope
dagardner-nv May 7, 2026
ce88f6e
Formatting
dagardner-nv May 7, 2026
07591fa
Add utils to __all__
dagardner-nv May 7, 2026
0a26572
Rework infer_codec_from_model
dagardner-nv May 7, 2026
b38f3ba
Remove tools from llm payloads, this wasn't working mostly because we…
dagardner-nv May 7, 2026
b744254
Remove unused code, consolidate redundant code
dagardner-nv May 7, 2026
10767ce
Reduce imports
dagardner-nv May 7, 2026
7d075e5
Cleanup imports
dagardner-nv May 7, 2026
702d003
Formatting
dagardner-nv May 7, 2026
a88e76a
Add langchain/langgraph deps to ignore list
dagardner-nv May 7, 2026
677643d
Move things up one dir level
dagardner-nv May 7, 2026
de4c16e
Adding tests
dagardner-nv May 7, 2026
ad918fc
Set workspace dep for nemo-flow
dagardner-nv May 7, 2026
d528085
Fetch the version from the Cargo.toml file, we can't use maturin as t…
dagardner-nv May 7, 2026
36c3f53
Ignore ty unresolved-import check
dagardner-nv May 7, 2026
2d0ef6d
Explicitly import from utils
dagardner-nv May 7, 2026
430e2e7
Fix ty ignores
dagardner-nv May 7, 2026
bc97266
Add tests to CI
dagardner-nv May 7, 2026
e89169d
Add a readme to the integration
dagardner-nv May 7, 2026
76d237d
Update docs
dagardner-nv May 7, 2026
a62d92e
Fix spelling error
dagardner-nv May 7, 2026
b250da4
Mark llm_execute and llm_stream_execute as private, per WK feedback
dagardner-nv May 7, 2026
28f76ac
Infer the version based on the git tag
dagardner-nv May 7, 2026
e87e188
Linting fixes
dagardner-nv May 7, 2026
fbf672c
Create a single ThreadPoolExecutor instance
dagardner-nv May 7, 2026
a28fc87
Fix tests
dagardner-nv May 7, 2026
e91f84c
Update python/nemo_flow/utils.py
dagardner-nv May 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ci-path-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ node:
python:
- 'crates/python/Cargo.toml'
- 'crates/python/src/**'
- 'integrations/langchain/**'
- 'pyproject.toml'
- 'python/**/!(*.md)'
- 'uv.lock'
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/ci_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ jobs:
with:
version: ${{ steps.ci-config.outputs.uv_version }}
enable-cache: true
cache-dependency-glob: ${{ env.NEMO_FLOW_CI_WORKSPACE }}/uv.lock
cache-dependency-glob: |
${{ env.NEMO_FLOW_CI_WORKSPACE }}/uv.lock
${{ env.NEMO_FLOW_CI_WORKSPACE }}/integrations/langchain/uv.lock

- name: Set up Windows ARM Python
if: ${{ matrix.platform == 'windows-arm64' }}
Expand Down Expand Up @@ -109,6 +111,10 @@ jobs:
working-directory: ${{ env.NEMO_FLOW_CI_WORKSPACE }}
run: just --set ci true --set output_dir "${{ github.workspace }}" test-python

- name: Run LangChain integration tests
working-directory: ${{ env.NEMO_FLOW_CI_WORKSPACE }}
run: just test-python-integration

- name: Upload Python coverage to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6
with:
Expand Down Expand Up @@ -170,7 +176,9 @@ jobs:
with:
version: ${{ steps.ci-config.outputs.uv_version }}
enable-cache: true
cache-dependency-glob: ${{ env.NEMO_FLOW_CI_WORKSPACE }}/uv.lock
cache-dependency-glob: |
${{ env.NEMO_FLOW_CI_WORKSPACE }}/uv.lock
${{ env.NEMO_FLOW_CI_WORKSPACE }}/integrations/langchain/uv.lock

- name: Set up Windows ARM Python
if: ${{ matrix.platform == 'windows-arm64' }}
Expand Down Expand Up @@ -229,6 +237,13 @@ jobs:
--set ref_name "${NEMO_FLOW_PACKAGE_VERSION}" \
package-python

- name: Package LangChain integration wheel
if: ${{ matrix.platform == 'linux-amd64' }}
working-directory: ${{ env.NEMO_FLOW_CI_WORKSPACE }}/integrations/langchain
run: |
set -e
uv build --wheel --out-dir "${{ env.NEMO_FLOW_CI_WORKSPACE_TMP }}/wheels"

- name: Upload wheel artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ benchmarks/
# Local third-party upstream checkouts. These are bootstrapped from
# third_party/sources.lock and are intentionally excluded from the tracked
# first-party repository surface.
third_party/deepagents/
third_party/langchain/
third_party/langchain-nvidia/
third_party/langgraph/
Expand All @@ -90,3 +91,6 @@ CHANGELOG.md

crates/wasm/coverage/
.scannerwork/

# VSCode
/.vscode
8 changes: 8 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ python/
go/
nemo_flow/ # Experimental Go CGo binding and tests
docs/ # Sphinx documentation site
integrations/ # Sample integrations using public APIs without patching
scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile
third_party/ # Pinned upstream checkouts for sample integration patches
patches/ # NeMo Flow patch sets applied to third_party checkouts
Expand Down Expand Up @@ -205,6 +206,7 @@ truth.

## Third-Party Integrations And Patches

### Patch-based Integrations
Sample integrations are maintained as patch sets, not as primary package source. The pinned upstream checkouts are listed in `third_party/sources.lock`, local checkouts live under `third_party/`, and NeMo Flow patches live under `patches/`.

Current integration patch sets include:
Expand All @@ -227,6 +229,12 @@ Use the stable root-level wrappers:

`apply-patches.sh` expects clean third-party checkouts. After editing an integration checkout, run `./scripts/generate-patches.sh` to regenerate patch files and verify they apply to a clean detached checkout.

### Public API-based Integrations
Some integrations can be implemented using public APIs without patching. These implementations are maintained under `integrations/` with their own README files and test suites.

Current public API-based integrations include:
- LangChain: `integrations/langchain`

## Documentation And Contribution Workflow

These workflow notes keep public documentation, examples, and PR preparation aligned
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ The table below summarizes the support level for each binding surface.
Some framework integrations are maintained as patch sets against upstream
projects rather than as packages in this repository.

### Public API-based Integrations
Some integrations can be implemented using public APIs without patching. These implementations are maintained under `integrations/` with their own README files and test suites.

### Patch-based Integrations
Use [third_party/README.md](third_party/README.md) for the clone, checkout, and
patch-application workflow for those integrations.

Expand Down
74 changes: 74 additions & 0 deletions integrations/langchain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->

# NeMo Flow LangChain Integration

This directory contains the `langchain_nemo_flow` package which provides observability integration for LangChain.

The intent of this project is to enable as much NeMo Flow functionality as possible using public LangChain APIs without requiring changes to LangChain itself.

For an alternate approach refer to [the patch-based integration in `third_party/langchain`](../../third_party/README-langchain.md).

## Setup

```bash
uv venv .venv
. .venv/bin/activate
uv pip install -e .
uv pip install -e integrations/langchain
```
Comment thread
dagardner-nv marked this conversation as resolved.

Optionally install the langchain-nvidia-ai-endpoints package.

```bash
uv pip install langchain-nvidia-ai-endpoints
```

## Usage Example

```python
import asyncio

import nemo_flow
from langchain.agents import create_agent
from langchain_core.tools import tool
from langchain_nemo_flow import NemoFlowCallbackHandler, NemoFlowMiddleware

@tool
def get_weather(location: str) -> str:
"""Get the current weather for a location."""
return f"The weather in {location} is sunny and 72 degrees."

agent = create_agent(
model="nvidia:nvidia/nemotron-3-nano-30b-a3b",
tools=[get_weather],
middleware=[NemoFlowMiddleware()],
system_prompt="Use tools when they are relevant. Keep the final answer brief.",
)

input_payload = {
"messages": [
{
"role": "user",
"content": "What is the weather in San Francisco?",
}
]
}

with nemo_flow.scope.scope("langchain-request", nemo_flow.ScopeType.Agent):
result = asyncio.run(agent.ainvoke(input_payload, config={"callbacks": [NemoFlowCallbackHandler()]}))

final_message = result["messages"][-1]
print(f"Final response: {final_message.content}")
```

## Validation

Run tests for the `langchain_nemo_flow` package to validate the integration:

```bash
cd integrations/langchain
uv run --group test pytest -q
```
75 changes: 75 additions & 0 deletions integrations/langchain/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=64", "setuptools-scm>=8", "setuptools_dynamic_dependencies>=1.0.0"]

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]
git_describe_command = "git describe --long --first-parent"
root = "../.."

[project]
name = "langchain-nemo-flow"
dynamic = ["version", "dependencies"]
description = "NeMo Flow middleware and callback integrations for LangChain."
requires-python = ">=3.11"
license = "Apache-2.0"
authors = [
{ name = "NVIDIA Corporation & Affiliates" },
]
keywords = [
"agents",
"langchain",
"middleware",
"nemo-flow",
"observability",
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

[tool.setuptools_dynamic_dependencies]
dependencies = [
# Minimum version to support they hooks we are using
"langchain>=1.2.9,<2.0.0",
# Allow the langchain to dictate the version of langchain-core, not strictly needed
# but we do import from langchain_core
"langchain-core",
"nemo-flow == {version}",
]
Comment thread
dagardner-nv marked this conversation as resolved.

[dependency-groups]
test = [
"pytest>=8",
]

[project.urls]
Documentation = "https://nvidia.github.io/NeMo-Flow/"
Homepage = "https://github.com/NVIDIA/NeMo-Flow"
Issues = "https://github.com/NVIDIA/NeMo-Flow/issues"
Repository = "https://github.com/NVIDIA/NeMo-Flow"

[tool.ruff]
line-length = 120
target-version = "py311"

[tool.ruff.format]
quote-style = "double"

[tool.ruff.lint]
select = ["E", "F", "W", "I"]

[tool.uv]
default-groups = ["test"]

[tool.uv.sources]
nemo-flow = { path = "../..", editable = true }
12 changes: 12 additions & 0 deletions integrations/langchain/src/langchain_nemo_flow/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""NeMo Flow integrations for LangChain."""

from langchain_nemo_flow.callbacks import NemoFlowCallbackHandler
from langchain_nemo_flow.middleware import NemoFlowMiddleware

__all__ = [
"NemoFlowCallbackHandler",
"NemoFlowMiddleware",
]
Loading
Loading