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 Module Plugins having of the following https://mediahaven.atlassian.The contract of this API is as follows (anything can be added before the path):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.
Methods
GET /config-rules
...
Status |
---|
colour | Blue |
---|
title | ALL CATEGORIES |
---|
|
It gives the possible configuration parameters for this connector
...
Code Block |
---|
|
{
"Rules": [
{
"Name": "TextModel",
"Type": "String|Integer|Boolean",
"Required": false,
"Default" : "ada2"
}
]
} |
POST /text-embedding
Expected parameters
...
Record Text as json JSON body in Metadata
Text
property and Config
based on config rules
...
Code Block |
---|
|
{
"MetadataText": {"Given me pictures of "RightsManagement": {
lamas",
"PermissionsDimensions": {
1536,
"ExportConfig": [{
"058b5713-a7d6-45fe-81fc-bcb8b1925fbf",
"dd100b7a-efd0-44e3-8816-0905572421da",
"da100b7a-efd0-44e3-8816-0905572421da"
],
"Write"TextModel" : "ada2"
}
} |
Code Block |
---|
x-api-key: <optional api key> |
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.
Code Block |
---|
|
{
"Embedding": [
-0.006929283495992422,
"058b5713-a7d6-45fe-81fc-bcb8b1925fbf"-0.005336422007530928,
... (omitted for spacing)
"dd100b7a-efd0-44e3-8816-0905572421da",
-4.547132266452536e-05,
"da100b7a-efd0-44e3-8816-0905572421da"
],
"Read": [
-0.024047505110502243]
} |
POST /embedding
Expected parameters
Record as JSON body in Metadata
property and Config
based on config rules
Ex.
Code Block |
---|
|
{
"Config": {
"058b5713-a7d6-45fe-81fc-bcb8b1925fbf",
"dd100b7a-efd0-44e3-8816-0905572421da",
"330060ae-548c-474f-a863-9673fdf99458",
"de100b7a-efd0-44e3-8816-0905572421da",
"TextModel" : "ada2"
},
"Metadata": {
"df100b7a-efd0-44e3-8816-0905572421da",
RightsManagement": {
"da100b7a-efd0-44e3-8816-0905572421da"
]
"Permissions": {...},
"RecordPhase": "Concept",
"ExpiryDate": null,
"ExpiryStatus": null,
"Zone": {}
}
},
"Config": { "TextModelDimensions" : "ada2"1536
}
} |
...
Code Block |
---|
x-api-key: <optional api key> |
Output
Array of float (vector) with size equal to dimensions. The vector is normalizedMUST 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.
Code Block |
---|
|
{
"Embedding": [
-0.006929283495992422,
-0.005336422007530928,
... (omitted for spacing)
-4.547132266452536e-05,
-0.024047505110502243
]
} |
POST /describe
POST /generative-metadata/description
Status |
---|
colour | Blue |
---|
title | GENERATIVE |
---|
|
Expected parameters
...
Record as json JSON body in Metadata
property and Config
based on config rules
...
Code Block |
---|
|
{
"MetadataConfig": {
"RightsManagementTextModel" : {"ada2"
},
"PermissionsMetadata": {
"ExportRightsManagement": [{
"058b5713-a7d6-45fe-81fc-bcb8b1925fbf""Permissions": {...},
"dd100b7a-efd0-44e3-8816-0905572421da",
"RecordPhase": "Concept",
"da100b7a-efd0-44e3-8816-0905572421da"
"ExpiryDate": null,
]"ExpiryStatus": null,
"WriteZone": [{}
}
}
} |
Code Block |
---|
x-api-key: <optional api key> |
Output
Textual string
Ex.
Code Block |
---|
|
{
"058b5713-a7d6-45fe-81fc-bcb8b1925fbf",
"dd100b7a-efd0-44e3-8816-0905572421da",
"Description": "This is an image of a cat"
} |
POST /generative-metadata
Status |
---|
colour | Blue |
---|
title | 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.
Code Block |
---|
|
{
"Fields": {
"Descriptive.Description": {
"da100b7a-efd0-44e3-8816-0905572421da"
Hint": "Give a description for the image"
]},
"Read"Descriptive.Keywords.Keyword": [{
"Hint": "Give a list of keywords. Generate "058b5713-a7d6-45fe-81fc-bcb8b1925fbfaround 10.",
"dd100b7a-efd0-44e3-8816-0905572421da","Type": "array"
}
},
"330060ae-548c-474f-a863-9673fdf99458"Locale": "en_US",
"Config": {
"TextModel" : "ada2"
},
"de100b7a-efd0-44e3-8816-0905572421da",
Metadata": {
"df100b7a-efd0-44e3-8816-0905572421da",
"RightsManagement": {
"da100b7a-efd0-44e3-8816-0905572421da"
]
"Permissions": {...},
"RecordPhase": "Concept",
"ExpiryDate": null,
"ExpiryStatus": null,
"Zone": {}
}
},
"Config": {
"TextModel" : "ada2"
}
} |
...
Code Block |
---|
x-api-key: <optional api key> |
Output
Textual string
Ex. A JSON object of generated fields with as keys dotted keys and as value the AI's generated value.
Ex:
Code Block |
---|
|
{
"GeneratedFields": {
"Descriptive.Description": "This is an image of a cat",
"Descriptive.Keywords.Keyword": ["Animal", "Cat", ...]
}
} |