File tree 2 files changed +33
-0
lines changed
main/java/org/springframework/ai/tool/method
test/java/org/springframework/ai/tool/method
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ public ToolCallback[] getToolCallbacks() {
66
66
AopUtils .isAopProxy (toolObject ) ? AopUtils .getTargetClass (toolObject ) : toolObject .getClass ()))
67
67
.filter (toolMethod -> toolMethod .isAnnotationPresent (Tool .class ))
68
68
.filter (toolMethod -> !isFunctionalType (toolMethod ))
69
+ .filter (ReflectionUtils .USER_DECLARED_METHODS ::matches )
69
70
.map (toolMethod -> MethodToolCallback .builder ()
70
71
.toolDefinition (ToolDefinition .from (toolMethod ))
71
72
.toolMetadata (ToolMetadata .from (toolMethod ))
Original file line number Diff line number Diff line change
1
+ package org .springframework .ai .tool .method ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+ import org .springframework .ai .tool .ToolCallback ;
5
+ import org .springframework .ai .tool .annotation .Tool ;
6
+
7
+ import static org .junit .jupiter .api .Assertions .*;
8
+
9
+ class MethodToolCallbackProviderTest {
10
+
11
+ abstract class TestObjectClass <T > {
12
+
13
+ public abstract String test (T input );
14
+ }
15
+
16
+ class TestObjectSuperClass extends TestObjectClass <String > {
17
+
18
+ @ Tool
19
+ public String test (String input ) {
20
+ return input ;
21
+ }
22
+ }
23
+
24
+ @ Test
25
+ public void buildToolsWithBridgeMethodReturnOnlyUserDeclaredMethods () {
26
+ MethodToolCallbackProvider provider = MethodToolCallbackProvider .builder ().toolObjects (new TestObjectSuperClass ()).build ();
27
+ ToolCallback [] toolCallbacks = provider .getToolCallbacks ();
28
+ assertEquals (1 , toolCallbacks .length );
29
+ assertInstanceOf (MethodToolCallback .class , toolCallbacks [0 ]);
30
+ }
31
+
32
+ }
You can’t perform that action at this time.
0 commit comments