Skip to content

Commit

Permalink
Change the sequence of putting parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
qianheng-aws committed Aug 21, 2024
1 parent 2f1f610 commit 80461b5
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ Tool createTool(MLToolSpec toolSpec) {
@VisibleForTesting
Map<String, String> getToolExecuteParams(MLToolSpec toolSpec, Map<String, String> params) {
Map<String, String> executeParams = new HashMap<>();
if (toolSpec.getParameters() != null) {
executeParams.putAll(toolSpec.getParameters());
}
for (String key : params.keySet()) {
String toBeReplaced = null;
if (key.startsWith(toolSpec.getType() + ".")) {
Expand All @@ -287,15 +284,16 @@ Map<String, String> getToolExecuteParams(MLToolSpec toolSpec, Map<String, String
executeParams.put(key, params.get(key));
}
}
// tooSpec parameter may override the parameters in params.
if (toolSpec.getParameters() != null) {
executeParams.putAll(toolSpec.getParameters());
}

if (executeParams.containsKey("input")) {
String input = executeParams.get("input");
StringSubstitutor substitutor = new StringSubstitutor(executeParams, "${parameters.", "}");
input = substitutor.replace(input);
executeParams.put("input", input);
// Remove the current input from params to avoid passing it to the following tools.
// Otherwise, it will override the default input of the following tools.
params.remove("input");
}
return executeParams;
}
Expand Down

0 comments on commit 80461b5

Please sign in to comment.