Star A Repository on Github

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

1

Install Packages

pip install composio-llamaindex llama-index
2

Import Libraries & Initialize ComposioToolSet & LLM

from llama_index.llms.openai import OpenAI
from llama_index.core.llms import ChatMessage
from llama_index.core.agent import FunctionCallingAgentWorker
from composio_llamaindex import App, ComposioToolSet

toolset = ComposioToolSet()
llm = OpenAI()
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 = toolset.get_tools(apps=[App.GITHUB])
5

Define the Agent

prefix_messages = [
    ChatMessage(
        role="system",
        content=(
            "You are a Github Agent, and you can use tools to perform actions on Github."
        ),
    )
]

agent = FunctionCallingAgentWorker(
    tools=tools,
    llm=llm,
    prefix_messages=prefix_messages,
    max_function_calls=10,
    allow_parallel_tool_calls=False,
    verbose=True,
).as_agent()
6

Execute the Agent

result = agent.chat("Star a repo composiohq/composio on GitHub")