Setup
First, install the relevantlunary
and langchain
packages:
LUNARY_PUBLIC_KEY
environment variable to your app tracking id.
Usage with LLM calls
You can use the callback handler with any LLM or Chat class from LangChain.Usage with chains (LCEL)
You can also use the callback handler with LCEL, LangChain Expression Language.Usage with agents
The callback handler works seamlessly with LangChain agents and chains. For agents, it is recommended to pass a name in the metadatas to track them in the dashboard. Example:Usage with custom agents
If you’re partially using LangChain, you can use the callback handler combined with thelunary
module to track custom agents: