Tool Type Generator
This is a bit of a checky tutorial as it is dogfooding the docs
tool generation process.
To motivate this example clearly, in our tools section — we have details about let’s say Github
tool, that shows its auth scheme, actions and their params.
Now why would anyone outside of Composio want to do this? Well if you are building a platform on top of Composio, perchance a Workflow builder like langflow. You would want to show some or all of this information to your users.
This is a non standard use case, that we support and love users building on top of us but if this is uninteresting to you, you can skip this tutorial.
How does one build a tool type generator?
In composio, we have two internal states for tools
- Raw tool definition
- Provider tool definition
The raw tool definition is an generic input output schema definition that we internally for tools, we expose it for customers if they want to build on top of it but it is not the primary way tools are normally used.
The provider tool definition, translates this raw tool definition to the specific schema of a provider (by default openai
).
For building something like this, we need to use the raw tool definition.
Getting the raw tool definition
Of course, you need to initiate the Composio
sdk first and use a COMPOSIO_API_KEY
environment variable.
Let us see an example output for a raw GMAIL
toolkit, with all of its tools.
this is just a taste but you can see the full output here.
There is a bunch of useful information here, around the input_parameters
and output_parameters
for this example but scopes
is very valuable to know what permissions are required for this tool.
Now from these input_parameters
and output_parameters
you can showcase the tool definitions.
There is a bunch of other processing things happening here that are super generally relevant, so not going to call them out here that said there is another thing i want to showcase
Toolkit Information
Toolkis are what we call apps or integrations, for us they are a collection of tools. GMAIL
has GMAIL_SEND_EMAIL
as a tool.
Now for building something out like this, you might also want information about the toolkit itself.
A toolkit has information like categories
or auth_schemes
auth_schemes
here are OAUTH2
, API_KEY
or BASIC_AUTH
, etc — essentially the types of how one could authenticate with the toolkit.
Here is a way to parse the auth_scheme
data
these are tuple
objects as they have different schema for specific conditions like auth_config_creation
or connected_account_initiation
they also have required
and optional
fields.
the context here is there are some fields you need while creating an auth config and some you need while connecting an account. this separation is done by the tuple
here
This is a fairly minimal explanation for the amount of code, as most of it is not super related to composio but it will be a good example on seeing behind the scenes of how composio is working and how to leverage the platform further.