Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,50 @@ The Composio Python SDK allows you to interact with the Composio Platform. It pr

```bash
pip install composio
# or
pip install composio-core
```

> **Note:** `composio-core` is the legacy SDK and is no longer maintained. Install `composio` for the current SDK.

### Provider-Specific Installations

For specific AI framework integrations:
For specific AI framework integrations, install the matching provider package alongside `composio`:

```bash
# OpenAI integration
pip install composio-openai
pip install composio composio-openai

# OpenAI Agents SDK integration
pip install composio composio-openai-agents

# Anthropic (Claude) integration
pip install composio composio-anthropic

# Claude Agent SDK integration
pip install composio composio-claude-agent-sdk

# LangChain integration
pip install composio-langchain
# LangChain integration
pip install composio composio-langchain

# LangGraph integration
pip install composio composio-langgraph

# CrewAI integration
pip install composio-crewai
pip install composio composio-crewai

# Anthropic integration
pip install composio-anthropic
# LlamaIndex integration
pip install composio composio-llamaindex

# AutoGen integration
pip install composio-autogen
# Google Vertex AI integration
pip install composio composio-google

# Google GenAI / Gemini integration
pip install composio composio-gemini

# And many more...
# Google ADK integration
pip install composio composio-google-adk

# AutoGen integration
pip install composio composio-autogen
```

## Getting Started
Expand Down Expand Up @@ -162,33 +181,25 @@ print(result)
#### LangChain Integration

```python
from composio_langchain import ComposioToolSet
from composio import Composio
from composio_langchain import LangchainProvider
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI

# Initialize the toolset
toolset = ComposioToolSet()
# Initialize Composio with the LangChain provider
composio = Composio(provider=LangchainProvider())

# Get tools for a specific toolkit
tools = toolset.get_tools(toolkits=["GITHUB"])
tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])

# Initialize LLM
llm = ChatOpenAI(model="gpt-4o")

# Create agent with tools
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant"),
("user", "{input}"),
("assistant", "{agent_scratchpad}")
])

agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools)
agent = create_agent(model=llm, tools=tools, system_prompt="You are a helpful assistant")

# Execute task
result = agent_executor.invoke({"input": "Star the composiohq/composio repository"})
result = agent.invoke({"messages": [{"role": "user", "content": "Star the composiohq/composio repository"}]})
print(result)
```

Expand All @@ -198,7 +209,6 @@ The Composio constructor accepts the following configuration options:

```python
from composio import Composio
from composio.core.provider import OpenAIProvider

composio = Composio(
api_key="your-api-key", # Your Composio API key
Expand All @@ -207,7 +217,7 @@ composio = Composio(
max_retries=3, # Maximum number of retries
allow_tracking=True, # Enable/disable telemetry (default: True)
file_download_dir="./downloads", # Directory for file downloads
provider=OpenAIProvider(), # Custom provider (default: OpenAIProvider)
# provider=OpenAIProvider(), # Default; install `composio-openai` to import explicitly
toolkit_versions={ "github": "12202025_01" } # Toolkit versions to use
)
```
Expand Down
51 changes: 26 additions & 25 deletions python/providers/anthropic/README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@
## 🚀🔗 Leveraging Claude with Composio

Facilitate the integration of Claude with Composio to empower Claude models to directly interact with external applications, broadening their capabilities and application scope.
Facilitate the integration of Anthropic's Claude with Composio to empower Claude models to directly interact with external applications, broadening their capabilities and application scope.

### Objective

- **Automate starring a GitHub repository** using conversational instructions via Claude Function Calls.
- **Automate starring a GitHub repository** using conversational instructions via Claude tool use.

### Installation and Setup

Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.

```bash
# Install Composio LangChain package
pip install composio-claude
pip install composio composio-anthropic anthropic
```

