Skip to content

Commit e296ef6

Browse files
committed
tool convenience factory created
1 parent 94efb12 commit e296ef6

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

zsmith/src/main/java/airhacks/zsmith/tools/control/Tool.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package airhacks.zsmith.tools.control;
22

33
import java.util.List;
4+
import java.util.function.Function;
45

56
import org.json.JSONArray;
67
import org.json.JSONObject;
@@ -47,6 +48,16 @@ public Prop<E> optional() {
4748
}
4849
}
4950

51+
static Tool of(String name, String description, String inputSchema,
52+
Function<JSONObject, String> execute) {
53+
record SimpleTool(String toolName, String description, String inputSchema,
54+
Function<JSONObject, String> fn) implements Tool {
55+
@Override
56+
public String execute(JSONObject input) { return fn.apply(input); }
57+
}
58+
return new SimpleTool(name, description, inputSchema, execute);
59+
}
60+
5061
static String emptySchema() {
5162
return """
5263
{"type":"object","properties":{}}""";

zsmith/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2026.06.12.04
1+
2026.06.13.01

0 commit comments

Comments
 (0)