## 🚀🔗 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": "Composio",
"author_email": "Composio <tech@composio.dev>",
"download_url": "https://files.pythonhosted.org/packages/9b/c2/513981169360af01ab215991675c89c2f354a1810a1151431a2f76d7b1ec/composio_openai-0.8.10.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.8.10",
"project_urls": {
"Homepage": "https://github.com/ComposioHQ/composio"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "794bd05e3bf4633e191444af381259d169b724e5063f572dbbc79f70d595e03b",
"md5": "bf714d5ccedf6b8c9014510bb4ce6cec",
"sha256": "95d1acd75f8457238f7185fa601ab005b744689ae5a2454880785d21e19414d3"
},
"downloads": -1,
"filename": "composio_openai-0.8.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf714d5ccedf6b8c9014510bb4ce6cec",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 2965,
"upload_time": "2025-09-15T10:22:33",
"upload_time_iso_8601": "2025-09-15T10:22:33.573231Z",
"url": "https://files.pythonhosted.org/packages/79/4b/d05e3bf4633e191444af381259d169b724e5063f572dbbc79f70d595e03b/composio_openai-0.8.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9bc2513981169360af01ab215991675c89c2f354a1810a1151431a2f76d7b1ec",
"md5": "605204e7a9ba1f758afc9f199fc1d3f0",
"sha256": "944302b7eb7786103df5d9ab7612261dc155ed5b1c85a48add259de0216583ed"
},
"downloads": -1,
"filename": "composio_openai-0.8.10.tar.gz",
"has_sig": false,
"md5_digest": "605204e7a9ba1f758afc9f199fc1d3f0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 2713,
"upload_time": "2025-09-15T10:22:41",
"upload_time_iso_8601": "2025-09-15T10:22:41.703342Z",
"url": "https://files.pythonhosted.org/packages/9b/c2/513981169360af01ab215991675c89c2f354a1810a1151431a2f76d7b1ec/composio_openai-0.8.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-15 10:22:41",
"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"
}