Skip to content

Commit d570eea

Browse files
authored
## Issue Fixes langchain4j/langchain4j#2429 ## Change Keep original method that contains original method parameter names ## General checklist - [X] There are no breaking changes - [ ] I have added unit and/or integration tests for my change - [ ] The tests cover both positive and negative cases - [X] I have manually run all the unit and integration tests in the module I have added/changed, and they are all green - [ ] I have added/updated the [documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs) - [ ] I have added an example in the [examples repo](https://github.com/langchain4j/langchain4j-examples) (only for "big" features)
1 parent be4ecc5 commit d570eea

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: langchain4j-spring-boot-starter/src/main/java/dev/langchain4j/service/spring/AiServiceFactory.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,14 @@ private Map<ToolSpecification, ToolExecutor> aopEnhancedTools(Object enhancedToo
144144
for (Method originalToolMethod : originalToolClass.getDeclaredMethods()) {
145145
if (originalToolMethod.isAnnotationPresent(Tool.class)) {
146146
Arrays.stream(enhancedTool.getClass().getDeclaredMethods())
147-
.filter(m -> m.getName().equals(originalToolMethod.getName()))
148-
.findFirst()
149-
.ifPresent(enhancedMethod -> {
150-
ToolSpecification toolSpecification = toolSpecificationFrom(originalToolMethod);
151-
toolExecutors.put(toolSpecification, new DefaultToolExecutor(enhancedTool, enhancedMethod));
152-
});
147+
// TODO match by complete method signature, not only by name (there can be multiple methods with the same name)
148+
.filter(m -> m.getName().equals(originalToolMethod.getName()))
149+
.findFirst()
150+
.ifPresent(enhancedToolMethod -> {
151+
ToolSpecification toolSpecification = toolSpecificationFrom(originalToolMethod);
152+
ToolExecutor executor = new DefaultToolExecutor(enhancedTool, originalToolMethod, enhancedToolMethod);
153+
toolExecutors.put(toolSpecification, executor);
154+
});
153155
}
154156
}
155157
return toolExecutors;

0 commit comments

Comments
 (0)