Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/export-observability-data/basic-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Good starting points:
- [Basic Guide: Adding Scopes and Marks](../instrument-applications/adding-scopes-and-marks.md)
- [Basic Guide: Instrument a Tool Call](../instrument-applications/instrument-tool-call.md)
- [Basic Guide: Instrument an LLM Call](../instrument-applications/instrument-llm-call.md)
- [Python Quick Start](../getting-started/python.md)
- [Python Quick Start](../getting-started/python/index.md)
- [Node.js Quick Start](../getting-started/nodejs.md)
- [Rust Quick Start](../getting-started/rust.md)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ SPDX-License-Identifier: Apache-2.0

# Python Quick Start

This quick start shows the smallest Python workflow that emits scope, tool, and LLM
events.
This quick start shows the smallest Python workflow that emits scope, tool, and LLM events.

[LangChain](https://www.langchain.com/langchain) and [LangGraph](https://www.langchain.com/langgraph) users should start with the [LangChain integration](langchain.md) or [LangGraph integration](langgraph.md) guides for the best experience in those frameworks.

## Choose an Install Path

Expand Down Expand Up @@ -126,6 +127,20 @@ These modules are the main Python APIs to use from applications and integrations

Use these links to continue from the quick start into the core runtime concepts.

- [Scopes](../about/concepts/scopes.md)
- [Middleware](../about/concepts/middleware.md)
- [Plugins](../about/concepts/plugins.md)
- [LangChain integration](langchain.md)
- [LangGraph integration](langgraph.md)
- [Scopes](../../about/concepts/scopes.md)
- [Middleware](../../about/concepts/middleware.md)
- [Plugins](../../about/concepts/plugins.md)

## Framework Integrations

Use these guides when your Python application already uses LangChain or
LangGraph and you want NeMo Flow observability through their public APIs.

```{toctree}
:maxdepth: 1

LangChain Integration <langchain>
LangGraph Integration <langgraph>
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,59 @@ SPDX-License-Identifier: Apache-2.0

# NeMo Flow LangChain Integration

This directory contains the `nemo_flow.integrations.langchain` package which provides observability integration for LangChain.
Use the `nemo_flow.integrations.langchain` package to add NeMo Flow
observability to [LangChain](https://www.langchain.com/langchain) agents.

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.
## Setup

For an alternate approach refer to [the patch-based integration in `third_party/langchain`](../../../../third_party/README-langchain.md).
Install the LangChain integration extra in your application environment.

## Setup
::::{tab-set}
:sync-group: install-tool

:::{tab-item} uv
:selected:
:sync: uv

```bash
uv add "nemo-flow[langchain]"
```
:::

:::{tab-item} pip
:sync: pip

```bash
pip install "nemo-flow[langchain]"
```
Comment thread
dagardner-nv marked this conversation as resolved.
:::

::::

The example below uses the NVIDIA LangChain provider. Install that provider
extra too if you want to run the example as written:

::::{tab-set}
:sync-group: install-tool

:::{tab-item} uv
:selected:
:sync: uv

```bash
uv add "nemo-flow[langchain,langchain-nvidia]"
```
:::

:::{tab-item} pip
:sync: pip

```bash
uv sync --all-groups --all-extras
just build-python
pip install "nemo-flow[langchain,langchain-nvidia]"
```
Comment thread
dagardner-nv marked this conversation as resolved.
:::

::::

## Usage Example

Expand All @@ -28,11 +69,13 @@ from langchain.agents import create_agent
from langchain_core.tools import tool
from nemo_flow.integrations.langchain 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],
Expand All @@ -50,16 +93,14 @@ input_payload = {
}

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

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

## Validation
## Observability

Run tests for the LangChain integration package to validate the integration:

```bash
uv run pytest python/tests/integrations/langchain
```
Refer to [Export Observability Data](../../export-observability-data/about.md) for details on exporting NeMo Flow observability data to third-party systems.
Comment thread
dagardner-nv marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,37 @@ SPDX-License-Identifier: Apache-2.0

# NeMo Flow LangGraph Integration

This directory contains the `nemo_flow.integrations.langgraph` package, which provides public-API LangGraph integration for NeMo Flow.
Use the `nemo_flow.integrations.langgraph` package to add NeMo Flow
observability to [LangGraph](https://www.langchain.com/langgraph) workflows through public LangGraph APIs.

The integration builds on `nemo_flow.integrations.langchain`: `NemoFlowCallbackHandler` inherits the LangChain callback handler, and `NemoFlowMiddleware` is re-exported for LangChain agents used inside LangGraph workflows.
## Setup

For an alternate approach refer to [the patch-based integration in `third_party/langchain`](../../../../third_party/README-langgraph.md).
Install the LangGraph integration extra in your application environment.

## Setup
::::{tab-set}
:sync-group: install-tool

:::{tab-item} uv
:selected:
:sync: uv

```bash
uv sync --all-groups --extra langgraph
just build-python
uv add "nemo-flow[langgraph]"
```
:::

Installing the `langgraph` extra also installs the LangChain integration dependencies.
:::{tab-item} pip
:sync: pip

```bash
pip install "nemo-flow[langgraph]"
```
Comment thread
dagardner-nv marked this conversation as resolved.
:::

::::

Installing the `langgraph` extra also installs the LangChain integration
dependencies.

## Usage Example

Expand Down Expand Up @@ -54,7 +71,9 @@ with nemo_flow.scope.scope("langgraph-request", nemo_flow.ScopeType.Agent):
print(result)
```

For LangChain agents inside a LangGraph workflow, use `NemoFlowMiddleware` from this package the same way as the LangChain integration and pass the LangGraph `config` into the nested agent call:
For LangChain agents inside a LangGraph workflow, use `NemoFlowMiddleware` from
this package the same way as the LangChain integration and pass the LangGraph
`config` into the nested agent call:

```python
from langchain.agents import create_agent
Expand All @@ -72,8 +91,31 @@ def agent_node(state: dict, config: RunnableConfig) -> dict:
return agent.invoke({"messages": state["messages"]}, config=config)
```

## Validation
Install the NVIDIA LangChain provider if you want to run the nested agent
example as written:

::::{tab-set}
:sync-group: install-tool

:::{tab-item} uv
:selected:
:sync: uv

```bash
uv add "nemo-flow[langgraph,langchain-nvidia]"
```
:::

:::{tab-item} pip
:sync: pip

```bash
uv run pytest python/tests/integrations/langgraph
pip install "nemo-flow[langgraph,langchain-nvidia]"
```
Comment thread
dagardner-nv marked this conversation as resolved.
:::

::::

## Observability

Refer to [Export Observability Data](../../export-observability-data/about.md) for details on exporting NeMo Flow observability data to third-party systems.
Comment thread
dagardner-nv marked this conversation as resolved.
2 changes: 1 addition & 1 deletion docs/getting-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Choose the Quick Start guide for the primary binding that you plan to use.
```{toctree}
:maxdepth: 1

Python Quick Start <python>
Python Quick Start <python/index>
Node.js Quick Start <nodejs>
Rust Quick Start <rust>
```
2 changes: 1 addition & 1 deletion docs/instrument-applications/adding-scopes-and-marks.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Scopes give emitted work ownership. Marks record point-in-time checkpoints insid

Complete one binding Quick Start guide first:

- [Python Quick Start](../getting-started/python.md)
- [Python Quick Start](../getting-started/python/index.md)
- [Node.js Quick Start](../getting-started/nodejs.md)
- [Rust Quick Start](../getting-started/rust.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/instrument-applications/instrument-llm-call.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You will wrap one existing LLM provider invocation with the managed LLM executio

Complete one binding Quick Start guide first:

- [Python Quick Start](../getting-started/python.md)
- [Python Quick Start](../getting-started/python/index.md)
- [Node.js Quick Start](../getting-started/nodejs.md)
- [Rust Quick Start](../getting-started/rust.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/instrument-applications/instrument-tool-call.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You will wrap one existing tool callback with the managed tool execution API. Th

Complete one binding Quick Start guide first:

- [Python Quick Start](../getting-started/python.md)
- [Python Quick Start](../getting-started/python/index.md)
- [Node.js Quick Start](../getting-started/nodejs.md)
- [Rust Quick Start](../getting-started/rust.md)

Expand Down
4 changes: 4 additions & 0 deletions docs/integrate-frameworks/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Use these signals to decide whether this documentation path matches your current
- Are building or reviewing third-party integration patches

If you own the application call sites directly, use [Instrument Applications](../instrument-applications/about.md) first.
If your application uses [LangChain](https://www.langchain.com/langchain) or
[LangGraph](https://www.langchain.com/langgraph), start with
[LangChain Integration](../getting-started/python/langchain.md) or
[LangGraph Integration](../getting-started/python/langgraph.md).

## Guides

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/api/python/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ nemo_flow <_generated/nemo_flow/index>
Use these links to continue from the API reference into task-focused guides.

- [Quick Start](../../../getting-started/quick-start.md)
- [Python Quick Start](../../../getting-started/python.md)
- [Python Quick Start](../../../getting-started/python/index.md)
- [Scopes](../../../about/concepts/scopes.md)
- [Middleware](../../../about/concepts/middleware.md)
- [Subscribers](../../../about/concepts/subscribers.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/support-and-faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Start with Python, Node.js, or Rust. These are the primary documented bindings
and have the broadest getting-started, concept, guide, and generated API
coverage.

- Use [Python Quick Start](../getting-started/python.md) when you are adding
- Use [Python Quick Start](../getting-started/python/index.md) when you are adding
NeMo Flow to Python application code or agent harnesses.
- Use [Node.js Quick Start](../getting-started/nodejs.md) when your application,
framework integration, or plugin-facing code runs in Node.js.
Expand Down
52 changes: 52 additions & 0 deletions python/nemo_flow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,53 @@ If you are not using `uv`, install it with `pip`:
pip install nemo-flow
```

### Optional Dependencies

#### LangChain Integration

[LangChain](https://www.langchain.com/langchain) integration is available with the `langchain` extra:

```bash
# With uv
uv add "nemo-flow[langchain]"

# With pip
pip install "nemo-flow[langchain]"
```

#### LangGraph Integration

[LangGraph](https://www.langchain.com/langgraph) integration is available with the `langgraph` extra, this builds upon and includes the `langchain` extra as well.

```bash
# With uv
uv add "nemo-flow[langgraph]"

# With pip
pip install "nemo-flow[langgraph]"
```

#### LangChain NVIDIA Integration

The [LangChain NVIDIA](https://github.com/langchain-ai/langchain-nvidia) extra builds upon the `langchain` extra adding a compatible version of the `langchain-nvidia-ai-endpoints` package.

```bash
# With uv
uv add "nemo-flow[langchain-nvidia]"

# With pip
pip install "nemo-flow[langchain-nvidia]"
```

To install this along with the `langgraph` extra, use:

```bash
# With uv
uv add nemo-flow[langgraph,langchain-nvidia]
# With pip
pip install nemo-flow[langgraph,langchain-nvidia]
```

## Getting Started

Register a subscriber, create a scope, and emit a mark event:
Expand Down Expand Up @@ -98,6 +145,11 @@ The public package modules are:
- `nemo_flow.typed`
- `nemo_flow.codecs`

### Integrations

- `nemo_flow.integrations.langchain`
- `nemo_flow.integrations.langgraph`
Comment thread
dagardner-nv marked this conversation as resolved.

The compiled extension is exposed as `nemo_flow._native`.

## Documentation
Expand Down
Loading