nemo_relay.integrations.langchain.callbacks#

LangChain callback handler that maps run hierarchy to NeMo Relay scopes.

Classes#

NemoRelayCallbackHandler

Bridge LangChain chain run IDs to NeMo Relay Agent scopes.

Module Contents#

class nemo_relay.integrations.langchain.callbacks.NemoRelayCallbackHandler#

Bases: langchain_core.callbacks.base.BaseCallbackHandler

Bridge LangChain chain run IDs to NeMo Relay Agent scopes.

run_inline = True#
on_chain_start(
serialized: dict[str, Any],
inputs: dict[str, Any],
*,
run_id: uuid.UUID,
parent_run_id: uuid.UUID | None = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
**kwargs: Any,
) Any#

Push a NeMo Relay Agent scope for a LangChain chain run.

on_chain_end(
outputs: dict[str, Any],
*,
run_id: uuid.UUID,
parent_run_id: uuid.UUID | None = None,
**kwargs: Any,
) Any#

Pop the NeMo Relay scope associated with a LangChain chain run.

on_chain_error(
error: BaseException,
*,
run_id: uuid.UUID,
parent_run_id: uuid.UUID | None = None,
**kwargs: Any,
) Any#

Pop the NeMo Relay scope associated with a failed LangChain chain run.