Fetching tools

While you can find and specify tools from the dashboard, Composio also offers programmatic methods to retrieve tools for your LLM applications. This gives you greater flexibility when building dynamic systems.

Specifying apps and tags

You can also retrieve tools by specifying apps and tags, allowing for more targeted tool selection based on your specific needs. This approach helps you filter the available tools to only those relevant to your application.

1from composio_openai import ComposioToolSet, Action, App
2toolset = ComposioToolSet()
3
4tools = toolset.get_tools(
5 apps=[App.JIRA],
6 tags=["Issues"]
7)

When working with tools from specific apps, consider the number of tools from specific apps loaded into your LLMs context window.

When fetching by specifying the App, the Toolset returns only the tools with an important tag and not all the tools!

Use-case search (experimental)

Finding tools based on what you’re trying to accomplish is often the most intuitive approach.

1from composio_openai import ComposioToolSet
2
3toolset = ComposioToolSet()
4query = "make a notion page"
5
6actions = toolset.find_actions_by_use_case(
7 use_case=query,
8 # advanced=True, # Enable this for complex queries requiring multiple tools
9)
Use the advanced flag when you need to retrieve multiple tools to use together in a chain

Using tools directly

It’s possible to use custom logic to execute the tools instead of relying on handle_tool_calls. The params parameter expects all the valid parameters for the tool you want to execute.

You can view the valid parameters for a tool from the dashboard!
1from openai import OpenAI
2from composio_openai import ComposioToolSet, App, Action
3
4toolset = ComposioToolSet()
5toolset.execute_action(action=Action.GOOGLECALENDAR_LIST_CALENDARS, params={})

Using custom auth

If you wish to manage your own authentication from another provider you can add the auth parameters for any app as well!

1from composio import ComposioToolSet, App
2
3toolset = ComposioToolSet()
4
5toolset.add_auth(
6 app=App.GITHUB,
7 parameters=[
8 dict(
9 name="Authorization",
10 in_="header",
11 value="Bearer gho_",
12 )
13 ],
14)
15
16toolset.execute_action(
17 action="GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER",
18 params={"owner": "composiohq", "repo": "composio"},
19)

Inspect Tool Schemas (Researchers!)

You might want to inspect the tool schemas of your custom tools or Composio tools during experimentation. By setting check_connected_accounts to False you can bypass the authentication check in place for ensuring safe execution of tools!

1from composio import ComposioToolSet, App
2
3toolset = ComposioToolSet()
4
5toolset.get_action_schemas(
6 actions=[Action.GOOGLECALENDAR_LIST_CALENDARS], check_connected_accounts=False
7)
Built with