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
base: main
Are you sure you want to change the base?
addOptionalParameter for aiServices #922
Conversation
@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)); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
when use tools if user define method parameter as Optional addOptionalParameter