Annotation Tool

  • All Implemented Interfaces:
    java.lang.annotation.Annotation

    @Retention(value = RUNTIME)@Target(value = {}) 
    public @interface Tool
    
                        

    Java methods annotated with @Tool are considered tools/functions that language model can execute/call. Tool/function calling LLM capability (e.g., see OpenAI function calling documentation) is used under the hood. When used together with AiServices, a low-level ToolSpecification will be automatically created from the method signature (e.g. method name, method parameters (names and types), @Tool and @P annotations, etc.) and will be sent to the LLM. If the LLM decides to call the tool, the arguments will be parsed, and the method will be called automatically. If the return type of the method annotated with @Tool is String, the returned value will be sent to the LLM as-is. If the return type is void, "Success" string will be sent to the LLM. In all other cases, the returned value will be serialized into a JSON string and sent to the LLM.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • 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
      abstract String name() Name of the tool.
      abstract Array<String> value() Description of the tool.
      • Methods inherited from class java.lang.annotation.Annotation

        annotationType, equals, hashCode, toString
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • name

         abstract String name()

        Name of the tool. If not provided, method name will be used.

        Returns:

        name of the tool.

      • value

         abstract Array<String> value()

        Description of the tool. It should be clear and descriptive to allow language model to understand the tool's purpose and its intended use.

        Returns:

        description of the tool.