Skip to content

Commit

Permalink
Merge branch 'fix/swe-benchmark' of github.com:ComposioHQ/composio in…
Browse files Browse the repository at this point in the history
…to fix/swe-benchmark
  • Loading branch information
alt-glitch committed Feb 7, 2025
2 parents 7480c26 + 26e0075 commit edd51bc
Show file tree
Hide file tree
Showing 41 changed files with 769 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: |
pip install build twine
plugins="autogen camel claude crew_ai griptape julep langchain llamaindex lyzr openai praisonai langgraph phidata google"
plugins="autogen camel claude crew_ai griptape julep langchain llamaindex lyzr openai praisonai langgraph phidata google gemini agno"
mkdir plugins_dist
for plugin in $plugins; do
cd plugins/$plugin
Expand Down
24 changes: 12 additions & 12 deletions docs/framework/phidata.mdx → docs/framework/agno.mdx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
title: "Using Composio With Phidata"
sidebarTitle: "Phidata"
description: "Integrate Composio with Phidata agents to let them seamlessly interact with external apps"
title: "Using Composio With Agno"
sidebarTitle: "Agno"
description: "Integrate Composio with Agno agents to let them seamlessly interact with external apps"
---

## Star A Repository on Github
In this example, we will use Phidata Agent to star a repository on Github using Composio Tools
## Star A Repository on GitHub
In this example, we will use Agno Agent to star a repository on GitHub using Composio Tools

<Steps>
<Step title="Install Packages">
```bash Python
pip install composio-phidata
pip install composio-agno openai
```
</Step>
<Step title="Import Libraries & Initialize ComposioToolSet & LLM">
```python Python
from phi.assistant import Assistant
from composio_phidata import Action, App, ComposioToolSet
from agno.agent.agent import Agent
from composio_agno import Action, App, ComposioToolSet

toolset = ComposioToolSet()
```
Expand All @@ -39,20 +39,20 @@ Don't forget to set your `COMPOSIO_API_KEY` and `OPENAI_API_KEY` in your environ
</Tip>
</Step>

<Step title="Get All Github Tools">
<Step title="Get All GitHub Tools">
You can get all the tools for a given app as shown below, but you can get **specific actions** and filter actions using **usecase** & **tags**. Learn more [here](../../patterns/tools/use-tools/use-specific-actions)
```python Python
composio_tools = toolset.get_tools(apps=[App.GITHUB])
tools = toolset.get_tools(apps=[App.GITHUB])
```
</Step>
<Step title="Define the Assistant">
```python Python
assistant = Assistant(tools=composio_tools, show_tool_calls=True)
agent = Agent(tools=tools, show_tool_calls=True)
```
</Step>
<Step title="Execute the Agent">
```python Python
assistant.print_response("Can you star composiohq/composio repo?")
agent.print_response("Can you star ComposioHQ/composio repo?")
```
</Step>
</Steps>
66 changes: 66 additions & 0 deletions docs/framework/gemini.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: "Using Composio With Gemini"
sidebarTitle: "Gemini"
description: "Integrate Composio with Gemini to let them seamlessly interact with external Apps"
---

## Star A Repository on GitHub
In this example, we will use Gemini to star a repository on GitHub using Composio Tools

