A set of tools that allows you to easily call OpenAPI functions using an LLM. The library tools serve a few purposes:
-
OpenAPI Cleaning & Editing: OpenAPI spec are rarely ready to ingest into an LLM right away. This library provides an Editor class which provides convience methods to delete routes, rename routes, edit decriptions, and more. The editor ultimately produced a cleaned spec that is better for LLM ingestion.
-
OpenAPI to Function Calling (aka Tools): Convert a spec (preferably cleaned) into a set of functions that can be selected by a function calling LLM. The set generated follows the MCP Tool Definition structure for now. The tools generated follow this schema:
{
"name": "getPetById",
"description": "Retrieve a pet by its ID",
"inputSchema": {
"type": "object",
"properties": {
"petId": {
"type": "integer",
"description": "ID of the pet to retrieve"
}
},
"required": ["petId"]
}
}
- Invoker: The invoker class takes the same openapi spec. Using the
.invoke
method, it will take the list of tools generated by the LLM and call the appropriate function.
Ok so I really wish I didn't have to build this library, but the only alternative to this I found was the OpenAPI Agent toolkit from langchain which does not give you the cleaning flexibility & granularity of control of the functions that I wanted. Please let me know if there is a better alternative out there!