Easy LLM Tools is a set of tools to create tools used by LLMs, primarily for Java and Spring AI. It consists of three parts:
Tools play an important role in building AI applications, especially for agents. Agents use tools to access external information and perform actions.
Tools are not hard to create. Different AI frameworks and libraries have their own ways to create tools. These frameworks and tools usually take a code-first approach. Tools are directly built using code.
Easy LLM Tools takes a spec-first approach. For each tool, its spec should be create first. By creating tool specs, we can enable advanced usage scenarios of tools:
Tool spec describes tools used by LLM.
The tool spec is a JSON schema file. The spec defines the definition of a tool and the configuration required to create this tool.
Below is the spec of a tool to get weather by location. This tool has one parameter location
to specify the location. Its configuration has one property temperatureUnit
to configure the unit of temperature.
{ "definition": { "name": "Get weather", "description": "Get weather by location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "Location" } } }, "returnType": { "type": "object", "properties": { "condition": { "type": "string", "description": "Weather condition" }, "temperature": { "type": "number", "description": "Temperature" }, "temperatureUnit": { "type": "string", "description": "Unit of temperature", "enum": ["C", "F"] } } }, "examples": [ { "description": "Get weather of New York", "parameters": { "location": "New York" }, "returnValue": { "condition": "Sunny", "temperature": 28, "temperatureUnit": "C" } } ] }, "configuration": { "type": "object", "properties": { "temperatureUnit": { "type": "string", "description": "Unit of temperature", "enum": ["C", "F"] } } } }
Easy LLM Tools has a command line tool to generate source code for tools. It currently supports two types of code generators.
simple
: Generate code from a tool specopenapi
: Generate code from a OpenAPI spec.Generated source code contains the model classes for parameters, return type and configuration. After the code is generated, we only need to implement the logic in the Tool
interface.
For the tool spec mentioned above, the code generator creates the following files.
. ├── AbstractGetWeather.java ├── GetWeather.java ├── GetWeatherFactory.java └── model ├── GetWeatherConfiguration.java ├── GetWeatherParameters.java └── GetWeatherReturnType.java
We only need to implement the GetWeather
class.
OpenAPI code generator generates LLM tools from OpenAPI specs. The whole OpenAPI spec is converted to a toolkit. Each operation is the OpenAPI spec is converted to a tool in this toolkit. Information of a tool is extracted from the OpenAPI spec.
See the video below for a demo.
Source code can be found on GitHub
There are no models linked
There are no models linked
There are no datasets linked
There are no datasets linked