Using Tools Directly

Composio allows you to execute tools directly as function calls. When calling a tool directly, you’ll need to provide the input parameters. Checkout Get Action Schema to learn how to get the input parameters for an action.

Install packages:

pip install composio-core

Using tools directly:

from composio import ComposioToolSet, Action

tool_set = ComposioToolSet(entity_id="Jessica")

tool_set.execute_action(
   action=Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER,
   params={"owner": "composiohq", "repo": "composio"},
   entity_id="Jessica",
)

Execute Tools or Actions with Natural Language

You can also execute Tools or Actions by passing in natural language prompts without specific parameters

tool_set.execute_action(
    action=Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER,
    params={},
    # Natural language prompt
    text="Star the repo composiohq/composio",
    entity_id="Jessica",
)

How to execute custom actions directly?

You can execute custom actions directly by specifying the action name as shown below. Here create_draft is the custom action name. Learn more about custom actions here.

toolset.execute_action(
    action=create_draft,
    params={
        "thread_id": "",
        "message_body": "",
    },
    entity_id="Jessica",
)