Simple
Simple code generator generates code for a tool from its spec.
Below is the spec of a tool to get weather by location. This tool has a single parameter location
representing the location to get weather.
Spec of get weather tool
{
"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"]
}
}
}
}
By using the command line tool, we can generate source code for this tool.
Use CLI to generate source code
java -jar code-generator-cli.jar simple \
--output=tool-get-weather-fake \
--artifact-id=get-weather --artifact-version=0.1.0 \
--package-name=com.javaaidev.easyllmtools.tools.getweather \
get-weather.json
The generated source code can be found at here.