Annotation Interface AiService


@Target(TYPE) @Introduction @Documented @AllowsReflection public @interface AiService
Registers an AI service.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    The default no-op customizer.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    A customizer can be registered to customize its creation.
    The names of the LangChain4j McpClient beans whose tools are provided to the service, for example the clients configured with the Micronaut MCP LangChain4j client.
    The name of a configured AI model.
    The name of the LangChain4j Skills bean whose Agent Skills are offered to the service, for example the skills configured with langchain4j.skills.<name>.
    The names of the ToolProvider beans that provide dynamic tools, for example the tools of MCP servers.
    Class<?>[]
    The types of the tools to include.
    Defines the service name.
  • Element Details

    • value

      @AliasFor(annotation=jakarta.inject.Named.class,member="value") @AliasFor(member="named") String value
      Defines the service name. Same as named().
      Returns:
      The service name
      Default:
      ""
    • named

      @AliasFor(annotation=jakarta.inject.Named.class, member="value") String named
      The name of a configured AI model.
      Returns:
      The model name.
      Default:
      ""
    • tools

      Class<?>[] tools
      The types of the tools to include. Can be set to an empty array to include none.
      Returns:
      The tool types
      Default:
      {}
    • toolProviders

      String[] toolProviders
      The names of the ToolProvider beans that provide dynamic tools, for example the tools of MCP servers.

      When this member is not set, the ToolProvider bean qualified with the name of the service is used, otherwise the default ToolProvider bean if there is one. Set it to an empty array to use no tool provider.

      Returns:
      The names of the tool provider beans
      Since:
      2.4.0
      Default:
      {}
    • mcpClients

      String[] mcpClients
      The names of the LangChain4j McpClient beans whose tools are provided to the service, for example the clients configured with the Micronaut MCP LangChain4j client.

      Requires dev.langchain4j:langchain4j-mcp on the classpath. When this member is set and toolProviders() is not, no ToolProvider bean is applied implicitly, so that the service only receives the tools of the named MCP clients.

      Returns:
      The names of the MCP client beans
      Since:
      2.4.0
      Default:
      {}
    • skills

      String skills
      The name of the LangChain4j Skills bean whose Agent Skills are offered to the service, for example the skills configured with langchain4j.skills.<name>.

      Requires dev.langchain4j:langchain4j-skills on the classpath. The service receives the activate_skill tool and its system message lists the available skills.

      Returns:
      The name of the skills bean
      Since:
      2.4.0
      Default:
      ""
    • customizer

      Class<? extends AiServiceCustomizer<?>> customizer
      A customizer can be registered to customize its creation.

      Normally these are picked up automatically if declared as beans, using this members allows the chosen customizer to be overridden.

      Returns:
      The customizer
      Default:
      io.micronaut.langchain4j.annotation.AiService.NoOpCustomizer.class