Skip to main content
LangChain is a framework for developing applications powered by language models. AgentOps automatically tracks your LangChain agents by integrating its callback handler.

Installation

Install AgentOps and the necessary LangChain dependencies:

Setting Up API Keys

You’ll need API keys for AgentOps and OpenAI (as ChatOpenAI is commonly used with LangChain): Set these as environment variables or in a .env file.
Then load them in your Python code:

Usage

Integrating AgentOps with LangChain involves using the LangchainCallbackHandler.
You don’t need a separate agentops.init() call; the LangchainCallbackHandler initializes the AgentOps client automatically if an API key is provided to it or found in the environment.
Here’s a basic example:
Visit the AgentOps Dashboard to see your session.

Examples

LangChain Example

A detailed notebook demonstrating the LangChain callback handler integration.