-
Notifications
You must be signed in to change notification settings - Fork 62
Description
When using the built in reflection mechanism to create functions from java.lang.Methods with the current sdk (1.12.0) Tool.builder().functions(method1, method2) does not allow for passing function description or parameter description or returned type schema.
Moreover if you try to use FunctionDeclarations directly, the SDK wont trigger function calls automatically because AfcUtil looks for a Method object under Tools.functions to perform the invokation
If you try to use FunctionDeclaration (via builder) and the Tools.functions(Method) the sdk converts the method to a FunctionDeclaration with the same name and the server reports an error complayining it has been offered two functions with the same name.
A possible solution would be to add a java.lang.Method attribute to FunctionDeclarations (e.g. "method") so the method object can pass through to the AfcUtil code that performs the invokation and a way to produce FunctionDeclarations from a java.lang.Method so the user can fill in the function description, params description and returned object description if needed. Tool.functions() would become irrelevant() and only FunctionDeclarations could be used.
Another option (that would conserver Tools.functions) would be to provide an annotation to annotate methods and method parameters and then look for this annotation when creating the FunctionDeclaration from the method object. Something like this:
/**
*
- @author pablo
*/
@retention(RetentionPolicy.RUNTIME)
@target({ElementType.METHOD, ElementType.PARAMETER})
public @interface AfcDescription {
String value();
}