Skip to content

Commit 5f0367a

Browse files
Added ML create, update, get, search, delete memory APIs.
Signed-off-by: Nathalie Jonathan <[email protected]>
1 parent 9c8431f commit 5f0367a

File tree

8 files changed

+415
-2
lines changed

8 files changed

+415
-2
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
4545
- Added `GET /_plugins/_ml/connectors/{connector_id}`, `_search`, `POST /_plugins/_ml/connectors/_search`, and `PUT /_plugins/_ml/connectors/{connector_id}` ([#764](https://github.com/opensearch-project/opensearch-api-specification/pull/764))
4646
- Added the ability to skip an individual chapter test ([#765](https://github.com/opensearch-project/opensearch-api-specification/pull/765))
4747
- Added uploading of test spec logs ([#767](https://github.com/opensearch-project/opensearch-api-specification/pull/767))
48+
- Added `POST /_plugins/_ml/memory`, `PUT /_plugins/_ml/memory/{memory_id}`, `GET /_plugins/_ml/memory`, `GET /_plugins/_ml/memory/{memory_id}`, `_search`, `POST /_plugins/_ml/memory/_search`, and `DELETE /_plugins/_ml/memory/{memory_id}` ([#771](https://github.com/opensearch-project/opensearch-api-specification/pull/771))
4849

4950
### Removed
5051
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))

Diff for: spec/namespaces/ml.yaml

+176
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,83 @@ paths:
255255
responses:
256256
'200':
257257
$ref: '#/components/responses/ml.delete_agent@200'
258+
/_plugins/_ml/memory:
259+
get:
260+
operationId: ml.get_memory.0
261+
x-operation-group: ml.get_memory
262+
x-version-added: '2.12'
263+
description: Get a memory.
264+
requestBody:
265+
$ref: '#/components/requestBodies/ml.get_memory'
266+
responses:
267+
'200':
268+
$ref: '#/components/responses/ml.get_memory@200'
269+
post:
270+
operationId: ml.create_memory.0
271+
x-operation-group: ml.create_memory
272+
x-version-added: '2.12'
273+
description: Create a memory.
274+
requestBody:
275+
$ref: '#/components/requestBodies/ml.create_memory'
276+
responses:
277+
'200':
278+
$ref: '#/components/responses/ml.create_memory@200'
279+
/_plugins/_ml/memory/{memory_id}:
280+
get:
281+
operationId: ml.get_memory.1
282+
x-operation-group: ml.get_memory
283+
x-version-added: '2.12'
284+
description: Get a memory.
285+
requestBody:
286+
$ref: '#/components/requestBodies/ml.get_memory'
287+
parameters:
288+
- $ref: '#/components/parameters/ml.get_memory::path.memory_id'
289+
responses:
290+
'200':
291+
$ref: '#/components/responses/ml.get_memory@200'
292+
put:
293+
operationId: ml.update_memory.0
294+
x-operation-group: ml.update_memory
295+
x-version-added: '2.12'
296+
description: Update a memory.
297+
parameters:
298+
- $ref: '#/components/parameters/ml.update_memory::path.memory_id'
299+
requestBody:
300+
$ref: '#/components/requestBodies/ml.update_memory'
301+
responses:
302+
'200':
303+
$ref: '#/components/responses/ml.update_memory@200'
304+
delete:
305+
operationId: ml.delete_memory.0
306+
x-operation-group: ml.delete_memory
307+
x-version-added: '2.12'
308+
description: Delete a memory.
309+
parameters:
310+
- $ref: '#/components/parameters/ml.delete_memory::path.memory_id'
311+
responses:
312+
'200':
313+
$ref: '#/components/responses/ml.delete_memory@200'
314+
/_plugins/_ml/memory/_search:
315+
get:
316+
operationId: ml.search_memory.0
317+
x-operation-group: ml.search_memory
318+
x-version-added: '2.12'
319+
description: Search memory.
320+
requestBody:
321+
$ref: '#/components/requestBodies/ml.search_memory'
322+
responses:
323+
'200':
324+
$ref: '#/components/responses/ml.search_memory@200'
325+
post:
326+
operationId: ml.search_memory.1
327+
x-operation-group: ml.search_memory
328+
x-version-added: '2.12'
329+
description: Search memory.
330+
requestBody:
331+
$ref: '#/components/requestBodies/ml.search_memory'
332+
responses:
333+
'200':
334+
$ref: '#/components/responses/ml.search_memory@200'
258335
components:
259336
requestBodies:
260337
ml.register_model_group:
@@ -547,6 +624,53 @@ components:
547624
required:
548625
- name
549626
- type
627+
ml.get_memory:
628+
content:
629+
application/json:
630+
schema:
631+
type: object
632+
properties:
633+
max_results:
634+
type: integer
635+
format: int64
636+
description: The maximum number of results to return.
637+
next_token:
638+
type: integer
639+
format: int64
640+
description: The index of the first memory in the sorted list of memories to return.
641+
ml.create_memory:
642+
content:
643+
application/json:
644+
schema:
645+
type: object
646+
properties:
647+
name:
648+
$ref: '../schemas/_common.yaml#/components/schemas/Name'
649+
ml.update_memory:
650+
content:
651+
application/json:
652+
schema:
653+
type: object
654+
properties:
655+
name:
656+
$ref: '../schemas/_common.yaml#/components/schemas/Name'
657+
ml.search_memory:
658+
content:
659+
application/json:
660+
schema:
661+
type: object
662+
properties:
663+
query:
664+
$ref: '../schemas/ml._common.yaml#/components/schemas/Query'
665+
size:
666+
type: integer
667+
format: int64
668+
description: The number of memories to return.
669+
sort:
670+
type: array
671+
items:
672+
$ref: '../schemas/ml._common.yaml#/components/schemas/SortMemory'
673+
description: The sort order.
550674
responses:
551675
ml.register_model_group@200:
552676
content:
@@ -682,6 +806,40 @@ components:
682806
application/json:
683807
schema:
684808
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
809+
ml.get_memory@200:
810+
content:
811+
application/json:
812+
schema:
813+
$ref: '../schemas/ml._common.yaml#/components/schemas/GetMemoryResponse'
814+
ml.create_memory@200:
815+
content:
816+
application/json:
817+
schema:
818+
type: object
819+
properties:
820+
memory_id:
821+
type: string
822+
ml.update_memory@200:
823+
content:
824+
application/json:
825+
schema:
826+
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
827+
ml.delete_memory@200:
828+
content:
829+
application/json:
830+
schema:
831+
type: object
832+
properties:
833+
success:
834+
type: boolean
835+
description: Whether the memory was deleted successfully.
836+
required:
837+
- success
838+
ml.search_memory@200:
839+
content:
840+
application/json:
841+
schema:
842+
$ref: '../schemas/ml._common.yaml#/components/schemas/SearchMemoryResponse'
685843
parameters:
686844
ml.get_model_group::path.model_group_id:
687845
name: model_group_id
@@ -777,5 +935,23 @@ components:
777935
name: task_id
778936
in: path
779937
required: true
938+
schema:
939+
type: string
940+
ml.get_memory::path.memory_id:
941+
name: memory_id
942+
in: path
943+
required: true
944+
schema:
945+
type: string
946+
ml.update_memory::path.memory_id:
947+
name: memory_id
948+
in: path
949+
required: true
950+
schema:
951+
type: string
952+
ml.delete_memory::path.memory_id:
953+
name: memory_id
954+
in: path
955+
required: true
780956
schema:
781957
type: string

Diff for: spec/schemas/ml._common.yaml

+83-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ components:
7474
$ref: '#/components/schemas/Source'
7575
model_id:
7676
$ref: '_common.yaml#/components/schemas/Name'
77+
sort:
78+
type: array
79+
items:
80+
type: number
81+
format: float
82+
description: The sort values.
7783
required:
7884
- _score
7985
Source:
@@ -149,8 +155,7 @@ components:
149155
format: int64
150156
description: The auto redeploy retry times.
151157
name:
152-
type: string
153-
description: The model name.
158+
$ref: '_common.yaml#/components/schemas/Name'
154159
connector_id:
155160
type: string
156161
description: The connector ID.
@@ -203,6 +208,22 @@ components:
203208
type: array
204209
items:
205210
$ref: '#/components/schemas/Action'
211+
updated_time:
212+
type: string
213+
format: date-time
214+
description: The updated time.
215+
create_time:
216+
type: string
217+
format: date-time
218+
description: The create time.
219+
application_type:
220+
type: ['null', string]
221+
description: The application type.
222+
additional_info:
223+
$ref: '#/components/schemas/AdditionalInfo'
224+
user:
225+
type: string
226+
description: The username of the user.
206227
ModelConfig:
207228
type: object
208229
properties:
@@ -445,6 +466,8 @@ components:
445466
$ref: '_common.yaml#/components/schemas/Id'
446467
model_id:
447468
$ref: '_common.yaml#/components/schemas/Name'
469+
name:
470+
$ref: '#/components/schemas/OwnerNameKeyword'
448471
owner.name.keyword:
449472
$ref: '#/components/schemas/OwnerNameKeyword'
450473
Algorithm:
@@ -560,6 +583,28 @@ components:
560583
$ref: '#/components/schemas/SortOrder'
561584
_score:
562585
$ref: '#/components/schemas/SortOrder'
586+
SortMemory:
587+
type: object
588+
description: The sort memory query.
589+
properties:
590+
additional_info:
591+
$ref: '#/components/schemas/SortOrder'
592+
application_time:
593+
$ref: '#/components/schemas/SortOrder'
594+
create_time:
595+
$ref: '#/components/schemas/SortOrder'
596+
updated_time:
597+
$ref: '#/components/schemas/SortOrder'
598+
user:
599+
$ref: '#/components/schemas/SortOrder'
600+
_id:
601+
$ref: '#/components/schemas/SortOrder'
602+
_index:
603+
$ref: '#/components/schemas/SortOrder'
604+
_score:
605+
$ref: '#/components/schemas/SortOrder'
606+
_seq_no:
607+
$ref: '#/components/schemas/SortOrder'
563608
SortOrder:
564609
type: object
565610
description: The order of the sort.
@@ -804,6 +849,27 @@ components:
804849
properties:
805850
type:
806851
type: string
852+
memory_id:
853+
$ref: '_common.yaml#/components/schemas/Name'
854+
create_time:
855+
type: string
856+
format: date-time
857+
description: The create time.
858+
updated_time:
859+
type: string
860+
format: date-time
861+
description: The updated time.
862+
name:
863+
$ref: '_common.yaml#/components/schemas/Name'
864+
user:
865+
type: string
866+
description: The username of the user.
867+
additional_info:
868+
$ref: '#/components/schemas/AdditionalInfo'
869+
AdditionalInfo:
870+
type: object
871+
description: Additional information query.
872+
properties: {}
807873
ToolItems:
808874
type: object
809875
properties:
@@ -851,4 +917,19 @@ components:
851917
format: int64
852918
description: The last updated time.
853919
SearchConnectorsResponse:
920+
$ref: '#/components/schemas/SearchResponse'
921+
GetMemoryResponse:
922+
oneOf:
923+
- $ref: '#/components/schemas/Memory'
924+
- type: object
925+
properties:
926+
memories:
927+
type: array
928+
items:
929+
$ref: '#/components/schemas/Memory'
930+
next_token:
931+
type: integer
932+
format: int64
933+
description: The index of the first memory in the sorted list of memories.
934+
SearchMemoryResponse:
854935
$ref: '#/components/schemas/SearchResponse'

Diff for: tests/plugins/ml/ml/memory/create.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
$schema: ../../../../../json_schemas/test_story.schema.yaml
2+
3+
description: Test the creation of a memory.
4+
version: '>= 2.12'
5+
epilogues:
6+
- path: /_plugins/_ml/memory/{memory_id}
7+
method: DELETE
8+
status: [200, 404]
9+
parameters:
10+
memory_id: ${create_memory.memory_id}
11+
chapters:
12+
- synopsis: Create a memory.
13+
id: create_memory
14+
path: /_plugins/_ml/memory
15+
method: POST
16+
request:
17+
payload:
18+
name: Test memory
19+
response:
20+
status: 200
21+
output:
22+
memory_id: payload.memory_id

Diff for: tests/plugins/ml/ml/memory/delete.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$schema: ../../../../../json_schemas/test_story.schema.yaml
2+
3+
description: Test the deletion of a memory.
4+
version: '>= 2.12'
5+
prologues:
6+
- path: /_plugins/_ml/memory
7+
id: create_memory
8+
method: POST
9+
request:
10+
payload:
11+
name: Test memory
12+
output:
13+
memory_id: payload.memory_id
14+
epilogues:
15+
- path: /_plugins/_ml/memory/{memory_id}
16+
method: DELETE
17+
status: [200, 404]
18+
parameters:
19+
memory_id: ${create_memory.memory_id}
20+
chapters:
21+
- synopsis: Delete a memory.
22+
path: /_plugins/_ml/memory/{memory_id}
23+
method: DELETE
24+
parameters:
25+
memory_id: ${create_memory.memory_id}
26+
response:
27+
status: 200

0 commit comments

Comments
 (0)