# Composio <> CrewAI
![CrewAI Logo](https://i.imgur.com/jXeNUda.png)
**Composio** enables **CrewAI agents** to connect with numerous tools, making it easy for these agents to interact with external applications seamlessly.
## Installation and Setup
Start by installing Composio CrewAI and connecting your GitHub account to enable GitHub functionalities for your agents.
```bash
pip install composio_crewai
composio-cli add github # Connect your GitHub account
composio-cli show-apps # Check available applications
```
## Goal
Automate GitHub interactions, such as starring a repository, using natural language commands through a CrewAI Agent.
### Step-by-Step Guide
#### 1. Import Base Packages
Prepare your environment by importing the necessary packages for CrewAI and setting up your language model.
```python
from crewai import Agent, Task
from langchain_openai import ChatOpenAI
# Initialize the language model with your OpenAI API key
llm = ChatOpenAI(openai_api_key="sk-<OPENAI KEY>")
```
#### 2. Fetch Tools via Composio
Initialize the Composio toolset for interacting with GitHub.
```python
from composio_crewai import ComposioToolSet, Action, App
# Initialize the toolset with GitHub application
tools = ComposioToolSet(apps=[App.GITHUB])
```
#### 3. Execute the Agent
Configure and execute the CrewAI agent to perform GitHub actions.
```python
crewai_agent = Agent(
role='Github Agent',
goal="You take action on Github using Github APIs",
backstory="You are an AI agent responsible for taking actions on Github on users' behalf using Github APIs",
verbose=True,
tools=tools,
llm=llm
)
# Define the task
task = Task(
description="Star a repo composiohq/composio on GitHub",
agent=crewai_agent,
expected_output="if the star happened"
)
# Execute the task
task.execute()
```
#### 4. Check Response
Verify the agent's actions and responses to ensure the task was completed successfully.
```bash
> Entering new CrewAgentExecutor chain...
> I need to star the repository "composiohq/composio" on GitHub.
> {'execution_details': {'executed': True}, 'response_data': ''}
> Finished chain.
```
### Advanced Configuration
- **Filter Specific Actions:** Limit the actions an agent can perform for enhanced security and operational focus.
```python
toolsGithubCreateIssue = ComposioToolSet(actions=[Action.GITHUB_CREATE_ISSUE])
```
- **Filter Specific Apps:** Restrict the agent's access to certain applications for streamlined operations.
```python
toolsAsanaGithub = ComposioToolSet(apps=[App.ASANA, App.GITHUB])
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ComposioHQ/composio",
"name": "composio-crewai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Himanshu",
"author_email": "himanshu@composio.dev",
"download_url": "https://files.pythonhosted.org/packages/08/a9/91e856a8ea93c8e8369fcaf2a51e3c65151cd7016e4c7c18d32c54f014f7/composio_crewai-0.5.42.tar.gz",
"platform": null,
"description": "# Composio <> CrewAI\n\n![CrewAI Logo](https://i.imgur.com/jXeNUda.png)\n\n**Composio** enables **CrewAI agents** to connect with numerous tools, making it easy for these agents to interact with external applications seamlessly.\n\n## Installation and Setup\n\nStart by installing Composio CrewAI and connecting your GitHub account to enable GitHub functionalities for your agents.\n\n```bash\npip install composio_crewai\ncomposio-cli add github # Connect your GitHub account\ncomposio-cli show-apps # Check available applications\n```\n\n## Goal\n\nAutomate GitHub interactions, such as starring a repository, using natural language commands through a CrewAI Agent.\n\n### Step-by-Step Guide\n\n#### 1. Import Base Packages\n\nPrepare your environment by importing the necessary packages for CrewAI and setting up your language model.\n\n```python\nfrom crewai import Agent, Task\nfrom langchain_openai import ChatOpenAI\n\n# Initialize the language model with your OpenAI API key\nllm = ChatOpenAI(openai_api_key=\"sk-<OPENAI KEY>\")\n```\n\n#### 2. Fetch Tools via Composio\n\nInitialize the Composio toolset for interacting with GitHub.\n\n```python\nfrom composio_crewai import ComposioToolSet, Action, App\n\n# Initialize the toolset with GitHub application\ntools = ComposioToolSet(apps=[App.GITHUB])\n```\n\n#### 3. Execute the Agent\n\nConfigure and execute the CrewAI agent to perform GitHub actions.\n\n```python\ncrewai_agent = Agent(\n role='Github Agent',\n goal=\"You take action on Github using Github APIs\",\n backstory=\"You are an AI agent responsible for taking actions on Github on users' behalf using Github APIs\",\n verbose=True,\n tools=tools,\n llm=llm\n)\n\n# Define the task\ntask = Task(\n description=\"Star a repo composiohq/composio on GitHub\",\n agent=crewai_agent,\n expected_output=\"if the star happened\"\n)\n\n# Execute the task\ntask.execute()\n```\n\n#### 4. Check Response\n\nVerify the agent's actions and responses to ensure the task was completed successfully.\n\n```bash\n> Entering new CrewAgentExecutor chain...\n> I need to star the repository \"composiohq/composio\" on GitHub.\n> {'execution_details': {'executed': True}, 'response_data': ''}\n> Finished chain.\n```\n\n### Advanced Configuration\n\n- **Filter Specific Actions:** Limit the actions an agent can perform for enhanced security and operational focus.\n\n```python\ntoolsGithubCreateIssue = ComposioToolSet(actions=[Action.GITHUB_CREATE_ISSUE])\n```\n\n- **Filter Specific Apps:** Restrict the agent's access to certain applications for streamlined operations.\n\n```python\ntoolsAsanaGithub = ComposioToolSet(apps=[App.ASANA, App.GITHUB])\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Use Composio to get an array of tools with your CrewAI agent.",
"version": "0.5.42",
"project_urls": {
"Homepage": "https://github.com/ComposioHQ/composio"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e349cc193d4b6c4e7869d30db683770b7327901780beedbe4d7776355dbe5bc0",
"md5": "8cff877370ecc2010ce7d4953bf92416",
"sha256": "7185fd5816c512324419ffa467bb202488ae3b168aa98e31ea6c65183de69b33"
},
"downloads": -1,
"filename": "composio_crewai-0.5.42-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8cff877370ecc2010ce7d4953bf92416",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 4707,
"upload_time": "2024-11-14T07:23:50",
"upload_time_iso_8601": "2024-11-14T07:23:50.759459Z",
"url": "https://files.pythonhosted.org/packages/e3/49/cc193d4b6c4e7869d30db683770b7327901780beedbe4d7776355dbe5bc0/composio_crewai-0.5.42-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "08a991e856a8ea93c8e8369fcaf2a51e3c65151cd7016e4c7c18d32c54f014f7",
"md5": "53e6e5583b901cd22667b609ea47ecae",
"sha256": "b980b31bd737e7865e83beeda29e6695411bc4df710e6f51a7586a95871a8137"
},
"downloads": -1,
"filename": "composio_crewai-0.5.42.tar.gz",
"has_sig": false,
"md5_digest": "53e6e5583b901cd22667b609ea47ecae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 4271,
"upload_time": "2024-11-14T07:23:51",
"upload_time_iso_8601": "2024-11-14T07:23:51.726286Z",
"url": "https://files.pythonhosted.org/packages/08/a9/91e856a8ea93c8e8369fcaf2a51e3c65151cd7016e4c7c18d32c54f014f7/composio_crewai-0.5.42.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-14 07:23:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ComposioHQ",
"github_project": "composio",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "composio-crewai"
}