Skip to content

Commit 9cb2c1d

Browse files
committed
2057 - SF
1 parent aa36324 commit 9cb2c1d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sdks/backend/java/ai-toolkit-spring/src/main/java/com/bytechef/ai/toolkit/tool/ToolCallbackProviderImpl.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ public ToolCallbackProviderImpl(
5353
public ToolCallback[] getToolCallbacks() {
5454
List<ToolCallback> toolCallbacks = new ArrayList<>();
5555

56-
List<ToolModel> toolModels = new ToolClient(apiKey, baseUrl, environment).getTools(externalUserId)
57-
.entrySet()
56+
ToolClient toolClient = new ToolClient(apiKey, baseUrl, environment);
57+
58+
List<ToolModel> toolModels = toolClient.getTools(externalUserId)
59+
.values()
5860
.stream()
59-
.flatMap(entry -> entry.getValue()
60-
.stream())
61+
.flatMap(List::stream)
6162
.toList();
6263

6364
for (ToolModel toolModel : toolModels) {
@@ -83,7 +84,10 @@ public ToolCallback[] getToolCallbacks() {
8384
private Function<Map<String, Object>, Object> getToolCallbackFunction(
8485
String toolName, String externalUserId, String apiKey, Environment environment) {
8586

86-
return parameters -> new ToolClient(
87-
apiKey, baseUrl, environment).executeTool(externalUserId, toolName, parameters);
87+
return parameters -> {
88+
ToolClient toolClient = new ToolClient(apiKey, baseUrl, environment);
89+
90+
return toolClient.executeTool(externalUserId, toolName, parameters);
91+
};
8892
}
8993
}

0 commit comments

Comments
 (0)