Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement]Adding additional info for memory metadata #2750

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

Hailong-am
Copy link
Contributor

@Hailong-am Hailong-am commented Jul 25, 2024

Description

Adding additional info for memory metadata

index mapping, additional_info is new added field with flat_object type

{
 ".plugins-ml-memory-meta": {
  "mappings": {
   "_meta": {
    "schema_version": 2
   },
   "properties": {
    "additional_info": {
     "type": "flat_object"
    },
    "application_type": {
     "type": "keyword"
    },
    "create_time": {
     "type": "date",
     "format": "strict_date_time||epoch_millis"
    },
    "name": {
     "type": "text"
    },
    "updated_time": {
     "type": "date",
     "format": "strict_date_time||epoch_millis"
    },
    "user": {
     "type": "keyword"
    }
   }
  }
 }
}

API request/response samples

Create memory without additional info

curl --request POST \
  --url http://localhost:9200/_plugins/_ml/memory \
  --header 'Content-Type: application/json' \
  --data '{"name": "test memory1"}'
}

# response
{
 "memory_id": "qDjoBpEB_JGSOCujgATn"
}

# get a memory
curl http://localhost:9200/_plugins/_ml/memory/qDjoBpEB_JGSOCujgATn

{
 "memory_id": "qDjoBpEB_JGSOCujgATn",
 "create_time": "2024-07-31T03:49:46.343662Z",
 "updated_time": "2024-07-31T03:49:46.343662Z",
 "name": "test memory1",
 "user": "admin",
 "additional_info": {}
}

Create new memory with additional info

curl --request POST \
  --url http://localhost:9200/_plugins/_ml/memory \
  --header 'Content-Type: application/json' \
  --data '{
 "name": "test memory",
 "additional_info": {
  "x": "yz"
 }
}'

# response
{
 "memory_id": "ZTjeBpEB_JGSOCuj5ARu"
}

## Get memory

curl http://localhost:9200/_plugins/_ml/memory/ZTjeBpEB_JGSOCuj5ARu

# response
{
 "memory_id": "ZTjeBpEB_JGSOCuj5ARu",
 "create_time": "2024-07-31T03:39:16.462676Z",
 "updated_time": "2024-07-31T03:39:16.462676Z",
 "name": "test memory",
 "user": "admin",
 "additional_info": {
  "x": "yz"
 }
}

Search memory

curl --request POST \
  --url https://localhost:9200/_plugins/_ml/memory/_search \
  --header 'Content-Type: application/json' \
  --data '{ 
  "query": {
    "match": {
     "name": "test memory"
    }
  }
}'

# response
{
 "took": 1,
 "timed_out": false,
 "_shards": {
  "total": 1,
  "successful": 1,
  "skipped": 0,
  "failed": 0
 },
 "hits": {
  "total": {
   "value": 2,
   "relation": "eq"
  },
  "max_score": 1.0577903,
  "hits": [
   {
    "_index": ".plugins-ml-memory-meta",
    "_id": "mjjmBpEB_JGSOCujnwTA",
    "_version": 1,
    "_seq_no": 0,
    "_primary_term": 1,
    "_score": 1.0577903,
    "_source": {
     "updated_time": "2024-07-31T03:47:43.168654Z",
     "create_time": "2024-07-31T03:47:43.168654Z",
     "application_type": null,
     "additional_info": {
      "x": "yz"
     },
     "name": "test memory",
     "user": "admin"
    }
   },
   {
    "_index": ".plugins-ml-memory-meta",
    "_id": "qDjoBpEB_JGSOCujgATn",
    "_version": 1,
    "_seq_no": 1,
    "_primary_term": 1,
    "_score": 0.36464313,
    "_source": {
     "updated_time": "2024-07-31T03:49:46.343662Z",
     "create_time": "2024-07-31T03:49:46.343662Z",
     "application_type": null,
     "additional_info": {},
     "name": "test memory1",
     "user": "admin"
    }
   }
  ]
 }
}

Issues Resolved

#2755

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@ylwu-amzn
Copy link
Collaborator

@Zhangxunmt help review ?

@Hailong-am Hailong-am changed the title Adding additional info for memory metadata [Enhancement]Adding additional info for memory metadata Jul 29, 2024
@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env July 29, 2024 09:55 — with GitHub Actions Inactive
Signed-off-by: Hailong Cui <[email protected]>

create conversation support additional info

Signed-off-by: Hailong Cui <[email protected]>

add test for search conversation

Signed-off-by: Hailong Cui <[email protected]>

add bwc

Signed-off-by: Hailong Cui <[email protected]>
@@ -35,7 +36,7 @@ public class UpdateConversationRequest extends ActionRequest {
private String conversationId;
private Map<String, Object> updateContent;

private static final Set<String> allowedList = new HashSet<>(Arrays.asList(META_NAME_FIELD));
private static final Set<String> allowedList = new HashSet<>(Arrays.asList(META_NAME_FIELD, META_ADDITIONAL_INFO_FIELD));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would allow update/delete anything inside META_ADDITIONAL_INFO_FIELD. I think you need to put some restrictions to not allow updating certain fields inside it like the application/memory type, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense. We can initially make it open and then add restrictions when the need arises.

@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env August 5, 2024 06:26 — with GitHub Actions Inactive
@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env August 5, 2024 06:26 — with GitHub Actions Inactive
@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env August 5, 2024 07:31 — with GitHub Actions Inactive
@zane-neo zane-neo merged commit 920685d into opensearch-project:main Aug 5, 2024
6 of 7 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 5, 2024
create conversation support additional info

add test for search conversation

add bwc

Signed-off-by: Hailong Cui <[email protected]>
(cherry picked from commit 920685d)
dhrubo-os pushed a commit that referenced this pull request Aug 8, 2024
…2804)

create conversation support additional info

add test for search conversation

add bwc

Signed-off-by: Hailong Cui <[email protected]>
(cherry picked from commit 920685d)

Co-authored-by: Hailong Cui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants