-
Notifications
You must be signed in to change notification settings - Fork 183
Add escape output parameter #4179
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import static org.opensearch.ml.common.conversation.ActionConstants.AI_RESPONSE_FIELD; | ||
import static org.opensearch.ml.common.conversation.ActionConstants.MEMORY_ID; | ||
import static org.opensearch.ml.common.conversation.ActionConstants.PARENT_INTERACTION_ID_FIELD; | ||
import static org.opensearch.ml.common.utils.ToolUtils.TOOL_ESCAPE_OUTPUT; | ||
import static org.opensearch.ml.common.utils.ToolUtils.TOOL_OUTPUT_FILTERS_FIELD; | ||
import static org.opensearch.ml.common.utils.ToolUtils.filterToolOutput; | ||
import static org.opensearch.ml.common.utils.ToolUtils.getToolName; | ||
|
@@ -262,7 +263,11 @@ private void processOutput( | |
String outputKey = toolName + ".output"; | ||
Map<String, String> toolParameters = ToolUtils.buildToolParameters(params, previousToolSpec, tenantId); | ||
String filteredOutput = parseResponse(filterToolOutput(toolParameters, output)); | ||
params.put(outputKey, StringUtils.prepareJsonValue(filteredOutput)); | ||
params | ||
.put( | ||
outputKey, | ||
StringUtils.prepareJsonValue(filteredOutput, Boolean.parseBoolean(toolParameters.getOrDefault(TOOL_ESCAPE_OUTPUT, "false"))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we expecting customer to provide this settings: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, as tool parameters whebln configure the agent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An example
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just trying to understand, based on what condition/experience customer will try to set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that depends on the use case, if the tool output will used to concat with other strings to build a prompt for LLM, that's a typical case we need to set it as true. That is the case for chatbot question suggestor which is a MLModelTool and leverage previous tool output to build the prompt for LLM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
+1 |
||
); | ||
boolean traceDisabled = params.containsKey(DISABLE_TRACE) && Boolean.parseBoolean(params.get(DISABLE_TRACE)); | ||
|
||
if (previousToolSpec.isIncludeOutputInAgentResponse() || finalI == toolSpecs.size()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is misleading here, you are actually escaping the plain text, but passing "escape" parameter as false. May be rename "escape" parameter in the API definition, which should understand it is only about json string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense, i will update it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename it to
escapeJson