跳到主要内容

OpenAPI

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.

Options of openapi code generator
Usage: easy-llm-tools openapi [-hV] [--validate-spec]
[--artifact-id=<artifactId>]
[--artifact-version=<artifactVersion>]
[--group-id=<groupId>] [--output=<outputDir>]
[--package-name=<packageName>]
[--parent-artifact-id=<parentArtifactId>]
[--parent-artifact-version=<parentArtifactVersion>
] [--parent-group-id=<parentGroupId>] <inputSpec>
Generate LLM tools from OpenAPI spec
<inputSpec>
--artifact-id=<artifactId>
Artifact id
--artifact-version=<artifactVersion>
Artifact version
--group-id=<groupId> Group id
-h, --help Show this help message and exit.
--output=<outputDir> Output directory
--package-name=<packageName>
Package name
--parent-artifact-id=<parentArtifactId>
Parent artifact id
--parent-artifact-version=<parentArtifactVersion>
Parent artifact version
--parent-group-id=<parentGroupId>
Parent group id
-V, --version Print version information and exit.
--validate-spec Should the spec be validated

Source code can be generated using CLI. Below are some examples.

Examples

Canada Holidays

信息

This is an example of using public APIs without authentication.

The Canada Holidays API lists all 30 public holidays for all 13 provinces and territories in Canada, including federal holidays.

Source code can be generated using the following command.

Generate code
java -jar code-generator-cli.jar openapi \
--output=target/canada-holidays \
--artifact-id=canada-holidays --artifact-version=0.1.0 \
--package-name=com.javaaidev.easyllmtools.tools.canadaholidays \
canada-holidays.openapi.json

Generated source code is a Maven project. Install this project to use this tool.

Install Maven project
mvn -B -ntp -f target/canada-holidays/pom.xml install

NYTimes Top Stories

信息

This is an example of using public APIs using API keys.

The Top Stories API provides lists of articles and associated images by section.

Source code can be generated using the following command.

Generate code
java -jar target/code-generator-cli.jar openapi \
--output=target/nytimes \
--artifact-id=nytimes --artifact-version=0.1.0 \
--package-name=com.javaaidev.easyllmtools.tools.nytimes \
nytimes-top_stories.json

Generated source code is a Maven project. Install this project to use this tool.

Install Maven project
mvn -B -ntp -f target/nytimes/pom.xml install