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

Conversation

zhangdashuai11
Copy link

when use tools if user define method parameter as Optional addOptionalParameter

@langchain4j
Copy link
Owner

@zhangdashuai11 please add tests and document this change. Please see https://github.com/langchain4j/langchain4j/blob/main/CONTRIBUTING.md

//if user define method parameter as Optional addOptionalParameter
if (parameter.getType().equals(Optional.class)) {
builder.addOptionalParameter(parameter.getName(), toJsonSchemaProperties(parameter));
}
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.

@@ -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

@langchain4j langchain4j added the P3 Medium priority label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Medium priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants