@bluebag/langchain
v0.1.0
Published
LangChain integration for Bluebag
Readme
@bluebag/langchain
LangChain integration for Bluebag.
Installation
npm install @bluebag/langchain langchain @langchain/openaiQuick Start
import { createAgent } from 'langchain';
import { HumanMessage } from '@langchain/core/messages';
import { Bluebag } from '@bluebag/langchain';
// Create the Bluebag client
const bluebag = new Bluebag({
apiKey: process.env.BLUEBAG_API_KEY!,
});
// Enhance your config with Bluebag tools
const config = await bluebag.enhance({
model: 'openai:gpt-4o',
messages: [
new HumanMessage('Create a Python script that prints hello world'),
],
});
// Create a LangChain agent
const agent = createAgent({
model: config.model,
tools: config.tools,
systemPrompt: config.systemMessage,
});
// Run the agent
const result = await agent.invoke({ messages: config.messages });
console.log(result.messages.at(-1)?.content);Configuration Options
const bluebag = new Bluebag({
apiKey: process.env.BLUEBAG_API_KEY!,
stableId: 'user-123', // Optional: for multi-tenant isolation
activeSkills: ['skill-id'], // Optional: restrict to specific skills
stripMimeTypes: ['image/png'], // Optional: strip specific MIME types from messages
});Tools
The package provides the following tools:
- bluebag_bash - Execute bash commands in the sandbox
- bluebag_code_execution - Run Python, JavaScript, or TypeScript code
- bluebag_computer_use - Control the sandbox desktop
- bluebag_text_editor - View, create, and edit files
- bluebag_file_download_url - Get download URLs for generated files
API Reference
Bluebag Class
The main client class for Bluebag integration.
const bluebag = new Bluebag({ apiKey: "..." });
// Enhance your config with Bluebag tools
const config = await bluebag.enhance({
model: "openai:gpt-4o",
messages: [...],
});
// Session management
await bluebag.initSession();
const sessionId = bluebag.getSessionId();
bluebag.setStableId("user-123");
bluebag.setActiveSkills(["pdf-processing"]);
// File operations
const file = await bluebag.files.create({ file, filename, mediaType });
const blob = await bluebag.files.download(fileId);
const metadata = await bluebag.files.retrieveMetadata(fileId);
const url = await bluebag.files.mintShortLivedDownloadUrl(fileId);Constructor Options
| Option | Type | Description |
| ---------------- | -------------- | -------------------------------------------- |
| apiKey | string | Your Bluebag API key (required) |
| stableId | string | Stable identifier for multi-tenant isolation |
| activeSkills | string[] | Array of skill IDs to enable |
| apiBaseUrl | string | Custom API base URL |
| fetchImpl | typeof fetch | Custom fetch implementation |
| stripMimeTypes | string[] | MIME types to strip from messages |
