Star A Repository on Github

In this example, we will use OpenAI Assistant to star a repository on Github using Composio Tools

1

Install Packages

pip install composio-openai openai
2

Import Libraries & Initialize ComposioToolSet & LLM

from openai import OpenAI
from composio_openai import ComposioToolSet, Action

openai_client = OpenAI()
composio_toolset = ComposioToolSet()
3

Connect Your GitHub Account

You need to have an active GitHub Integration. Learn how to do this here
composio login
composio add github

Don’t forget to set your COMPOSIO_API_KEY and OPENAI_API_KEY in your environment variables.

4

Get All Github Tools

You can get all the tools for a given app as shown below, but you can get specific actions and filter actions using usecase & tags. Learn more here

tools = composio_toolset.get_tools(apps=[App.GITHUB])
5

Define the Assistant

assistant_instruction = "You are a super intelligent personal assistant"

assistant = openai_client.beta.assistants.create(
  name="Personal Assistant",
  instructions=assistant_instruction,
  model="gpt-4-turbo-preview",
  tools=tools,
)

thread = openai_client.beta.threads.create()
my_task = "Star a repo composiohq/composio on GitHub"
message = openai_client.beta.threads.messages.create(thread_id=thread.id,role="user",content=my_task)

run = openai_client.beta.threads.runs.create(thread_id=thread.id,assistant_id=assistant.id)

response_after_tool_calls = composio_toolset.wait_and_handle_assistant_tool_calls(
    client=openai_client,
    run=run,
    thread=thread,
)
6

Execute the Agent

print(response_after_tool_calls)