<Steps>
<Step title="Install Packages">
```bash Python
pip install composio-gemini
```
</Step>
<Step title="Import Libraries & Initialize ComposioToolSet & Gemini">
```bash Python
from google.genai import types
from google import genai
from composio_gemini import Action, ComposioToolSet, App

client = genai.Client(api_key="<gemini-api-key>")
toolset = ComposioToolSet(api_key="<composio-api-key>")
```
</Step>
<Step title="Connect Your GitHub Account">
<Info>You need to have an active GitHub Integration. Learn how to do this [here](https://youtu.be/LmyWy4LiedQ?si=u5uFArlNL0tew0Wf)</Info>
<CodeGroup>
```shell CLI
composio login
composio add github
```
```python Python
request = toolset.initiate_connection(app=App.GITHUB)
print(f"Open this URL to authenticate: {request.redirectUrl}")
```
</CodeGroup>
<Tip>
Don't forget to set your `COMPOSIO_API_KEY` and `GEMINI_API_KEY` in your environment variables.
</Tip>
</Step>

<Step title="Get All GitHub Tools & Create Config">
You can get all the tools for a given app or specific actions as shown below. Learn more [here](../../patterns/tools/use-tools/use-specific-actions)
```python Python
tools = toolset.get_tools(
apps=[
App.GITHUB
]
)

config = types.GenerateContentConfig(tools=tools)
```
</Step>
<Step title="Execute the Agent">
```python Python
chat = client.chats.create(model="gemini-2.0-flash", config=config)

response = chat.send_message(
"Can you star composiohq/composio repository on github",
)

print(response.text)
```
</Step>
</Steps>
2 changes: 1 addition & 1 deletion docs/framework/groq.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "🦜🔗 Using Composio With Groq"
title: "Using Composio With Groq"
sidebarTitle: "Groq"
description: "Integrate Composio with Groq to seamlessly interact with external apps"
---
Expand Down
125 changes: 125 additions & 0 deletions docs/framework/ibm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
title: "Using Composio With IBM"
sidebarTitle: "IBM"
description: "Integrate Composio with IBM's Granite Models to let them seamlessly interact with external apps"
---

**Composio enables** **IBM's Granite Models** to **connect** with many **tools**!

<Tip>Goal: Star a repository on GitHub with natural language</Tip>

## Video Guide
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/d3-UIp1MOXg?si=qLxkmst9cg-_Lkqb"
title="YouTube video player"
frameborder="0"
allow="accelerometer;
autoplay;
clipboard-write;
encrypted-media;
gyroscope;
picture-in-picture;
web-share"
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen>
</iframe>

### Install Packages & Connect a Tool

Ensure you have the necessary packages installed and connect your GitHub account to allow your IBM agents to utilize GitHub functionalities.
<CodeGroup>
``` bash Run command
pip install composio-langchain
pip install langchain-ibm

# Connect your GitHub so agents can use it.
composio add github
# Check all different apps which you can connect with
composio apps
```
</CodeGroup>

### Goal: Prepare your environment by initializing necessary imports from Composio & IBM.

<Steps>
<Step title="Import Base Packages">

Prepare your environment by initializing necessary imports from Composio & IBM.

<CodeGroup>
```python Default Imports
from composio_langchain import ComposioToolSet, Action
from langchain_ibm import ChatWatsonx
import os

os.environ['WATSONX_API_KEY'] = '<ibm_api_key>' #add your ibm api key here
if not os.environ.get('WATSONX_API_KEY'):
raise ValueError("WATSONX_API_KEY environment variable is not set")
```

</CodeGroup>

</Step>

<Step title="Integrating GitHub Tools with Composio">

This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for Agent operations.

<CodeGroup>
```python IBM Supported tools from Composio
composio_toolset = ComposioToolSet()
tools = composio_toolset.get_tools(
actions=[Action.GITHUB_ACTIVITY_STAR_REPO_FOR_AUTHENTICATED_USER]
)
```
</CodeGroup>

</Step>

<Step title="IBM Agent Setup">

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

<CodeGroup>
```python IBM Agent Setup
parameters = {
"decoding_method": "sample",
"max_new_tokens": 100,
"min_new_tokens": 1,
"temperature": 0.5,
"top_k": 50,
"top_p": 1,
}
url = input('Add your IBM Cloud URL here: ')
project_id = input('Add your IBM Project ID here: ')
watsonx_llm = ChatWatsonx(
model_id = 'ibm/granite-3-8b-instruct',
url = url,
project_id = project_id,
)

if not url or not project_id:
raise ValueError("IBM Cloud URL and Project ID must be provided")

llm_with_tools = watsonx_llm.bind_tools(tools)


```
</CodeGroup>

</Step>

<Step title="Execute with your prompt/task.">

Execute the following code to execute the agent, ensuring that the intended task has been successfully completed.

<CodeGroup>
```python Agent Execution
response = llm_with_tools.invoke("Star the composiohq/composio repository")
print(response)
```
</CodeGroup>

</Step>
</Steps>
4 changes: 3 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"pages": [
"framework/autogen",
"framework/crewai",
"framework/gemini",
"framework/langchain",
"framework/langflow",
"framework/langgraph",
Expand All @@ -154,7 +155,8 @@
"framework/phidata",
"framework/praisonai",
"javascript/vercel",
"framework/google"
"framework/google",
"framework/ibm"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion python/composio/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.0"
__version__ = "0.7.1"
6 changes: 3 additions & 3 deletions python/composio/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import requests

from composio.client.collections import (
AUTH_SCHEMES,
AUTH_SCHEME_WITH_INITIATE,
Actions,
ActiveTriggerModel,
ActiveTriggers,
Expand Down Expand Up @@ -446,9 +446,9 @@ def initiate_connection(
app = self.client.apps.get(name=app_name_str)
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
if integration is None and auth_mode is not None:
if auth_mode not in AUTH_SCHEMES:
if auth_mode not in AUTH_SCHEME_WITH_INITIATE:
raise ComposioClientError(
f"'auth_mode' should be one of {AUTH_SCHEMES}"
f"'auth_mode' should be one of {AUTH_SCHEME_WITH_INITIATE}"
)
auth_mode = t.cast(AuthSchemeType, auth_mode)
if "OAUTH" not in auth_mode:
Expand Down
3 changes: 2 additions & 1 deletion python/composio/client/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
if t.TYPE_CHECKING:
from composio.client import Composio

AUTH_SCHEMES = ("OAUTH2", "OAUTH1", "API_KEY", "BASIC", "BEARER_TOKEN")
ALL_AUTH_SCHEMES = ("OAUTH2", "OAUTH1", "API_KEY", "BASIC", "BEARER_TOKEN", "NO_AUTH")
AUTH_SCHEME_WITH_INITIATE = ("OAUTH2", "OAUTH1", "API_KEY", "BASIC", "BEARER_TOKEN")
AuthSchemeType = t.Literal[
"OAUTH2", "OAUTH1", "API_KEY", "BASIC", "BEARER_TOKEN", "BASIC_WITH_JWT", "NO_AUTH"
]
Expand Down
24 changes: 20 additions & 4 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
from composio import Action, ActionType, App, AppType, TagType
from composio.client import Composio, Entity
from composio.client.collections import (
AUTH_SCHEMES,
ALL_AUTH_SCHEMES,
AUTH_SCHEME_WITH_INITIATE,
ActionModel,
ActiveTriggerModel,
AppAuthScheme,
Expand Down Expand Up @@ -1111,7 +1112,7 @@ def get_auth_scheme_for_app(
if auth_scheme is not None:
return auth_schemes[auth_scheme]

for scheme in AUTH_SCHEMES:
for scheme in ALL_AUTH_SCHEMES:
if scheme in auth_schemes:
scheme = t.cast(AuthSchemeType, scheme)
return auth_schemes[scheme]
Expand Down Expand Up @@ -1273,6 +1274,12 @@ def create_integration(
force_new_integration=force_new_integration,
)

def _validate_no_auth_scheme(self, auth_scheme):
if auth_scheme == "NO_AUTH":
raise ComposioSDKError(
"'NO_AUTH' does not require initiating a connection. Please use the `execute_action` method directly to execute actions for this app."
)

def initiate_connection(
self,
integration_id: t.Optional[str] = None,
Expand All @@ -1296,8 +1303,11 @@ def initiate_connection(
:param auth_scheme: (Optional[AuthSchemeType]): Authentication scheme to use
:return: (ConnectionRequestModel) Details of the connection request.
"""
if auth_scheme is not None and auth_scheme not in AUTH_SCHEMES:
raise ComposioSDKError(f"'auth_scheme' must be one of {AUTH_SCHEMES}")
if auth_scheme is not None and auth_scheme not in AUTH_SCHEME_WITH_INITIATE:
self._validate_no_auth_scheme(auth_scheme)
raise ComposioSDKError(
f"'auth_scheme' must be one of {AUTH_SCHEME_WITH_INITIATE}"
)

if integration_id is None:
if app is None:
Expand All @@ -1308,6 +1318,12 @@ def initiate_connection(
if auth_scheme is None:
auth_scheme = self.get_auth_scheme_for_app(app).auth_mode

if auth_scheme is not None and auth_scheme not in AUTH_SCHEME_WITH_INITIATE:
self._validate_no_auth_scheme(auth_scheme)
raise ComposioSDKError(
f"'auth_scheme' must be one of {AUTH_SCHEME_WITH_INITIATE}"
)

try:
integration_id = self._get_integration_for_app(
app=t.cast(
Expand Down
2 changes: 1 addition & 1 deletion python/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN /bin/python3 -m venv .composio/venv
RUN export PATH=$PATH:$(pwd)/.composio/venv/bin

# Install composio
RUN python -m pip install composio-core[all]==0.7.0 fastapi playwright uvicorn
RUN python -m pip install composio-core[all]==0.7.1 fastapi playwright uvicorn

# Install playwright deps
RUN playwright install-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Now, fill in the `.env` file with your secrets.

### 2. Run the Python Script
```shell
python cookbook/python-examples/advanced_agents/deepseek_research/main.py
python cookbook/python-examples/advanced_agents/domain_deep_research/main.py
```

Loading

0 comments on commit edd51bc

Please sign in to comment.