Interface MethodToolFactory

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Tool fromMethod(Object instance, KFunction<?> method, ObjectMapper objectMapper) Create a Tool from a Kotlin method annotated with LlmTool.
      Tool fromMethod(Object instance, Method method, ObjectMapper objectMapper) Create a Tool from a Java method annotated with LlmTool.
      List<Tool> fromInstance(Object instance, ObjectMapper objectMapper) Create Tools from all methods annotated with LlmTool on an instance.
      List<Tool> safelyFromInstance(Object instance, ObjectMapper objectMapper) Safely create Tools from an instance, returning empty list if no annotated methods found.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • fromMethod

         Tool fromMethod(Object instance, KFunction<?> method, ObjectMapper objectMapper)

        Create a Tool from a Kotlin method annotated with LlmTool.

        Parameters:
        instance - The object instance containing the method
        method - The Kotlin method to wrap as a tool
        objectMapper - ObjectMapper for JSON parsing (optional)
        Returns:

        A Tool that invokes the method

      • fromMethod

         Tool fromMethod(Object instance, Method method, ObjectMapper objectMapper)

        Create a Tool from a Java method annotated with LlmTool.

        Parameters:
        instance - The object instance containing the method
        method - The Java method to wrap as a tool
        objectMapper - ObjectMapper for JSON parsing (optional)
        Returns:

        A Tool that invokes the method

      • fromInstance

         List<Tool> fromInstance(Object instance, ObjectMapper objectMapper)

        Create Tools from all methods annotated with LlmTool on an instance.

        If the instance's class is annotated with @UnfoldingTools or @MatryoshkaTools, returns a single UnfoldingTool containing all the inner tools. Otherwise, returns individual tools for each annotated method.

        Parameters:
        instance - The object instance to scan for annotated methods
        objectMapper - ObjectMapper for JSON parsing (optional)
        Returns:

        List of Tools, one for each annotated method (or single UnfoldingTool if @UnfoldingTools/@MatryoshkaTools present)

      • safelyFromInstance

         List<Tool> safelyFromInstance(Object instance, ObjectMapper objectMapper)

        Safely create Tools from an instance, returning empty list if no annotated methods found. This is useful when you want to scan an object that may or may not have tool methods.

        Parameters:
        instance - The object instance to scan for annotated methods
        objectMapper - ObjectMapper for JSON parsing (optional)
        Returns:

        List of Tools, or empty list if no annotated methods found