LangChain
This guide explains how to integrate HoneyHive with LangChain for both Python and TypeScript implementations.
Initializing HoneyHive Tracer
Use the following code to initialize HoneyHive tracing in your project:
pip install honeyhive[langchain]
.For Python projects, use the HoneyHiveTracer
class to initialize tracing:
This initializes auto-tracing for your entire Python application.
pip install honeyhive[langchain]
.For Python projects, use the HoneyHiveTracer
class to initialize tracing:
This initializes auto-tracing for your entire Python application.
For TypeScript projects, use the HoneyHiveLangChainTracer
class to create a tracer instance:
You’ll need to pass this tracer instance to the LangChain components you want to trace.
If you’re using these code examples verbatim, then make sure to set the appropriate environment variables (HH_API_KEY
, HH_PROJECT
, and for TypeScript, HH_SESSION_NAME
) before running your application.
Supported LangChain Versions/Interfaces
- Python: Compatible with LangChain versions
^0.2.0
and above. - JavaScript: Compatible with LangChain versions
^0.2.0
and above.
For the most up-to-date compatibility information, please refer to the HoneyHive documentation.
Nesting
Nesting is handled automatically by the HoneyHive tracing system. When you use traced components within other traced components, the system will create a hierarchical structure of spans, reflecting the nested nature of your LangChain operations.
Enriching Properties
For information on how to enrich your traces and spans with additional context, see our enrichment documentation.
Adding Evaluators
Once traces have been logged in the HoneyHive platform, you can then run evaluations with either Python or TypeScript.
Cookbook Examples
Python Example
TypeScript Example
These examples demonstrate how to integrate HoneyHive tracing with LangChain in both Python and TypeScript environments, covering document loading, text splitting, embedding creation, vector store operations, and question-answering chains.