Skip to content

Commit bf539a7

Browse files
authored
feat(specs): predict model endpoints (#1014)
1 parent f03f671 commit bf539a7

16 files changed

+555
-0
lines changed

specs/predict/common/parameters.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ userID:
55
schema:
66
type: string
77
description: User ID for authenticated users or cookie ID for non-authenticated repeated users (visitors).
8+
9+
modelID:
10+
name: modelID
11+
in: path
12+
required: true
13+
schema:
14+
type: string
15+
description: The ID of the model to retrieve.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
activateModelParams:
2+
type: object
3+
properties:
4+
type:
5+
$ref: '../../common/schemas/Params.yml#/modelsToRetrieve'
6+
name:
7+
$ref: '#/name'
8+
sourceID:
9+
$ref: '#/sourceID'
10+
index:
11+
$ref: '#/index'
12+
affinities:
13+
type: array
14+
items:
15+
$ref: '#/affinities'
16+
contentAttributes:
17+
type: array
18+
items:
19+
$ref: '#/contentAttributes'
20+
required:
21+
- type
22+
- name
23+
- sourceID
24+
- index
25+
26+
updateModelParams:
27+
type: object
28+
properties:
29+
name:
30+
$ref: '#/name'
31+
affinities:
32+
type: array
33+
items:
34+
$ref: '#/affinities'
35+
contentAttributes:
36+
type: array
37+
items:
38+
$ref: '#/contentAttributes'
39+
status:
40+
$ref: '#/status'
41+
required:
42+
- modelID
43+
- sourceID
44+
- index
45+
46+
type:
47+
type: string
48+
enum: ['funnel_stage', 'order_value', 'affinities']
49+
description: The model's type.
50+
51+
name:
52+
type: string
53+
description: The model’s instance name.
54+
55+
sourceID:
56+
type: string
57+
description: The data source ID, as returned by the (external) sources API.
58+
59+
index:
60+
type: string
61+
description: The index name.
62+
63+
affinities:
64+
type: string
65+
description: List of items attributes that will be used as affinities. This param is required if `type=affinities`.
66+
67+
contentAttributes:
68+
type: string
69+
description: List of items attributes that will be used for embeddings, for ex. titles or descriptions.
70+
71+
status:
72+
type: string
73+
enum: [active, inactive]
74+
description: |
75+
`active` - model is running and generating predictions. The active value is allowed only if the current status of the model is `inactive`. \
76+
`inactive` - model training and inference have been paused. The inactive value is allowed only if the current status of the model is `active`.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
get:
2+
tags:
3+
- models
4+
operationId: getAvailableModelTypes
5+
summary: Get a list of available model types.
6+
description: Get a list of all available model types. Each model type can be activated more than once, by selecting a different data source.
7+
responses:
8+
'200':
9+
description: OK
10+
content:
11+
application/json:
12+
schema:
13+
title: getAvailableModelTypesResponse
14+
type: array
15+
items:
16+
type: object
17+
additionalProperties: false
18+
properties:
19+
name:
20+
type: string
21+
description: Name of the model.
22+
type:
23+
type: string
24+
description: Description of the model.
25+
compatibleSources:
26+
type: array
27+
items:
28+
type: string
29+
$ref: '../../responses/ModelTypes.yml#/compatibleSources'
30+
dataRequirements:
31+
type: object
32+
additionalProperties: false
33+
properties:
34+
minUsers:
35+
type: integer
36+
description: Minimum number of users required for this model.
37+
minDays:
38+
type: integer
39+
description: Minimum number of days model needs to run.
40+
required:
41+
- minUsers
42+
- minDays
43+
required:
44+
- name
45+
- type
46+
- compatibleSources
47+
- dataRequirements
48+
'401':
49+
$ref: '../../responses/InvalidCredentials.yml'
50+
'422':
51+
$ref: '../../../common/responses/UnprocessableEntity.yml'
52+
'500':
53+
$ref: '../../../common/responses/InternalError.yml'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
get:
2+
tags:
3+
- models
4+
operationId: getModelMetrics
5+
summary: Get a model’s instance metrics.
6+
description: Get the model instance’ training metrics.
7+
parameters:
8+
- $ref: '../../common/parameters.yml#/modelID'
9+
responses:
10+
'200':
11+
description: OK
12+
content:
13+
application/json:
14+
schema:
15+
title: getModelMetricsResponse
16+
type: array
17+
items:
18+
$ref: '../../responses/Models.yml#/modelMetrics'
19+
'401':
20+
$ref: '../../responses/InvalidCredentials.yml'
21+
'404':
22+
$ref: '../../../common/responses/IndexNotFound.yml'
23+
'422':
24+
$ref: '../../../common/responses/UnprocessableEntity.yml'
25+
'500':
26+
$ref: '../../../common/responses/InternalError.yml'
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
get:
2+
tags:
3+
- models
4+
operationId: getModelInstanceConfig
5+
summary: Get a model’s instance configuration.
6+
description: Get the configuration for a model that was activated.
7+
parameters:
8+
- $ref: '../../common/parameters.yml#/modelID'
9+
responses:
10+
'200':
11+
description: OK
12+
content:
13+
application/json:
14+
schema:
15+
title: getModelInstanceConfigResponse
16+
$ref: '../../responses/Models.yml#/modelInstance'
17+
'401':
18+
$ref: '../../responses/InvalidCredentials.yml'
19+
'404':
20+
$ref: '../../../common/responses/IndexNotFound.yml'
21+
'422':
22+
$ref: '../../../common/responses/UnprocessableEntity.yml'
23+
'500':
24+
$ref: '../../../common/responses/InternalError.yml'
25+
26+
post:
27+
tags:
28+
- models
29+
operationId: updateModelInstance
30+
summary: Update a model instance.
31+
description: Update a model’s configuration.
32+
parameters:
33+
- $ref: '../../common/parameters.yml#/modelID'
34+
requestBody:
35+
required: true
36+
content:
37+
application/json:
38+
schema:
39+
$ref: '../../common/schemas/modelsParams.yml#/updateModelParams'
40+
responses:
41+
'200':
42+
description: OK
43+
content:
44+
application/json:
45+
schema:
46+
title: updateModelInstanceResponse
47+
type: object
48+
additionalProperties: false
49+
properties:
50+
modelID:
51+
type: string
52+
description: The ID of the model.
53+
updatedAt:
54+
$ref: '../../../common/responses/common.yml#/updatedAt'
55+
required:
56+
- modelID
57+
- updatedAt
58+
'401':
59+
$ref: '../../responses/InvalidCredentials.yml'
60+
'404':
61+
$ref: '../../../common/responses/IndexNotFound.yml'
62+
'422':
63+
$ref: '../../../common/responses/UnprocessableEntity.yml'
64+
'500':
65+
$ref: '../../../common/responses/InternalError.yml'
66+
67+
delete:
68+
tags:
69+
- models
70+
operationId: deleteModelInstance
71+
summary: Delete a model instance.
72+
description: Delete the model’s configuration, pipelines and generated predictions.
73+
parameters:
74+
- $ref: '../../common/parameters.yml#/modelID'
75+
responses:
76+
'200':
77+
description: OK
78+
content:
79+
application/json:
80+
schema:
81+
title: deleteModelInstanceResponse
82+
type: object
83+
additionalProperties: false
84+
properties:
85+
modelID:
86+
type: string
87+
description: The ID of the model.
88+
deletedUntil:
89+
type: string
90+
description: The date until which you can safely consider the data as being deleted.
91+
required:
92+
- modelID
93+
- deletedUntil
94+
'401':
95+
$ref: '../../responses/InvalidCredentials.yml'
96+
'404':
97+
$ref: '../../../common/responses/IndexNotFound.yml'
98+
'422':
99+
$ref: '../../../common/responses/UnprocessableEntity.yml'
100+
'500':
101+
$ref: '../../../common/responses/InternalError.yml'

specs/predict/paths/models/models.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
get:
2+
tags:
3+
- models
4+
operationId: getModelInstances
5+
summary: Get model instances.
6+
description: Get a list of all model instances.
7+
responses:
8+
'200':
9+
description: OK
10+
content:
11+
application/json:
12+
schema:
13+
title: getModelInstancesResponse
14+
type: array
15+
items:
16+
$ref: '../../responses/Models.yml#/modelInstance'
17+
'401':
18+
$ref: '../../responses/InvalidCredentials.yml'
19+
'422':
20+
$ref: '../../../common/responses/UnprocessableEntity.yml'
21+
'500':
22+
$ref: '../../../common/responses/InternalError.yml'
23+
24+
post:
25+
tags:
26+
- models
27+
operationId: activateModelInstance
28+
summary: Activate a model instance.
29+
description: >
30+
Activate an existing model template. This action triggers the training and inference pipelines for the selected model.
31+
The model is added with `status=pending`.
32+
If a model with the exact same source & index already exists, the API endpoint returns an error.
33+
requestBody:
34+
required: true
35+
content:
36+
application/json:
37+
schema:
38+
$ref: '../../common/schemas/modelsParams.yml#/activateModelParams'
39+
responses:
40+
'200':
41+
description: OK
42+
content:
43+
application/json:
44+
schema:
45+
title: activateModelInstanceResponse
46+
type: object
47+
additionalProperties: false
48+
properties:
49+
modelID:
50+
type: string
51+
description: The ID of the model.
52+
updatedAt:
53+
$ref: '../../../common/responses/common.yml#/updatedAt'
54+
required:
55+
- modelID
56+
- updatedAt
57+
58+
'401':
59+
$ref: '../../responses/InvalidCredentials.yml'
60+
'422':
61+
$ref: '../../../common/responses/UnprocessableEntity.yml'
62+
'500':
63+
$ref: '../../../common/responses/InternalError.yml'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
compatibleSources:
2+
type: string
3+
enum: [bigquery]

0 commit comments

Comments
 (0)