Skip to content

Conversation

@Siriussee
Copy link

This PR adds 2 adapters to existing db_load and allows users to ingest Java functions and Web APIs in OpenAPI JSON format into the vector database of NLWeb. Both adapters come with their own demos.

Get started

Please follow the README file.

Key features in this PR

OpenAPI JSON

Given a web API in OpenAPI JSON format, the new openapi_strategy.py adapter parses the API URL, HTTP method, parameters, return values, and description into APIReference @ schema.org. Example:

Input OpenAPI JSON

"/users/{username}": {
  "get": {
    "description": "...",
    "externalDocs": {
      "description": "API method documentation",
      "url": "https://docs.github.com/rest/reference/users#get-a-user"
    },
    "operationId": "users/get-by-username",
    "parameters": [
      {
        "$ref": "#/components/parameters/username"
      }
    ],
    "responses": {
      "200": {...},
      "404": {...}
    },
    "summary": "Get a user",
    "tags": [
      "users"
    ],
  }
}

Output

{
    "url": "../demo/verb_demo/github_com.json#getUser(String)",
    "name": "github_com.getUser",
    "site": "github_com",
    "schema_data": {...}
}

Java Function

Given a Java function interface, the new java_strategy.py adapter parses the function name, parameters, return values, and docs strings into APIReference @ schema.org. Example:

Input Java function

/**
 * Search for flights between origin and destination
 * @param origin Origin airport code
 * @param destination Destination airport code
 * @param outboundDate Outbound flight date
 * @param returnDate Return flight date
 * @return JsonObject containing flight information
 */
JsonObject searchFlights(String origin, String destination, String outboundDate, String returnDate);

Output

{
    "url": "../demo/verb_demo/alaskaair_com.java#searchFlights(String, String, String, String)",
    "name": "alaskaair_com.searchFlights",
    "site": "alaskaair_com",
    "schema_data": {...}
}

demo files

All demo files are available at demo/verb_demo.

CLI

We also add a cli-app.py for users to interact with NLWeb from command line.

@Siriussee
Copy link
Author

@microsoft-github-policy-service agree company="Microsoft"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants