LangChain
We provide callback handler that can be used to track LangChain calls, chains and agents.
Setup
First, install the relevant lunary
and langchain
packages:
Then, set the LUNARY_PUBLIC_KEY
environment variable to your app tracking id.
If you'd prefer not to set an environment variable, you can pass the key directly when initializing the callback handler:
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 the lunary
module to track custom agents:
Usage with LangServe
You can use the callback handler to track all calls to your LangServe server.
Server
Client