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

Add search and singular APIs to conversation memory #1504

Merged
merged 14 commits into from
Nov 30, 2023

Conversation

HenryL27
Copy link
Collaborator

@HenryL27 HenryL27 commented Oct 12, 2023

Description

Adds search and singular apis to conversation memory as per this spec

The lower level architecture is identical to the rest of the conversation memory architecture - conversations index + interactions index; private-mode security. APIs are basically just wrappers around normal OpenSearch document APIs

Issues Resolved

#1268

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.

@HenryL27 HenryL27 temporarily deployed to ml-commons-cicd-env October 12, 2023 18:03 — with GitHub Actions Inactive
@HenryL27 HenryL27 temporarily deployed to ml-commons-cicd-env October 12, 2023 18:03 — with GitHub Actions Inactive
@HenryL27 HenryL27 had a problem deploying to ml-commons-cicd-env October 12, 2023 18:03 — with GitHub Actions Failure
@HenryL27 HenryL27 had a problem deploying to ml-commons-cicd-env October 12, 2023 18:03 — with GitHub Actions Failure
@HenryL27
Copy link
Collaborator Author

HenryL27 commented Oct 12, 2023

failed expected flakies in linux (20)

Tests with failures:
 - org.opensearch.ml.action.prediction.PredictionITTests.testPredictionWithDataFrame_LinearRegression
 - org.opensearch.ml.action.prediction.PredictionITTests.testPredictionWithoutDataset_KMeans

and these integtests in windows (20)

Tests with failures:
51 tests completed, 8 failed, 9 skipped
 - org.opensearch.ml.rest.RestMLDeployModelActionIT.testReDeployModel
 - org.opensearch.ml.rest.RestMLDeployModelActionIT.classMethod
 - org.opensearch.ml.rest.RestMLGetModelActionIT.testGetModelAPI_EmptyResources
 - org.opensearch.ml.rest.RestMLRemoteInferenceIT.testOpenAIModerationsModel
 - org.opensearch.ml.rest.RestMLRemoteInferenceIT.testCohereGenerateTextModel
 - org.opensearch.ml.rest.RestMLRemoteInferenceIT.testOpenAIEditsModel
 - org.opensearch.ml.rest.RestMLRemoteInferenceIT.testCohereClassifyModel
 - org.opensearch.ml.rest.RestMLRemoteInferenceIT.testPredictRemoteModel

all unrelated to this PR

Copy link
Collaborator

@austintlee austintlee left a comment

Choose a reason for hiding this comment

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

I think you can reduce a lot of duplicate code (constructors and doExecute routines, e.g.) by using a base class and an interface with default method.

