Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* @author Thomas Vitale
* @author Christian Tzolov
* @author Daniel Garnier-Moiroux
* @author Yanming Zhou
* @since 1.0.0
*/
@AutoConfiguration
Expand All @@ -70,10 +71,9 @@ public class ToolCallingAutoConfiguration {
@Bean
@ConditionalOnMissingBean
ToolCallbackResolver toolCallbackResolver(GenericApplicationContext applicationContext,
List<ToolCallback> toolCallbacks, List<ToolCallbackProvider> tcbProviders) {
List<ToolCallback> toolCallbacks, ObjectProvider<ToolCallbackProvider> tcbProviders) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility, Would this work if there is a List instead of just multiple ToolCallbackProvider instances?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List<ToolCallbackProvider> bean will not be injected via ObjectProvider<ToolCallbackProvider>, but I don't think anyone would do that, and ObjectProvider<ToolCallbackProvider> is the recommended way by Spring Boot, you can refer to other AutoConfigurations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on using ObjectProvider being the better approach. My question is mainly about backwards compatibility. Since we already had "List tcbProviders", we don't want to break the compatibility for those who already uses "List tcbProviders". Perhaps, we should use ObjectProvider<List>. cc @tzolov

List<ToolCallback> allFunctionAndToolCallbacks = new ArrayList<>(toolCallbacks);
tcbProviders.stream()
.filter(pr -> !isMcpToolCallbackProvider(ResolvableType.forInstance(pr)))
tcbProviders.stream(clazz -> !isMcpToolCallbackProvider(ResolvableType.forClass(clazz)))
.map(pr -> List.of(pr.getToolCallbacks()))
.forEach(allFunctionAndToolCallbacks::addAll);

Expand Down