Class ToolCallingAutoConfiguration

java.lang.Object
org.springframework.ai.model.tool.autoconfigure.ToolCallingAutoConfiguration
All Implemented Interfaces:
org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor

@AutoConfiguration @ConditionalOnClass(ChatModel.class) @EnableConfigurationProperties(ToolCallingProperties.class) public class ToolCallingAutoConfiguration extends Object implements org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
Auto-configuration for common tool calling features of ChatModel.
Since:
1.0.0
Author:
Thomas Vitale, Christian Tzolov, Daniel Garnier-Moiroux
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
    Wrap ToolCallbackProvider beans that are not MCP-related into a named bean, which will be picked up by the toolCallbackResolver(org.springframework.context.support.GenericApplicationContext, java.util.List<org.springframework.ai.tool.ToolCallback>, java.util.List<org.springframework.ai.tool.ToolCallbackProvider>).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor

    postProcessBeanFactory
  • Constructor Details

    • ToolCallingAutoConfiguration

      public ToolCallingAutoConfiguration()
  • Method Details

    • postProcessBeanDefinitionRegistry

      public void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException
      Wrap ToolCallbackProvider beans that are not MCP-related into a named bean, which will be picked up by the toolCallbackResolver(org.springframework.context.support.GenericApplicationContext, java.util.List<org.springframework.ai.tool.ToolCallback>, java.util.List<org.springframework.ai.tool.ToolCallbackProvider>).

      MCP providers must be excluded, because they may depend on a ChatClient to do sampling. The chat client, in turn, depends on a ToolCallbackResolver. To do the detection, we depend on the exposed bean type. If a bean uses a factory method which returns a ToolCallbackProvider, which is an MCP provider under the hood, it will be included in the list.

      Specified by:
      postProcessBeanDefinitionRegistry in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Throws:
      org.springframework.beans.BeansException