Skip to content

The isFunctionalType method of MethodToolVNet Provider is incorrect, resulting in some cases where the tool cannot be registered #3355

Closed
@TheEterna

Description

@TheEterna
 private boolean isFunctionalType(Method toolMethod) {
		var isFunction = ClassUtils.isAssignable(toolMethod.getReturnType(), Function.class)
				|| ClassUtils.isAssignable(toolMethod.getReturnType(), Supplier.class)
				|| ClassUtils.isAssignable(toolMethod.getReturnType(), Consumer.class);
		if (isFunction) {
			logger.warn("Method {} is annotated with @Tool but returns a functional type. "
					+ "This is not supported and the method will be ignored.", toolMethod.getName());
		}
		return isFunction;
	}

The isFunctionalType method of class MethodToolCallbackProvider has a bug ( Unable to correctly determine function type ),fixed:

 private boolean isFunctionalType(Method toolMethod) {
        var isFunction = ClassUtils.isAssignable(Function.class, toolMethod.getReturnType())
                || ClassUtils.isAssignable(Supplier.class, toolMethod.getReturnType())
                || ClassUtils.isAssignable(Consumer.class, toolMethod.getReturnType());
        if (isFunction) {
            log.warn("Method {} is annotated with @Tool but returns a functional type. "
                    + "This is not supported and the method will be ignored.", toolMethod.getName());
        }

        return isFunction;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions