-
Notifications
You must be signed in to change notification settings - Fork 136
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
add action input as parameters for tool execution in conversational agent #3200
base: main
Are you sure you want to change the base?
Conversation
…gent Signed-off-by: Jing Zhang <jngz@amazon.com>
toolParams.put("action_input", actionInput); | ||
if (isJson(actionInput)) { |
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.
can actionInput
be null here?
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.
Yes.
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.
will it be a problem if we put actionInput
as null within the params? I can see that isJson
will check for null, but wondering if line 475 can cause issue
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.
Good catch, @pyek-bot looking at MLToolSpec
we'd get here:
ml-commons/common/src/main/java/org/opensearch/ml/common/utils/StringUtils.java
Lines 109 to 118 in 5cfdc3c
Object value = parameterObjs.get(key); | |
try { | |
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> { | |
if (value instanceof String) { | |
parameters.put(key, (String) value); | |
} else { | |
parameters.put(key, gson.toJson(value)); | |
} | |
return null; | |
}); |
and Gson.toJson
internally uses ...Object.getClass()
which may throw NPE
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.
looks good, thanks for validating!
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.
@jngz-es Can you add a test case for null
value ? From code https://github.com/opensearch-project/ml-commons/blob/main/common/src/main/java/org/opensearch/ml/common/utils/StringUtils.java#L69, it will throw null pointer exception
tests passed but failed in upload, not related to this code change. Approved.
|
@@ -472,6 +472,11 @@ public static Map<String, String> constructToolParams( | |||
if (toolSpecConfigMap != null) { | |||
toolParams.putAll(toolSpecConfigMap); | |||
} | |||
toolParams.put("action_input", actionInput); |
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.
action_input
looks like coupled with code logic. Change to more readable name ?
The changes for AgentUtils look fine, but is AgentUtils used for conversational agents? The tool parameters are build inside I showed a code proposal for I would also highly recommend to add the new "action_input" parameter to flow agents (i.e. |
Description
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
#3134
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.