-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* code refactoring on MLCommonsClientAccessor request
Signed-off-by: Fen Qin <mfenqin@amazon.com> * fix unit tests Signed-off-by: Fen Qin <mfenqin@amazon.com> * Implements inheritance pattern to break down inference request Signed-off-by: Fen Qin <mfenqin@amazon.com>
- Loading branch information
Showing
20 changed files
with
364 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/opensearch/neuralsearch/processor/InferenceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.neuralsearch.processor; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
import lombok.Setter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@SuperBuilder | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
/** | ||
* Base abstract class for inference requests. | ||
* This class contains common fields and behaviors shared across different types of inference requests. | ||
*/ | ||
public abstract class InferenceRequest { | ||
/** | ||
* Unique identifier for the model to be used for inference. | ||
* This field is required and cannot be null. | ||
*/ | ||
@NonNull | ||
private String modelId; | ||
/** | ||
* List of targetResponseFilters to be applied. | ||
* Defaults value if not specified. | ||
*/ | ||
@Builder.Default | ||
private List<String> targetResponseFilters = List.of("sentence_embedding"); | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/opensearch/neuralsearch/processor/MapInferenceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.neuralsearch.processor; | ||
|
||
import java.util.Map; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
/** | ||
* Implementation of InferenceRequest for inputObjects based inference requests. | ||
* Use this class when the input data consists of key-value pairs. | ||
* | ||
* @see InferenceRequest | ||
*/ | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
public class MapInferenceRequest extends InferenceRequest { | ||
private Map<String, String> inputObjects; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/opensearch/neuralsearch/processor/SimilarityInferenceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.neuralsearch.processor; | ||
|
||
import lombok.NoArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
/** | ||
* Implementation of InferenceRequest for similarity based text inference requests. | ||
* | ||
* @see TextInferenceRequest | ||
*/ | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
public class SimilarityInferenceRequest extends TextInferenceRequest { | ||
private String queryText; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.