# Connect your GitHub account
composio-cli add github
Connect your GitHub account from the [Composio dashboard](https://platform.composio.dev/) before running the example.

# View available applications you can connect with
composio-cli show-apps
```
> Looking for the Claude Agent SDK? See `composio-claude-agent-sdk` instead.

### Usage Steps

#### 1. Import Base Packages

Prepare your environment by initializing necessary imports from Claude and setting up your client.
Prepare your environment by initializing necessary imports from Anthropic and Composio.

```python
import anthropic

from composio import Composio
from composio_anthropic import AnthropicProvider

# Initialize Claude client
client = anthropic.Anthropic()

# Initialize Composio with the Anthropic provider
composio = Composio(provider=AnthropicProvider())
```

### Step 2: Integrating GitHub Tools with Composio

This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for LangChain operations.
```python
from composio_claude import App, ComposioToolSet
Fetch GitHub tools for the user from Composio. Tools are returned in the Claude tool-use format, ready to pass to `messages.create`.

toolset = ComposioToolSet()
actions = toolset.get_tools(tools=App.GITHUB)
```python
tools = composio.tools.get(user_id="default", toolkits=["GITHUB"])
```

### Step 3: Agent Execution

This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
Send a request to Claude with the Composio-provided tools.

```python
my_task = "Star a repo composiohq/composio on GitHub"
task = "Star me composiohq/composio repo in github."

# Create a chat completion request to decide on the action
response = client.beta.tools.messages.create(
response = client.messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
tools= actions,
messages=[{"role": "user", "content": "Star me composiohq/composio repo in github."}],
tools=tools,
messages=[{"role": "user", "content": task}],
)
pprint(response)

print(response)
```

### Step 4: Validate Execution Response

Execute the following code to validate the response, ensuring that the intended task has been successfully completed.
Have Composio handle any tool calls the model produced and return the results.

```python
result = toolset.handle_tool_calls(response)
pprint(result)
result = composio.provider.handle_tool_calls(user_id="default", response=response)
print(result)
```
52 changes: 21 additions & 31 deletions python/providers/gemini/README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,59 @@
## 🚀🔗 Integrating Composio with Google's Gemini SDK

Streamline the integration of Composio with Google AI Python to enhance the capabilities of Gemini models, allowing them to interact directly with external applications and expanding their operational scope.
Streamline the integration of Composio with the Google GenAI (Gemini) SDK to enhance the capabilities of Gemini models, allowing them to interact directly with external applications and expanding their operational scope.

### Objective

- **Automate starring a GitHub repository** using conversational instructions via Google AI Python's Function Calling feature.
- **Automate starring a GitHub repository** using conversational instructions via Gemini's function-calling feature.

### Installation and Setup

Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.

```bash
# Install Composio Gemini package
pip install composio-gemini

# Connect your GitHub account
composio add github

# View available applications you can connect with
composio apps
pip install composio composio-gemini google-genai
```

Connect your GitHub account from the [Composio dashboard](https://platform.composio.dev/) before running the example.

### Usage Steps

#### 1. Import Base Packages

Prepare your environment by initializing necessary imports from Google AI Python and setting up your client.
Prepare your environment by initializing necessary imports from Google's GenAI SDK and Composio.

```python
from google import genai
from google.genai import types

# Create google client
from composio import Composio
from composio_gemini import GeminiProvider

# Initialize Composio with the Gemini provider
composio = Composio(provider=GeminiProvider())

# Create the Google GenAI client
client = genai.Client()
```

### Step 2: Integrating GitHub Tools with Composio

This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for Google AI Python operations.
```python
from google.genai import types

from composio_gemini import Action, ComposioToolSet

# Create composio client
toolset = ComposioToolSet()
Fetch a specific GitHub tool from Composio and attach it to a Gemini config.

# Create tools
tools = toolset.get_tools(
actions=[
Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER,
]
)

# Create genai client config
```python
config = types.GenerateContentConfig(
tools=tools, # type: ignore
tools=composio.tools.get(
user_id="default",
tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],
)
)
```

### Step 3: Agent Execution

This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
Use the chat interface to talk to Gemini.

```python
# Use the chat interface.
chat = client.chats.create(model="gemini-2.0-flash", config=config)
response = chat.send_message(
"Can you star composiohq/composio repository on github",
Expand Down
Loading
Loading