Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Lee <[email protected]>
  • Loading branch information
austintlee committed Sep 5, 2023
1 parent e076c92 commit 8cbac4c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import static org.opensearch.ml.common.CommonValue.ML_TASK_INDEX;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -680,32 +681,42 @@ public List<Setting<?>> getSettings() {

@Override
public List<SearchPlugin.SearchExtSpec<?>> getSearchExts() {
return ragSearchPipelineEnabled
? List
.of(
List<SearchPlugin.SearchExtSpec<?>> searchExts = new ArrayList<>();

if (ragSearchPipelineEnabled) {
searchExts
.add(
new SearchPlugin.SearchExtSpec<>(
GenerativeQAParamExtBuilder.PARAMETER_NAME,
input -> new GenerativeQAParamExtBuilder(input),
parser -> GenerativeQAParamExtBuilder.parse(parser)
)
)
// Feature not enabled
: Collections.emptyList();
);
}

return searchExts;
}

@Override
public Map<String, Processor.Factory<SearchRequestProcessor>> getRequestProcessors(Parameters parameters) {
return ragSearchPipelineEnabled
? Map.of(GenerativeQAProcessorConstants.REQUEST_PROCESSOR_TYPE, new GenerativeQARequestProcessor.Factory())
// Feature not enabled
: Collections.emptyMap();
Map<String, Processor.Factory<SearchRequestProcessor>> requestProcessors = new HashMap<>();

if (ragSearchPipelineEnabled) {
requestProcessors.put(GenerativeQAProcessorConstants.REQUEST_PROCESSOR_TYPE, new GenerativeQARequestProcessor.Factory());
}

return requestProcessors;
}

@Override
public Map<String, Processor.Factory<SearchResponseProcessor>> getResponseProcessors(Parameters parameters) {
return ragSearchPipelineEnabled
? Map.of(GenerativeQAProcessorConstants.RESPONSE_PROCESSOR_TYPE, new GenerativeQAResponseProcessor.Factory(this.client))
// Feature not enabled
: Collections.emptyMap();
Map<String, Processor.Factory<SearchResponseProcessor>> responseProcessors = new HashMap<>();

if (ragSearchPipelineEnabled) {
responseProcessors
.put(GenerativeQAProcessorConstants.RESPONSE_PROCESSOR_TYPE, new GenerativeQAResponseProcessor.Factory(this.client));
}

return responseProcessors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public List<Interaction> getInteractions(String conversationId, int lastN) {

List<Interaction> interactions = new ArrayList<>();
int from = 0;
boolean done = false;
boolean allInteractionsFetched = false;
int maxResults = lastN;
do {
GetInteractionsResponse response =
Expand All @@ -92,8 +92,8 @@ public List<Interaction> getInteractions(String conversationId, int lastN) {
break;
}
log.info("Interactions: {}, from: {}, maxResults: {}", interactions, from, maxResults);
done = !response.hasMorePages();
} while (from < lastN && !done);
allInteractionsFetched = !response.hasMorePages();
} while (from < lastN && !allInteractionsFetched);

return interactions;
}
Expand Down

0 comments on commit 8cbac4c

Please sign in to comment.