forked from embabel/java-agent-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoShell.java
More file actions
28 lines (24 loc) · 1 KB
/
DemoShell.java
File metadata and controls
28 lines (24 loc) · 1 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
package com.embabel.template;
import com.embabel.agent.api.common.autonomy.AgentInvocation;
import com.embabel.agent.core.AgentPlatform;
import com.embabel.agent.domain.io.UserInput;
import com.embabel.template.agent.WriteAndReviewAgent;
import com.embabel.template.injected.InjectedDemo;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
@ShellComponent
record DemoShell(InjectedDemo injectedDemo, AgentPlatform agentPlatform) {
@ShellMethod("Demo")
String demo() {
// Illustrate calling an agent programmatically,
// as most often occurs in real applications.
var reviewedStory = AgentInvocation
.create(agentPlatform, WriteAndReviewAgent.ReviewedStory.class)
.invoke(new UserInput("Tell me a story about caterpillars"));
return reviewedStory.getContent();
}
@ShellMethod("Invent an animal")
String animal() {
return injectedDemo.inventAnimal().toString();
}
}