1 Answer
- Newest
- Most votes
- Most comments
1
Found the problem, instead of using a String the schema need to be built using the Document interface like so:
Document search = Document.mapBuilder()
.putString("type", "string")
.putString("description", "the string to search in the db").build();
Document required = Document.listBuilder()
.addString("search").build();
Document properties = Document.mapBuilder()
.putDocument("search", search).build();
Document json = Document.mapBuilder()
.putString("type", "object")
.putDocument("properties", properties)
.putDocument("required", required).build();
This code generate a Json schema equivalent to the one i was using but it is built automagically and for some reason this one work. i also had to change the CustomToolSpecification class:
@NoArgsConstructor
@Getter
public abstract class CustomToolSpecification {
private ToolSpecification specification;
private ToolInputSchema inputSchema;
private Tool tool;
private void initializeInputSchema(Document json){
this.inputSchema = ToolInputSchema.builder().json(json).build();
}
private void initializeSpecification(String name, String description, Document json){
initializeInputSchema(json);
this.specification =
ToolSpecification.builder()
.name(name)
.description(description)
.inputSchema(this.inputSchema)
.build();
}
protected void initializeTool(String name, String description, Document json) {
initializeSpecification(name, description, json);
this.tool =
Tool.builder()
.toolSpec(this.specification).build();
}
}
