## 🚀🔗 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/bb/01/444b5ab4f6be3c45503b43783ea519e3f8bc9d9997b496f2d1d374b2fdf4/composio_openai-0.6.5.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.5",
"project_urls": {
"Homepage": "https://github.com/ComposioHQ/composio"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fd69ef8c6e62858643d0506b790e3cc0d30e7051438101af0ad259bd6c501808",
"md5": "1ee736cababef952344dd3c461289264",
"sha256": "4b26ce338fe1c5253c62bd59d9b3a83e3b9bcfefcb39deda85bcc42d1e109233"
},
"downloads": -1,
"filename": "composio_openai-0.6.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1ee736cababef952344dd3c461289264",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 4882,
"upload_time": "2024-12-20T10:48:17",
"upload_time_iso_8601": "2024-12-20T10:48:17.506087Z",
"url": "https://files.pythonhosted.org/packages/fd/69/ef8c6e62858643d0506b790e3cc0d30e7051438101af0ad259bd6c501808/composio_openai-0.6.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bb01444b5ab4f6be3c45503b43783ea519e3f8bc9d9997b496f2d1d374b2fdf4",
"md5": "36cc94817fd2816ce63d6451202791bf",
"sha256": "0bd5aa8d31c69c3461c0724016913877eb706a7e26d4c60d714310419865e622"
},
"downloads": -1,
"filename": "composio_openai-0.6.5.tar.gz",
"has_sig": false,
"md5_digest": "36cc94817fd2816ce63d6451202791bf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 4421,
"upload_time": "2024-12-20T10:48:19",
"upload_time_iso_8601": "2024-12-20T10:48:19.620415Z",
"url": "https://files.pythonhosted.org/packages/bb/01/444b5ab4f6be3c45503b43783ea519e3f8bc9d9997b496f2d1d374b2fdf4/composio_openai-0.6.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-20 10:48:19",
"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"
}