Class ToolRegistry

java.lang.Object
io.micronaut.langchain4j.tools.ToolRegistry
All Implemented Interfaces:
io.micronaut.context.processor.ExecutableMethodProcessor<dev.langchain4j.agent.tool.Tool>

@Singleton public class ToolRegistry extends Object implements io.micronaut.context.processor.ExecutableMethodProcessor<dev.langchain4j.agent.tool.Tool>
Register of tools.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ToolRegistry(io.micronaut.context.BeanContext beanContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull List<dev.langchain4j.service.tool.AiServiceTool>
    getAiServiceTools(@NonNull Set<?> toolTypes)
    Get the tools of the beans of the given types, as AiServiceTools invoking the Tool methods through their Micronaut ExecutableMethod: unlike the tool objects of getToolsTyped(Set), they let LangChain4j call the tools without scanning and invoking the methods reflectively.
    @NonNull List<dev.langchain4j.service.tool.AiServiceTool>
    Get all available tools, as AiServiceTools invoking the Tool methods through their Micronaut ExecutableMethod.
    Get all available tools.
    getToolsTyped(Set<?> toolTypes)
    Get tools for the given types.
    <B> void
    process(io.micronaut.inject.BeanDefinition<B> beanDefinition, io.micronaut.inject.ExecutableMethod<B,?> method)
     

    Methods inherited from class Object

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

    • ToolRegistry

      public ToolRegistry(io.micronaut.context.BeanContext beanContext)
  • Method Details

    • process

      public <B> void process(io.micronaut.inject.BeanDefinition<B> beanDefinition, io.micronaut.inject.ExecutableMethod<B,?> method)
      Specified by:
      process in interface io.micronaut.context.processor.ExecutableMethodProcessor<dev.langchain4j.agent.tool.Tool>
    • getAllTools

      public List<Object> getAllTools()
      Get all available tools.
      Returns:
      The tools
    • getToolsTyped

      public List<Object> getToolsTyped(Set<?> toolTypes)
      Get tools for the given types.
      Parameters:
      toolTypes - The tool types.
      Returns:
      A list of types
    • getAiServiceTools

      public @NonNull List<dev.langchain4j.service.tool.AiServiceTool> getAiServiceTools(@NonNull Set<?> toolTypes)
      Get the tools of the beans of the given types, as AiServiceTools invoking the Tool methods through their Micronaut ExecutableMethod: unlike the tool objects of getToolsTyped(Set), they let LangChain4j call the tools without scanning and invoking the methods reflectively.
      Parameters:
      toolTypes - The tool types
      Returns:
      The tools
      Since:
      2.4.0
    • getAllAiServiceTools

      public @NonNull List<dev.langchain4j.service.tool.AiServiceTool> getAllAiServiceTools()
      Get all available tools, as AiServiceTools invoking the Tool methods through their Micronaut ExecutableMethod.
      Returns:
      The tools
      Since:
      2.4.0