plugin/build.gradle Outdated Show resolved Hide resolved
newQuery.must(originalQuery);
newQuery.must(new TermQueryBuilder(ConversationalIndexConstants.INTERACTIONS_CONVERSATION_ID_FIELD, conversationId));
request.source().query(newQuery);
client.admin().indices().refresh(Requests.refreshRequest(indexName), ActionListener.wrap(refreshResponse -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is 'refresh' necessary? Does it force OpenSearch to do something every time or is it smart enough not to do anything if the index hasn't changed.

Comment on lines 394 to 407
if (!clusterService.state().metadata().hasIndex(indexName)) {
listener.onFailure(new IndexNotFoundException("cannot get interaction since the interactions index does not exist", indexName));
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't OS throw this error anyway when you execute the Get request below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure, but this way I shortcut the access control request

@HenryL27 HenryL27 temporarily deployed to ml-commons-cicd-env October 17, 2023 22:24 — with GitHub Actions Inactive
@HenryL27 HenryL27 had a problem deploying to ml-commons-cicd-env October 17, 2023 22:24 — with GitHub Actions Failure
@HenryL27 HenryL27 had a problem deploying to ml-commons-cicd-env October 17, 2023 22:24 — with GitHub Actions Failure
@HenryL27
Copy link
Collaborator Author

HenryL27 commented Nov 1, 2023

@jngz-es @dhrubo-os @ylwu-amzn or someone can I get some eyes on this? Thanks

@HenryL27
Copy link
Collaborator Author

@Zhangxunmt @ylwu-amzn this PR for memory search API

Copy link
Collaborator

@Zhangxunmt Zhangxunmt left a comment

Choose a reason for hiding this comment

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

@HenryL27 , I downloaded this PR and looks like there are still tests compile errors. Can you please update the tests and pass the CI?

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (df644ff) 80.83% compared to head (1f4bfdb) 81.19%.

Files Patch % Lines
...nversation/SearchConversationsTransportAction.java 86.36% 3 Missing ⚠️
...onversation/SearchInteractionsTransportAction.java 86.36% 3 Missing ⚠️
...nsearch/ml/memory/index/ConversationMetaIndex.java 96.47% 0 Missing and 3 partials ⚠️
.../opensearch/ml/memory/index/InteractionsIndex.java 97.36% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1504      +/-   ##
============================================
+ Coverage     80.83%   81.19%   +0.36%     
- Complexity     4215     4335     +120     
============================================
  Files           404      421      +17     
  Lines         16977    17303     +326     
  Branches       1818     1829      +11     
============================================
+ Hits          13723    14049     +326     
+ Misses         2539     2537       -2     
- Partials        715      717       +2     
Flag Coverage Δ
ml-commons 81.19% <97.08%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HenryL27
Copy link
Collaborator Author

@Zhangxunmt rebased for gradle/java/lombok update. Failing CI tests are known flaky tests, not introduced by this PR. Can you try again? Thanks

@HenryL27 HenryL27 requested a review from austintlee November 30, 2023 00:51
Copy link
Collaborator

@austintlee austintlee left a comment

Choose a reason for hiding this comment

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

LGTM

@HenryL27 HenryL27 merged commit adc7da0 into opensearch-project:main Nov 30, 2023
8 of 12 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 30, 2023
* add searchConversation

Signed-off-by: HenryL27 <[email protected]>

* add searchinteractions

Signed-off-by: HenryL27 <[email protected]>

* add searchConversationsITTests

Signed-off-by: HenryL27 <[email protected]>

* add searchInteractionsITTests

Signed-off-by: HenryL27 <[email protected]>

* add unit tests for storage-layer search

Signed-off-by: HenryL27 <[email protected]>

* add Search transport actions and tests

Signed-off-by: HenryL27 <[email protected]>

* add rest search actions

Signed-off-by: HenryL27 <[email protected]>

* add search rest actions

Signed-off-by: HenryL27 <[email protected]>

* Add singular get actions at storage layer

Signed-off-by: HenryL27 <[email protected]>

* Add OpenSearhMemoryHandler unit tests for singular get

Signed-off-by: HenryL27 <[email protected]>

* Add singular get transport layer

Signed-off-by: HenryL27 <[email protected]>

* add singular get rest actions

Signed-off-by: HenryL27 <[email protected]>

* fix async return value problem

Signed-off-by: HenryL27 <[email protected]>

* address esay PR comments

Signed-off-by: HenryL27 <[email protected]>

---------

Signed-off-by: HenryL27 <[email protected]>
(cherry picked from commit adc7da0)
HenryL27 added a commit to HenryL27/ml-commons that referenced this pull request Nov 30, 2023
…ct#1504)

* add searchConversation

Signed-off-by: HenryL27 <[email protected]>

* add searchinteractions

Signed-off-by: HenryL27 <[email protected]>

* add searchConversationsITTests

Signed-off-by: HenryL27 <[email protected]>

* add searchInteractionsITTests

Signed-off-by: HenryL27 <[email protected]>

* add unit tests for storage-layer search

Signed-off-by: HenryL27 <[email protected]>

* add Search transport actions and tests

Signed-off-by: HenryL27 <[email protected]>

* add rest search actions

Signed-off-by: HenryL27 <[email protected]>

* add search rest actions

Signed-off-by: HenryL27 <[email protected]>

* Add singular get actions at storage layer

Signed-off-by: HenryL27 <[email protected]>

* Add OpenSearhMemoryHandler unit tests for singular get

Signed-off-by: HenryL27 <[email protected]>

* Add singular get transport layer

Signed-off-by: HenryL27 <[email protected]>

* add singular get rest actions

Signed-off-by: HenryL27 <[email protected]>

* fix async return value problem

Signed-off-by: HenryL27 <[email protected]>

* address esay PR comments

Signed-off-by: HenryL27 <[email protected]>

---------

Signed-off-by: HenryL27 <[email protected]>
dhrubo-os pushed a commit that referenced this pull request Dec 1, 2023
…1504)  (#1720)

* Add search and singular APIs to conversation memory (#1504)

* add searchConversation

Signed-off-by: HenryL27 <[email protected]>

* add searchinteractions

Signed-off-by: HenryL27 <[email protected]>

* add searchConversationsITTests

Signed-off-by: HenryL27 <[email protected]>

* add searchInteractionsITTests

Signed-off-by: HenryL27 <[email protected]>

* add unit tests for storage-layer search

Signed-off-by: HenryL27 <[email protected]>

* add Search transport actions and tests

Signed-off-by: HenryL27 <[email protected]>

* add rest search actions

Signed-off-by: HenryL27 <[email protected]>

* add search rest actions

Signed-off-by: HenryL27 <[email protected]>

* Add singular get actions at storage layer

Signed-off-by: HenryL27 <[email protected]>

* Add OpenSearhMemoryHandler unit tests for singular get

Signed-off-by: HenryL27 <[email protected]>

* Add singular get transport layer

Signed-off-by: HenryL27 <[email protected]>

* add singular get rest actions

Signed-off-by: HenryL27 <[email protected]>

* fix async return value problem

Signed-off-by: HenryL27 <[email protected]>

* address esay PR comments

Signed-off-by: HenryL27 <[email protected]>

---------

Signed-off-by: HenryL27 <[email protected]>

* fix apache http version

Signed-off-by: HenryL27 <[email protected]>

---------

Signed-off-by: HenryL27 <[email protected]>
austintlee pushed a commit to austintlee/ml-commons that referenced this pull request Feb 29, 2024
…ct#1504)

* add searchConversation

Signed-off-by: HenryL27 <[email protected]>

* add searchinteractions

Signed-off-by: HenryL27 <[email protected]>

* add searchConversationsITTests

Signed-off-by: HenryL27 <[email protected]>

* add searchInteractionsITTests

Signed-off-by: HenryL27 <[email protected]>

* add unit tests for storage-layer search

Signed-off-by: HenryL27 <[email protected]>

* add Search transport actions and tests

Signed-off-by: HenryL27 <[email protected]>

* add rest search actions

Signed-off-by: HenryL27 <[email protected]>

* add search rest actions

Signed-off-by: HenryL27 <[email protected]>

* Add singular get actions at storage layer

Signed-off-by: HenryL27 <[email protected]>

* Add OpenSearhMemoryHandler unit tests for singular get

Signed-off-by: HenryL27 <[email protected]>

* Add singular get transport layer

Signed-off-by: HenryL27 <[email protected]>

* add singular get rest actions

Signed-off-by: HenryL27 <[email protected]>

* fix async return value problem

Signed-off-by: HenryL27 <[email protected]>

* address esay PR comments

Signed-off-by: HenryL27 <[email protected]>

---------

Signed-off-by: HenryL27 <[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.

3 participants