|
23 | 23 |
|
24 | 24 | import org.junit.jupiter.api.Test;
|
25 | 25 |
|
| 26 | +import org.springframework.ai.tool.ToolCallback; |
26 | 27 | import org.springframework.ai.tool.annotation.Tool;
|
27 | 28 | import org.springframework.ai.tool.execution.DefaultToolCallResultConverter;
|
28 | 29 | import org.springframework.ai.tool.execution.ToolCallResultConverter;
|
29 | 30 | import org.springframework.core.annotation.AliasFor;
|
30 | 31 |
|
31 | 32 | import static org.assertj.core.api.Assertions.assertThat;
|
32 | 33 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
| 34 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 35 | +import static org.junit.jupiter.api.Assertions.assertInstanceOf; |
33 | 36 |
|
34 | 37 | /**
|
35 | 38 | * Unit tests for {@link MethodToolCallbackProvider}.
|
@@ -112,6 +115,31 @@ void whenEnhanceToolObjectHasMixOfValidAndFunctionalTypeToolMethodsThenSucceed()
|
112 | 115 | assertThat(provider.getToolCallbacks()[0].getToolDefinition().name()).isEqualTo("validTool");
|
113 | 116 | }
|
114 | 117 |
|
| 118 | + @Test |
| 119 | + public void buildToolsWithBridgeMethodReturnOnlyUserDeclaredMethods() { |
| 120 | + MethodToolCallbackProvider provider = MethodToolCallbackProvider.builder() |
| 121 | + .toolObjects(new TestObjectSuperClass()) |
| 122 | + .build(); |
| 123 | + ToolCallback[] toolCallbacks = provider.getToolCallbacks(); |
| 124 | + assertEquals(1, toolCallbacks.length); |
| 125 | + assertInstanceOf(MethodToolCallback.class, toolCallbacks[0]); |
| 126 | + } |
| 127 | + |
| 128 | + abstract class TestObjectClass<T> { |
| 129 | + |
| 130 | + public abstract String test(T input); |
| 131 | + |
| 132 | + } |
| 133 | + |
| 134 | + class TestObjectSuperClass extends TestObjectClass<String> { |
| 135 | + |
| 136 | + @Tool |
| 137 | + public String test(String input) { |
| 138 | + return input; |
| 139 | + } |
| 140 | + |
| 141 | + } |
| 142 | + |
115 | 143 | static class ValidToolObject {
|
116 | 144 |
|
117 | 145 | @Tool
|
|
0 commit comments