diff --git a/CHANGELOG.md b/CHANGELOG.md index b5b2f575..360b3061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/spec/namespaces/ml.yaml b/spec/namespaces/ml.yaml index d9166bfe..262de7fc 100644 --- a/spec/namespaces/ml.yaml +++ b/spec/namespaces/ml.yaml @@ -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: @@ -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: @@ -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 @@ -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 \ No newline at end of file diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index 7a38327f..213ffd63 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -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: @@ -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. @@ -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: @@ -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: @@ -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. @@ -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: @@ -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' \ No newline at end of file diff --git a/tests/plugins/ml/ml/memory/create.yaml b/tests/plugins/ml/ml/memory/create.yaml new file mode 100644 index 00000000..20d6a16f --- /dev/null +++ b/tests/plugins/ml/ml/memory/create.yaml @@ -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 diff --git a/tests/plugins/ml/ml/memory/delete.yaml b/tests/plugins/ml/ml/memory/delete.yaml new file mode 100644 index 00000000..cb568308 --- /dev/null +++ b/tests/plugins/ml/ml/memory/delete.yaml @@ -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 \ No newline at end of file diff --git a/tests/plugins/ml/ml/memory/get.yaml b/tests/plugins/ml/ml/memory/get.yaml new file mode 100644 index 00000000..9e378714 --- /dev/null +++ b/tests/plugins/ml/ml/memory/get.yaml @@ -0,0 +1,35 @@ +$schema: ../../../../../json_schemas/test_story.schema.yaml + +description: Test the retrieval of a memory by ID and all memories. +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: Get a memory by ID. + path: /_plugins/_ml/memory/{memory_id} + method: GET + parameters: + memory_id: ${create_memory.memory_id} + response: + status: 200 + - synopsis: Get all memories. + path: /_plugins/_ml/memory + method: GET + request: + payload: + max_results: 10 + response: + status: 200 \ No newline at end of file diff --git a/tests/plugins/ml/ml/memory/search.yaml b/tests/plugins/ml/ml/memory/search.yaml new file mode 100644 index 00000000..873498cf --- /dev/null +++ b/tests/plugins/ml/ml/memory/search.yaml @@ -0,0 +1,41 @@ +$schema: ../../../../../json_schemas/test_story.schema.yaml + +description: Test the search of memories. +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: Search memory. + path: /_plugins/_ml/memory/_search + method: GET + request: + payload: + query: + match_all: {} + size: 1000 + response: + status: 200 + - synopsis: Search memory by name. + path: /_plugins/_ml/memory/_search + method: POST + request: + payload: + query: + term: + name: + value: conversation + response: + status: 200 \ No newline at end of file diff --git a/tests/plugins/ml/ml/memory/update.yaml b/tests/plugins/ml/ml/memory/update.yaml new file mode 100644 index 00000000..61e20d7d --- /dev/null +++ b/tests/plugins/ml/ml/memory/update.yaml @@ -0,0 +1,30 @@ +$schema: ../../../../../json_schemas/test_story.schema.yaml + +description: Test updating 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: Update a memory. + path: /_plugins/_ml/memory/{memory_id} + method: PUT + parameters: + memory_id: ${create_memory.memory_id} + request: + payload: + name: Test memory updated + response: + status: 200