Goal: Star a repository on GitHub with natural language

1

Install Composio Package

pip install composio-core 
pip install composio_openai 
2

Authenticate your github account using CLI

composio-cli add github
3

Import python packages

Modify OPENAIKEY before executing it.

from openai import OpenAI
from composio_openai import ComposioToolset, App

openai_client = OpenAI(api_key="**\*\***OPENAIKEY**\*\***")

# Initialise the Composio Tool Set

composio_tools = ComposioToolset()

4

Fetch all Github actions via Composio

# Get GitHub tools that are pre-configured
actions = composio_tools.get_tools(tools=App.GITHUB)
5

Using Function Call

my_task = "Star a repo SamparkAI/composio_sdk on GitHub"

# Create a chat completion request to decide on the action
response = openai_client.chat.completions.create(
model="gpt-4-turbo",
tools=actions, # Passing actions we fetched earlier.
messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": my_task}
  ]
)
6

Handle Tool Calls - Execute Actions

# Execute Function calls
execution_details = composio_tools.handle_tool_calls(response)

print(execution_details)
print("Completed Task")

Putting it all together

Replace OPENAIKEY.

## Step 1
#!pip install composio-core
#!pip install composio_openai


## Step 2
#!composio-cli add github

## Step 3
from openai import OpenAI
from composio_openai import ComposioToolset, App

openai_client = OpenAI(api_key="******OPENAIKEY******")

# Initialise the Composio Tool Set
composio_tools = ComposioToolset()

## Step 4
# Get GitHub tools that are pre-configured
actions = composio_tools.get_tools(tools=App.GITHUB)


## Step 5
my_task = "Star a repo SamparkAI/composio_sdk on GitHub"

# Create a chat completion request to decide on the action
response = openai_client.chat.completions.create(
model="gpt-4-turbo",
tools=actions, # Passing actions we fetched earlier.
messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": my_task}
  ]
)


## Step 6
# Execute Function calls
execution_details = composio_tools.handle_tool_calls(response)

print(execution_details)

print("Completed Task")