## 🚀🔗 Leveraging OpenAI with Composio
Facilitate the integration of OpenAI with Composio to empower OpenAI models to directly interact with external applications, broadening their capabilities and application scope.
### Objective
- **Automate starring a GitHub repository** using conversational instructions via OpenAI Function Calls.
### 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-openai
# Connect your GitHub account
composio-cli add github
# View available applications you can connect with
composio-cli show-apps
```
### Usage Steps
#### 1. Import Base Packages
Prepare your environment by initializing necessary imports from OpenAI and setting up your client.
```python
from openai import OpenAI
# Initialize OpenAI client
openai_client = OpenAI()
```
### 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_openai import App, ComposioToolSet
toolset = ComposioToolSet()
actions = toolset.get_tools(apps=[App.GITHUB])
```
### Step 3: Agent Execution
This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
```python
my_task = "Star a repo composiohq/composio on GitHub"
# Create a chat completion request to decide on the action
response = openai_client.chat.completions.create(model="gpt-4-turbo-preview",
tools=actions, # Passing actions we fetched earlier.
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": my_task}
]
)
pprint(response)
```
### Step 4: Validate Execution Response
Execute the following code to validate the response, ensuring that the intended task has been successfully completed.
```python
result = toolset.handle_tool_calls(response)
pprint(result)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ComposioHQ/composio",
"name": "composio-openai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Sawradip",
"author_email": "sawradip@composio.dev",
"download_url": "https://files.pythonhosted.org/packages/4b/c4/fcf239f263963f95d285684af39f63df20d7f8173ac884ca69239d6cc52b/composio_openai-0.6.19.tar.gz",
"platform": null,
"description": "## \ud83d\ude80\ud83d\udd17 Leveraging OpenAI with Composio\n\nFacilitate the integration of OpenAI with Composio to empower OpenAI models to directly interact with external applications, broadening their capabilities and application scope.\n\n### Objective\n\n- **Automate starring a GitHub repository** using conversational instructions via OpenAI Function Calls.\n\n### Installation and Setup\n\nEnsure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.\n\n```bash\n# Install Composio LangChain package\npip install composio-openai\n\n# Connect your GitHub account\ncomposio-cli add github\n\n# View available applications you can connect with\ncomposio-cli show-apps\n```\n\n### Usage Steps\n\n#### 1. Import Base Packages\n\nPrepare your environment by initializing necessary imports from OpenAI and setting up your client.\n\n```python\nfrom openai import OpenAI\n\n# Initialize OpenAI client\nopenai_client = OpenAI()\n```\n\n### Step 2: Integrating GitHub Tools with Composio\n\nThis step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for LangChain operations.\n```python\nfrom composio_openai import App, ComposioToolSet\n\ntoolset = ComposioToolSet()\nactions = toolset.get_tools(apps=[App.GITHUB])\n```\n\n### Step 3: Agent Execution\n\nThis step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.\n\n```python\nmy_task = \"Star a repo composiohq/composio on GitHub\"\n\n# Create a chat completion request to decide on the action\nresponse = openai_client.chat.completions.create(model=\"gpt-4-turbo-preview\",\n tools=actions, # Passing actions we fetched earlier.\n messages=[\n {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": my_task}\n ]\n )\n\npprint(response)\n```\n\n### Step 4: Validate Execution Response\n\nExecute the following code to validate the response, ensuring that the intended task has been successfully completed.\n\n```python\nresult = toolset.handle_tool_calls(response)\npprint(result)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Use Composio to get an array of tools with your OpenAI Function Call.",
"version": "0.6.19",
"project_urls": {
"Homepage": "https://github.com/ComposioHQ/composio"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2542bf2c5d6960558cd3c61456684b86de8bc015ed41e9c11a814e37780aa2cf",
"md5": "81d0c95b351019216fa004b27214d3ed",
"sha256": "d527ed5d930db2081761ab1f2f1fd6c88e69f849398bb9913345345e9c561e56"
},
"downloads": -1,
"filename": "composio_openai-0.6.19-py3-none-any.whl",
"has_sig": false,
"md5_digest": "81d0c95b351019216fa004b27214d3ed",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 5065,
"upload_time": "2025-01-28T19:25:36",
"upload_time_iso_8601": "2025-01-28T19:25:36.417456Z",
"url": "https://files.pythonhosted.org/packages/25/42/bf2c5d6960558cd3c61456684b86de8bc015ed41e9c11a814e37780aa2cf/composio_openai-0.6.19-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4bc4fcf239f263963f95d285684af39f63df20d7f8173ac884ca69239d6cc52b",
"md5": "023bc5c6ab2abb934b4ae466ac82d0ad",
"sha256": "9598d3751862d734e87f807c0d2ba8408df1d7601f7647a1d2c34214c6173b3a"
},
"downloads": -1,
"filename": "composio_openai-0.6.19.tar.gz",
"has_sig": false,
"md5_digest": "023bc5c6ab2abb934b4ae466ac82d0ad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 4608,
"upload_time": "2025-01-28T19:25:54",
"upload_time_iso_8601": "2025-01-28T19:25:54.314023Z",
"url": "https://files.pythonhosted.org/packages/4b/c4/fcf239f263963f95d285684af39f63df20d7f8173ac884ca69239d6cc52b/composio_openai-0.6.19.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-28 19:25:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ComposioHQ",
"github_project": "composio",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "composio-openai"
}