Skip to content
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

addOptionalParameter for aiServices #922

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import static dev.langchain4j.agent.tool.JsonSchemaProperty.*;
import static dev.langchain4j.internal.Utils.isNullOrBlank;
Expand Down Expand Up @@ -56,6 +57,10 @@ public static ToolSpecification toolSpecificationFrom(Method method) {
if (parameter.isAnnotationPresent(ToolMemoryId.class)) {
continue;
}
//if user define method parameter as Optional addOptionalParameter
if (parameter.getType().equals(Optional.class)) {
builder.addOptionalParameter(parameter.getName(), toJsonSchemaProperties(parameter));
Copy link
Owner

Choose a reason for hiding this comment

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

toJsonSchemaProperties will receive Optional type, but should probably receive an actual type

}
builder.addParameter(parameter.getName(), toJsonSchemaProperties(parameter));
Copy link
Owner

Choose a reason for hiding this comment

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

This should probybly be in else block.

}

Expand Down