npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@composio/langchain

v0.3.1

Published

The LangChain provider for Composio SDK, providing seamless integration with LangChain's ecosystem and tools.

Downloads

10,775

Readme

@composio/langchain

The LangChain provider for Composio SDK, providing seamless integration with LangChain's ecosystem and tools.

Features

  • LangChain Integration: Seamless integration with LangChain's ecosystem
  • LCEL Support: Full support for LangChain Expression Language (LCEL)
  • Streaming Support: First-class support for streaming responses
  • Tool Execution: Execute LangChain tools with proper parameter handling
  • Chain Integration: Work with LangChain chains and agents
  • Type Safety: Full TypeScript support with proper type definitions

Installation

npm install @composio/core @composio/langchain @langchain/core @langchain/openai
# or
yarn add @composio/core @composio/langchain @langchain/core @langchain/openai
# or
pnpm add @composio/core @composio/langchain @langchain/core @langchain/openai

Environment Variables

Required environment variables:

  • COMPOSIO_API_KEY: Your Composio API key
  • OPENAI_API_KEY: Your OpenAI API key (or other LLM provider's key)

Optional environment variables:

  • LANGCHAIN_TRACING_V2: Enable LangChain tracing (set to "true")
  • LANGCHAIN_ENDPOINT: Custom LangChain API endpoint
  • LANGCHAIN_API_KEY: Your LangChain API key (for hosted services)

Quick Start

import { Composio } from '@composio/core';
import { LangChainProvider } from '@composio/langchain';

// Initialize Composio with LangChain provider
const composio = new Composio({
  apiKey: 'your-composio-api-key',
  provider: new LangChainProvider(),
});

// Get available tools
const tools = await composio.tools.get('user123', {
  toolkits: ['gmail', 'googlecalendar'],
  limit: 10,
});

// Get tools with version control
const versionedTools = await composio.tools.get('user123', {
  toolkits: ['gmail'],
  toolkitVersions: { gmail: '20250909_00' },
});

// Get a specific tool
const sendEmailTool = await composio.tools.get('user123', 'GMAIL_SEND_EMAIL');

Examples

Check out our complete example implementations:

Basic Chain with Streaming

import { Composio } from '@composio/core';
import { LangChainProvider } from '@composio/langchain';
import { ChatPromptTemplate } from '@langchain/core/prompts';
import { StringOutputParser } from '@langchain/core/output_parsers';
import { ChatOpenAI } from '@langchain/openai';

const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
  provider: new LangChainProvider(),
});

// Get tools for the chain
const tools = await composio.tools.get('user123', {
  toolkits: ['gmail'],
  limit: 10,
});

const model = new ChatOpenAI({
  modelName: 'gpt-4',
  streaming: true,
});

const prompt = ChatPromptTemplate.fromTemplate('Tell me a joke about {topic}');
const parser = new StringOutputParser();

const chain = prompt.pipe(model).pipe(parser);

// Stream the response
const stream = await chain.stream({
  topic: 'programming',
});

for await (const chunk of stream) {
  console.log(chunk);
}

Tool Execution with Streaming Events

import { Composio } from '@composio/core';
import { LangChainProvider } from '@composio/langchain';
import { ChatPromptTemplate } from '@langchain/core/prompts';
import { JsonOutputParser } from '@langchain/core/output_parsers';
import { ChatOpenAI } from '@langchain/openai';

const composio = new Composio({
  apiKey: process.env.COMPOSIO_API_KEY,
  provider: new LangChainProvider(),
});

// Get tools for the chain
const tools = await composio.tools.get('user123', {
  toolkits: ['gmail'],
});

const model = new ChatOpenAI({
  modelName: 'gpt-4',
  streaming: true,
});

const chain = model.pipe(new JsonOutputParser());
const eventStream = await chain.streamEvents(
  `Output a list of the countries france, spain and japan and their populations in JSON format.`,
  { version: 'v2' }
);

for await (const event of eventStream) {
  const eventType = event.event;
  if (eventType === 'on_chat_model_stream') {
    console.log(`Chat model chunk: ${event.data.chunk.content}`);
  } else if (eventType === 'on_parser_stream') {
    console.log(`Parser chunk: ${JSON.stringify(event.data.chunk)}`);
  }
}

Provider Configuration

The LangChain provider can be configured with various options:

const provider = new LangChainProvider({
  // Default model configuration
  model: new ChatOpenAI({
    modelName: 'gpt-4',
    streaming: true,
  }),
  // Custom execution modifiers
  modifiers: {
    beforeExecute: params => {
      // Transform parameters before execution
      return params;
    },
    afterExecute: response => {
      // Transform response after execution
      return response;
    },
  },
  // Enable tracing
  tracing: true,
});

API Reference

LangChainProvider Class

The LangChainProvider class extends BaseComposioProvider and provides LangChain-specific functionality.

Methods

executeToolCall(tool: Tool): Promise<string>

Executes a LangChain tool call and returns the result.

const result = await provider.executeToolCall(tool);

Contributing

We welcome contributions! Please see our Contributing Guide for more details.

License

ISC License

Support

For support, please visit our Documentation or join our Discord Community.