python/providers/openai/README.md
Facilitate the integration of OpenAI with Composio to empower OpenAI models to directly interact with external applications, broadening their capabilities and application scope.
Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.
# 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
Prepare your environment by initializing necessary imports from OpenAI and setting up your client.
from openai import OpenAI
# Initialize OpenAI client
openai_client = OpenAI()
This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for LangChain operations.
from composio_openai import App, ComposioToolSet
toolset = ComposioToolSet()
actions = toolset.get_tools(apps=[App.GITHUB])
This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.
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-5",
tools=actions, # Passing actions we fetched earlier.
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": my_task}
]
)
pprint(response)
Execute the following code to validate the response, ensuring that the intended task has been successfully completed.
result = toolset.handle_tool_calls(response)
pprint(result)