Skip to content

Commit

Permalink
Added ML create, update, get, search, delete memory APIs.
Browse files Browse the repository at this point in the history
Signed-off-by: Nathalie Jonathan <[email protected]>
  • Loading branch information
nathaliellenaa committed Jan 7, 2025
1 parent 9c8431f commit 5f0367a
Show file tree
Hide file tree
Showing 8 changed files with 415 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- 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))
- Added the ability to skip an individual chapter test ([#765](https://github.com/opensearch-project/opensearch-api-specification/pull/765))
- Added uploading of test spec logs ([#767](https://github.com/opensearch-project/opensearch-api-specification/pull/767))
- 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))

### Removed
- 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))
Expand Down
176 changes: 176 additions & 0 deletions spec/namespaces/ml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,83 @@ paths:
responses:
'200':
$ref: '#/components/responses/ml.delete_agent@200'
/_plugins/_ml/memory:
get:
operationId: ml.get_memory.0
x-operation-group: ml.get_memory
x-version-added: '2.12'
description: Get a memory.
requestBody:
$ref: '#/components/requestBodies/ml.get_memory'
responses:
'200':
$ref: '#/components/responses/ml.get_memory@200'
post:
operationId: ml.create_memory.0
x-operation-group: ml.create_memory
x-version-added: '2.12'
description: Create a memory.
requestBody:
$ref: '#/components/requestBodies/ml.create_memory'
responses:
'200':
$ref: '#/components/responses/ml.create_memory@200'
/_plugins/_ml/memory/{memory_id}:
get:
operationId: ml.get_memory.1
x-operation-group: ml.get_memory
x-version-added: '2.12'
description: Get a memory.
requestBody:
$ref: '#/components/requestBodies/ml.get_memory'
parameters:
- $ref: '#/components/parameters/ml.get_memory::path.memory_id'
responses:
'200':
$ref: '#/components/responses/ml.get_memory@200'
put:
operationId: ml.update_memory.0
x-operation-group: ml.update_memory
x-version-added: '2.12'
description: Update a memory.
parameters:
- $ref: '#/components/parameters/ml.update_memory::path.memory_id'
requestBody:
$ref: '#/components/requestBodies/ml.update_memory'
responses:
'200':
$ref: '#/components/responses/ml.update_memory@200'
delete:
operationId: ml.delete_memory.0
x-operation-group: ml.delete_memory
x-version-added: '2.12'
description: Delete a memory.
parameters:
- $ref: '#/components/parameters/ml.delete_memory::path.memory_id'
responses:
'200':
$ref: '#/components/responses/ml.delete_memory@200'
/_plugins/_ml/memory/_search:
get:
operationId: ml.search_memory.0
x-operation-group: ml.search_memory
x-version-added: '2.12'
description: Search memory.
requestBody:
$ref: '#/components/requestBodies/ml.search_memory'
responses:
'200':
$ref: '#/components/responses/ml.search_memory@200'
post:
operationId: ml.search_memory.1
x-operation-group: ml.search_memory
x-version-added: '2.12'
description: Search memory.
requestBody:
$ref: '#/components/requestBodies/ml.search_memory'
responses:
'200':
$ref: '#/components/responses/ml.search_memory@200'
components:
requestBodies:
ml.register_model_group:
Expand Down Expand Up @@ -547,6 +624,53 @@ components:
required:
- name
- type
ml.get_memory:
content:
application/json:
schema:
type: object
properties:
max_results:
type: integer
format: int64
description: The maximum number of results to return.
next_token:
type: integer
format: int64
description: The index of the first memory in the sorted list of memories to return.
ml.create_memory:
content:
application/json:
schema:
type: object
properties:
name:
$ref: '../schemas/_common.yaml#/components/schemas/Name'
ml.update_memory:
content:
application/json:
schema:
type: object
properties:
name:
$ref: '../schemas/_common.yaml#/components/schemas/Name'
ml.search_memory:
content:
application/json:
schema:
type: object
properties:
query:
$ref: '../schemas/ml._common.yaml#/components/schemas/Query'
size:
type: integer
format: int64
description: The number of memories to return.
sort:
type: array
items:
$ref: '../schemas/ml._common.yaml#/components/schemas/SortMemory'
description: The sort order.
responses:
ml.register_model_group@200:
content:
Expand Down Expand Up @@ -682,6 +806,40 @@ components:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
ml.get_memory@200:
content:
application/json:
schema:
$ref: '../schemas/ml._common.yaml#/components/schemas/GetMemoryResponse'
ml.create_memory@200:
content:
application/json:
schema:
type: object
properties:
memory_id:
type: string
ml.update_memory@200:
content:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase'
ml.delete_memory@200:
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
description: Whether the memory was deleted successfully.
required:
- success
ml.search_memory@200:
content:
application/json:
schema:
$ref: '../schemas/ml._common.yaml#/components/schemas/SearchMemoryResponse'
parameters:
ml.get_model_group::path.model_group_id:
name: model_group_id
Expand Down Expand Up @@ -777,5 +935,23 @@ components:
name: task_id
in: path
required: true
schema:
type: string
ml.get_memory::path.memory_id:
name: memory_id
in: path
required: true
schema:
type: string
ml.update_memory::path.memory_id:
name: memory_id
in: path
required: true
schema:
type: string
ml.delete_memory::path.memory_id:
name: memory_id
in: path
required: true
schema:
type: string
85 changes: 83 additions & 2 deletions spec/schemas/ml._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ components:
$ref: '#/components/schemas/Source'
model_id:
$ref: '_common.yaml#/components/schemas/Name'
sort:
type: array
items:
type: number
format: float
description: The sort values.
required:
- _score
Source:
Expand Down Expand Up @@ -149,8 +155,7 @@ components:
format: int64
description: The auto redeploy retry times.
name:
type: string
description: The model name.
$ref: '_common.yaml#/components/schemas/Name'
connector_id:
type: string
description: The connector ID.
Expand Down Expand Up @@ -203,6 +208,22 @@ components:
type: array
items:
$ref: '#/components/schemas/Action'
updated_time:
type: string
format: date-time
description: The updated time.
create_time:
type: string
format: date-time
description: The create time.
application_type:
type: ['null', string]
description: The application type.
additional_info:
$ref: '#/components/schemas/AdditionalInfo'
user:
type: string
description: The username of the user.
ModelConfig:
type: object
properties:
Expand Down Expand Up @@ -445,6 +466,8 @@ components:
$ref: '_common.yaml#/components/schemas/Id'
model_id:
$ref: '_common.yaml#/components/schemas/Name'
name:
$ref: '#/components/schemas/OwnerNameKeyword'
owner.name.keyword:
$ref: '#/components/schemas/OwnerNameKeyword'
Algorithm:
Expand Down Expand Up @@ -560,6 +583,28 @@ components:
$ref: '#/components/schemas/SortOrder'
_score:
$ref: '#/components/schemas/SortOrder'
SortMemory:
type: object
description: The sort memory query.
properties:
additional_info:
$ref: '#/components/schemas/SortOrder'
application_time:
$ref: '#/components/schemas/SortOrder'
create_time:
$ref: '#/components/schemas/SortOrder'
updated_time:
$ref: '#/components/schemas/SortOrder'
user:
$ref: '#/components/schemas/SortOrder'
_id:
$ref: '#/components/schemas/SortOrder'
_index:
$ref: '#/components/schemas/SortOrder'
_score:
$ref: '#/components/schemas/SortOrder'
_seq_no:
$ref: '#/components/schemas/SortOrder'
SortOrder:
type: object
description: The order of the sort.
Expand Down Expand Up @@ -804,6 +849,27 @@ components:
properties:
type:
type: string
memory_id:
$ref: '_common.yaml#/components/schemas/Name'
create_time:
type: string
format: date-time
description: The create time.
updated_time:
type: string
format: date-time
description: The updated time.
name:
$ref: '_common.yaml#/components/schemas/Name'
user:
type: string
description: The username of the user.
additional_info:
$ref: '#/components/schemas/AdditionalInfo'
AdditionalInfo:
type: object
description: Additional information query.
properties: {}
ToolItems:
type: object
properties:
Expand Down Expand Up @@ -851,4 +917,19 @@ components:
format: int64
description: The last updated time.
SearchConnectorsResponse:
$ref: '#/components/schemas/SearchResponse'
GetMemoryResponse:
oneOf:
- $ref: '#/components/schemas/Memory'
- type: object
properties:
memories:
type: array
items:
$ref: '#/components/schemas/Memory'
next_token:
type: integer
format: int64
description: The index of the first memory in the sorted list of memories.
SearchMemoryResponse:
$ref: '#/components/schemas/SearchResponse'
22 changes: 22 additions & 0 deletions tests/plugins/ml/ml/memory/create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test the creation of a memory.
version: '>= 2.12'
epilogues:
- path: /_plugins/_ml/memory/{memory_id}
method: DELETE
status: [200, 404]
parameters:
memory_id: ${create_memory.memory_id}
chapters:
- synopsis: Create a memory.
id: create_memory
path: /_plugins/_ml/memory
method: POST
request:
payload:
name: Test memory
response:
status: 200
output:
memory_id: payload.memory_id
27 changes: 27 additions & 0 deletions tests/plugins/ml/ml/memory/delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test the deletion of a memory.
version: '>= 2.12'
prologues:
- path: /_plugins/_ml/memory
id: create_memory
method: POST
request:
payload:
name: Test memory
output:
memory_id: payload.memory_id
epilogues:
- path: /_plugins/_ml/memory/{memory_id}
method: DELETE
status: [200, 404]
parameters:
memory_id: ${create_memory.memory_id}
chapters:
- synopsis: Delete a memory.
path: /_plugins/_ml/memory/{memory_id}
method: DELETE
parameters:
memory_id: ${create_memory.memory_id}
response:
status: 200
Loading

0 comments on commit 5f0367a

Please sign in to comment.