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