
Security News
Python Adopts Standard Lock File Format for Reproducible Installs
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
@braintrust/langchain-js
Advanced tools
SDK for integrating Braintrust with LangChain.js. This package provides a callback handler to automatically log LangChain.js executions to Braintrust.
npm install @braintrust/langchain-js
# or
yarn add @braintrust/langchain-js
# or
pnpm add @braintrust/langchain-js
First, make sure you have your Braintrust API key set in your environment:
export BRAINTRUST_API_KEY="your-api-key"
import { ChatOpenAI } from "@langchain/openai";
import {
BraintrustCallbackHandler,
setGlobalHandler,
} from "@braintrust/langchain-js";
// Create the callback handler (optionally pass in a custom logger)
const handler = new BraintrustCallbackHandler();
// Set the handler for all LangChain components
setGlobalHandler(handler);
// Use LangChain as normal - all calls will be logged to Braintrust
const response = await model.invoke("Tell me a joke about bears");
If you'd like to pass the callback handler to specific LangChain calls, you can do so by passing the handler to the callbacks
option.
import { ChatOpenAI } from "@langchain/openai";
import { BraintrustCallbackHandler } from "@braintrust/langchain-js";
// Create the callback handler (optionally pass in a custom logger)
const handler = new BraintrustCallbackHandler();
// Initialize your LangChain components with the handler
const model = new ChatOpenAI({
callbacks: [handler],
});
// Use LangChain as normal - all calls will be logged to Braintrust
const response = await model.invoke("Tell me a joke about bears", {
callbacks: [handler],
});
The callback handler supports logging for:
Review the LangChain.js documentation for more information on how to use callbacks.
Contributions are welcomed!
git clone https://github.com/braintrustdata/sdk.git
cd sdk/integrations/langchain-js
pnpm install
# work on the code
pnpm test
pnpm build
FAQs
SDK for integrating Braintrust with LangChain.js
The npm package @braintrust/langchain-js receives a total of 264 weekly downloads. As such, @braintrust/langchain-js popularity was classified as not popular.
We found that @braintrust/langchain-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
Security News
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.