Skip to content

Update tools.adoc About toolDefinition parameter transfer error #3468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RobinElysia
Copy link
Contributor

Method method = ReflectionUtils.findMethod(DateTimeTools.class, "getCurrentDateTime");
ToolCallback toolCallback = MethodToolCallback.builder()
.toolDefinition(ToolDefinition.builder() // Shouldn't method be passed here?
.description("Get the current date and time in the user's timezone")
.build())
.toolMethod(method)
.toolObject(new DateTimeTools())
.build();

There shouldn't be a method here. This is obviously wrong.

Signed-off-by: qwp_p <70431503+RobinElysia@users.noreply.github.com>
Copy link
Contributor

@sunyuhan1998 sunyuhan1998 left a comment

Choose a reason for hiding this comment

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

Please refer to the following source code. I don't think there is any error in the document itself. Could you please double-check it?

public static DefaultToolDefinition.Builder builder(Method method) {

@RobinElysia
Copy link
Contributor Author

请参考以下来源代码。我认为文档本身没有任何错误。您可以再检查一下吗?

public static DefaultToolDefinition.Builder builder(Method method) {

Ok, maybe it's my version problem.😂

@RobinElysia
Copy link
Contributor Author

Please refer to the following source code. I don't think there is any error in the document itself. Could you please double-check it?

public static DefaultToolDefinition.Builder builder(Method method) {

No, no, no, that's not right. The version is fine. Sorry, it seems to be the fault of the document sample.😦

@RobinElysia
Copy link
Contributor Author

请参考以下来源代码。我认为文档本身没有任何错误。您可以再检查一下吗?

public static DefaultToolDefinition.Builder builder(Method method) {

This should be the interface:
spring-ai-model/src/main/java/org/springframework/ai/tool/definition/ToolDefinition.java

@sunyuhan1998
Copy link
Contributor

sunyuhan1998 commented Jun 9, 2025

I'm a bit confused about what you mean, the sample code in the current sample documentation is as follows:

ToolCallback toolCallback = MethodToolCallback.builder()
.toolDefinition(ToolDefinitions.builder(method)
.description("Get the current date and time in the user's timezone")
.build())
.toolMethod(method)
.toolObject(new DateTimeTools())
.build();

According to the interface definition, the org.springframework.ai.tool.method.MethodToolCallback.Builder#toolDefinition method receives a parameter of type ToolDefinition:

public Builder toolDefinition(ToolDefinition toolDefinition) {
this.toolDefinition = toolDefinition;
return this;
}

and ToolDefinitions.builder(method).build() returns a ToolDefinition:

which I don't seem to see a problem with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants