-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcurrentDate
More file actions
executable file
·39 lines (30 loc) · 1.18 KB
/
Copy pathcurrentDate
File metadata and controls
executable file
·39 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/java --enable-native-access=ALL-UNNAMED --class-path=../zsmith/zbo/zsmith.jar:../zsmith/zbo/lightmetal.jar --source 25
import java.time.LocalDate;
import airhacks.zsmith.agent.boundary.Agent;
import airhacks.zsmith.tools.boundary.Tool;
/**
* When {@code lightmetal.jar} is present on the classpath, zsmith communicates
* with LightMetal in-process (no HTTP, no IPC) — both run inside the same JVM
* and share the same heap.
*/
void main() {
var currentDate = Tool.of(
"current_date",
"Returns the current date in ISO format (yyyy-MM-dd).",
_ -> LocalDate.now().toString());
var printMessage = Tool.of(
"print_user_message",
"Prints a message to the user's console.",
Tool.schema(Tool.Prop.string(PrintField.message, "The message to print to the user")),
input -> {
IO.println(input.getString("message"));
return "Message printed to user";
});
var agent = new Agent("current-date", """
1. Use the current_date tool to obtain today's date.
2. Use the print_user_message tool to print the date to the user.
""")
.withTools(currentDate, printMessage);
agent.act();
}
enum PrintField { message }