Skip to content

Commit

Permalink
ignore runtime level override
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Nov 23, 2023
1 parent 801f917 commit 9918269
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,13 @@ private void runReAct(
}
} else {
Object result = output;
Tool tool = tools.get(lastAction.get());
if (tool != null && tool.includeOutputInAgentResponse()) {
MLToolSpec toolSpec = toolSpecMap.get(lastAction.get());
if (toolSpec != null && toolSpec.isIncludeOutputInAgentResponse()) {
String outputString = output instanceof String
? (String) output
: AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> gson.toJson(output));

String toolOutputKey = String.format("%s.output", tool.getType());
String toolOutputKey = String.format("%s.output", toolSpec.getType());
if (additionalInfo.get(toolOutputKey) != null) {
List<String> list = (List<String>) additionalInfo.get(toolOutputKey);
list.add(outputString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package org.opensearch.ml.engine.tools;

import static org.opensearch.ml.common.agent.MLToolSpec.INCLUDE_OUTPUT_IN_AGENT_RESPONSE;

import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -47,13 +45,11 @@ public class VisualizationsTool implements Tool {
private final Client client;
@Getter
private final String index;
private final boolean includeOutputInAgentResponse;

@Builder
public VisualizationsTool(Client client, String index, boolean includeOutputInAgentResponse) {
public VisualizationsTool(Client client, String index) {
this.client = client;
this.index = index;
this.includeOutputInAgentResponse = includeOutputInAgentResponse;
}

@Override
Expand Down Expand Up @@ -142,11 +138,6 @@ public boolean validate(Map<String, String> parameters) {
return parameters.containsKey("input") && !Strings.isNullOrEmpty(parameters.get("input"));
}

@Override
public boolean includeOutputInAgentResponse() {
return this.includeOutputInAgentResponse;
}

public static class Factory implements Tool.Factory<VisualizationsTool> {
private Client client;

Expand All @@ -172,14 +163,7 @@ public void init(Client client) {
@Override
public VisualizationsTool create(Map<String, Object> params) {
String index = params.get("index") == null ? ".kibana" : (String) params.get("index");
boolean includeOutputInAgentResponse = params.get(INCLUDE_OUTPUT_IN_AGENT_RESPONSE) != null
&& Boolean.parseBoolean((String) params.get(INCLUDE_OUTPUT_IN_AGENT_RESPONSE));
return VisualizationsTool
.builder()
.client(client)
.index(index)
.includeOutputInAgentResponse(includeOutputInAgentResponse)
.build();
return VisualizationsTool.builder().client(client).index(index).build();
}

@Override
Expand Down

0 comments on commit 9918269

Please sign in to comment.