composio-langchain

0.7.15last stable release 5 days ago
Complexity Score
High
Open Issues
N/A
Dependent Projects
8
Weekly Downloadsglobal
20,514

License

  • Apache-2.0
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Yespatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Downloads

Readme

EN | CN | JP

Production Ready Toolset for AI Agents

🚀 Now launching Composio MCP🚀

We're excited to announce the launch of Composio MCP Servers! Connect Claude, Cursor and Windsurf to 100+ fully-managed MCP Servers with built-in auth! Check it out here

What is Composio?

Composio provides production-ready toolset for AI agents, offering:

  • Support for over 250+ tools across multiple categories:
    • Software tools like GitHub, Notion, Linear, Gmail, Slack, Hubspot, Salesforce & more
    • OS operations including file tool, shell tool, code analysis tool & more
    • Search capabilities through Google, Perplexity, Tavily, and Exa & more
  • Comprehensive framework support including OpenAI, Groq, Claude, LlamaIndex, Langchain, CrewAI, Autogen, Gemini, and more
  • Managed authentication supporting multiple protocols (OAuth, API Keys, Basic JWT)
  • Up to 40% improved tool call accuracy through optimized design
  • Whitelabel solution for backend integration
  • Pluggable architecture supporting custom tools and extensions

Table of contents

  • Getting Started with Python
    • 1. Installation
    • 2. Creating an agent & executing a tool
  • Getting Started with Javascript
    • 1. Installation
    • 2. Creating an agent & executing a tool
  • Examples
    • Python Examples
    • Javascript Examples
  • Star History
  • Getting help
  • Contributions
  • Request a feature
  • Thanks To All Contributors

Getting Started with Python

1. Installation

Start by installing the package

pip install composio-core

If you want to install the ‘composio’ package along with its openai plugin: pip install composio-openai.

2. Creating an agent & executing a tool

Let’s create an AI Agent using OpenAI and use Composio’s GitHub tool to star a GitHub repository

[!NOTE] Set your COMPOSIO_API_KEY & OPENAI_API_KEY in your environment variables.

Connect your GitHub account to Composio

composio add github # Run this in terminal

from openai import OpenAI
from composio_openai import ComposioToolSet, App, Action

openai_client = OpenAI(
api_key="{{OPENAIKEY}}"
)

# Initialise the Composio Tool Set

composio_tool_set = ComposioToolSet()

# Get GitHub tools that are pre-configured
actions = composio_tool_set.get_actions(
actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER]
)

my_task = "Star a repo composiodev/composio on GitHub"

# Setup openai assistant
assistant_instruction = "You are a super intelligent personal assistant"

assistant = openai_client.beta.assistants.create(
name="Personal Assistant",
instructions=assistant_instruction,
model="gpt-4-turbo",
tools=actions,
)

# create a thread
thread = openai_client.beta.threads.create()

message = openai_client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=my_task
)

# Execute Agent with integrations
run = openai_client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id
)


# Execute Function calls
response_after_tool_calls = composio_tool_set.wait_and_handle_assistant_tool_calls(
client=openai_client,
run=run,
thread=thread,
)

print(response_after_tool_calls)

Getting Started with JavaScript

To get started with the Composio SDK in JavaScript, follow these steps:

1. Installation:

npm install composio-core

2. Creating an agent & executing a tool

Let’s create an AI Agent using OpenAI and use Composio’s GitHub tool to star a GitHub repository

[!NOTE] Set your COMPOSIO_API_KEY & OPENAI_API_KEY in your environment variables.

Connect your GitHub account to Composio

composio add github # Run this in terminal
import { OpenAIToolSet } from "composio-core";
import OpenAI from "openai";

const toolset = new OpenAIToolSet({ apiKey: process.env.COMPOSIO_API_KEY });
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

const tools = await toolset.getTools({ actions: ["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"] });

async function createGithubAssistant(openai, tools) {
return await openai.beta.assistants.create({
name: "Github Assistant",
instructions: "You're a GitHub Assistant, you can do operations on GitHub",
tools: tools,
model: "gpt-4o"
});
}

async function executeAssistantTask(openai, toolset, assistant, task) {
const thread = await openai.beta.threads.create();
const run = await openai.beta.threads.runs.create(thread.id, {
assistant_id: assistant.id,
instructions: task,
tools: tools,
model: "gpt-4o",
stream: false
});
const call = await toolset.waitAndHandleAssistantToolCalls(openai, run, thread);
console.log(call);
}

(async () => {
const githubAssistant = await createGithubAssistant(openai, tools);
await executeAssistantTask(
openai,
toolset,
githubAssistant,
"Star the repository 'composiohq/composio'"
);
})();

Examples

Python Examples

Javascript Examples

Star History

Getting help

  • Read the docs at docs.composio.dev
  • Post your questions on discord

Contributions

We’re an open-source project and welcome contributions. Please read the contributing guide for more information and check our code of conduct before you start.

Request a feature

  • If you have a feature request, please open an issue, make a pull request, or submit it in our feature requests channel.
  • If you have ideas for improvements, you can also start a discussion in our GitHub repository.

Thanks To All Contributors



           

Dependencies

No runtime dependency information found for this package.

CVE IssuesActive
0
Scorecards Score
No Data
Test Coverage
No Data
Follows Semver
No
Github Stars
24,898
Dependenciestotal
5
DependenciesOutdated
0
DependenciesDeprecated
0
Threat Modelling
No Data
Repo Audits
No Data

Learn how to distribute composio-langchain in your own private PyPI registry

pip install composio-langchain
Processing...
Done

195 Releases

PyPI on Cloudsmith

Getting started with PyPI on Cloudsmith is fast and easy.