AI Connector API contract

This contract is currently in the Proof-of-concept stage and still subject to change

Introduction

To expose AI services to our system, we need an API to be exposed for the MediaHaven installation. When creating new https://mediahaven.atlassian.net/wiki/spaces/CS/pages/4438884395 having of the following https://mediahaven.atlassian.net/wiki/spaces/CS/pages/edit-v2/4438884395#Categories

  • Embedding

  • GenerativeMetadata

then MediaHaven will connect to this plugin using REST API calls, which must implement the following methods depending on the category.

Connector Configuration

The custom properties on the connector, store the metadata fields to generate and the associated hints.

"Fields": { "Descriptive.Description": "Give a description for the image", "Descriptive.Title": "Give a prosaic title" },

Methods

GET /config-rules ALL CATEGORIES

It gives the possible configuration parameters for this connector

Ex.

{ "Rules": [ { "Name": "TextModel", "Type": "String|Integer|Boolean", "Required": false, "Default" : "ada2" } ] }

POST /text-embedding EMBEDDING

Expected parameters

Text as JSON body in Textproperty and Config based on config rules

Ex.

{ "Text": "Given me pictures of lamas", "Dimensions": 1536, "Config": { "TextModel" : "ada2" } }

Expected headers

Output

Array of float (vector) with size equal to dimensions. The vector MUST BE normalized. When the provided dimensions are 0, the embedding should be in the natural dimensions used by the embedding. If the embeddings cannot be provided in the requested dimensions, then a 400 HTTP error code should be returned.

Ex.

POST /embedding EMBEDDING

Expected parameters

Record as JSON body in Metadata property and Config based on config rules

Ex.

Expected headers

Output

Array of float (vector) with size equal to dimensions. The vector MUST BE normalized. When the provided dimensions are 0, the embedding should be in the natural dimensions used by the embedding. If the embeddings cannot be provided in the requested dimensions, then a 400 HTTP error code should be returned.

Ex.

POST /describe
POST /generative-metadata/description GENERATIVE

Expected parameters

Record as JSON body in Metadata property and Config based on config rules

Ex.

Expected headers

Output

Textual string

Ex.

POST /generative-metadata GENERATIVE

Record as JSON body in Metadata property, Fields with as items dotted keys and AI hint as value, Locale as the requested target locale for the output and finally Config based on config rules

Ex.

Expected headers

Output

A JSON object of generated fields with as keys dotted keys and as value the AI's generated value.

Ex:

Â