LangChain
Auto-trace chain, LLM, and tool lifecycle events from LangChain and LangGraph.
Installation
bash
pip install "axonpush[langchain]"Setup
python
import os
from axonpush import AxonPush
from axonpush.integrations.langchain import AxonPushCallbackHandler
client = AxonPush(
api_key=os.environ["AXONPUSH_API_KEY"],
tenant_id=os.environ["AXONPUSH_TENANT_ID"],
base_url=os.environ.get("AXONPUSH_BASE_URL", "https://api.axonpush.xyz"),
)
handler = AxonPushCallbackHandler(
client=client,
channel_id=1,
agent_id="langchain-agent",
)Usage
Pass the handler via config to any chain or agent:
python
result = chain.invoke(input, config={"callbacks": [handler]})python
result = agent_executor.invoke(
{"input": "What are AI agents?"},
config={"callbacks": [handler]},
)Events Traced
| Event | When |
|---|---|
chain.start | Chain begins execution |
chain.end | Chain completes |
llm.start | LLM call begins |
llm.end | LLM call completes |
tool.*.start | Tool execution begins |
tool.end | Tool execution completes |