Setup
First, install the relevantlunary
and langchain
packages:
- Python
- Javascript
LUNARY_PUBLIC_KEY
environment variable to your app tracking id.
- Python
- Javascript
Usage with LLM calls
You can use the callback handler with any LLM or Chat class from LangChain.- Python
- Javascript
Usage with chains (LCEL)
You can also use the callback handler with LCEL, LangChain Expression Language.- Python
- Javascript
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:- Python
- Javascript
Usage with custom agents
If you’re partially using LangChain, you can use the callback handler combined with thelunary
module to track custom agents:
- Python
- Javascript
Usage with LangServe
You can use the callback handler to track all calls to your LangServe server.Server
- Python
Client
- Python