Class ToolSpecifications
java.lang.Object
dev.langchain4j.agent.tool.ToolSpecifications
Utility methods for
ToolSpecifications.-
Method Summary
Modifier and TypeMethodDescriptionstatic ToolSpecificationtoolSpecificationFrom(Method method) Returns theToolSpecificationfor the given method annotated with @Tool.static List<ToolSpecification> toolSpecificationsFrom(Class<?> classWithTools) ReturnsToolSpecifications for all methods annotated with @Toolwithin the specified class.static List<ToolSpecification> toolSpecificationsFrom(Object objectWithTools) ReturnsToolSpecifications for all methods annotated with @Toolwithin the class of the specified object.static voidvalidateSpecifications(List<ToolSpecification> toolSpecifications) Validates all theToolSpecifications.
-
Method Details
-
toolSpecificationsFrom
ReturnsToolSpecifications for all methods annotated with @Toolwithin the specified class.- Parameters:
classWithTools- the class.- Returns:
- the
ToolSpecifications.
-
toolSpecificationsFrom
ReturnsToolSpecifications for all methods annotated with @Toolwithin the class of the specified object.- Parameters:
objectWithTools- the object.- Returns:
- the
ToolSpecifications.
-
validateSpecifications
public static void validateSpecifications(List<ToolSpecification> toolSpecifications) throws IllegalArgumentException Validates all theToolSpecifications. The validation checks for duplicate method names. ThrowsIllegalArgumentExceptionif validation fails- Parameters:
toolSpecifications- list of ToolSpecification to be validated.- Throws:
IllegalArgumentException
-
toolSpecificationFrom
Returns theToolSpecificationfor the given method annotated with @Tool.- Parameters:
method- the method.- Returns:
- the
ToolSpecification.
-