Skip to content

Commit c2697d3

Browse files
authored
Synchup with Agent Framework (#83)
1 parent 3c258e8 commit c2697d3

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

examples-java/src/main/java/com/embabel/example/repeatuntil/GoatWriterConfig.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import com.embabel.agent.api.common.workflow.loop.RepeatUntilAcceptableBuilder;
1919
import com.embabel.agent.api.common.workflow.loop.TextFeedback;
20-
2120
import com.embabel.agent.api.models.OpenAiModels;
2221
import com.embabel.agent.core.Agent;
2322
import org.springframework.context.annotation.Bean;
@@ -38,8 +37,8 @@ public Agent goatWriter() {
3837
.returning(Goat.class)
3938
.withMaxIterations(3)
4039
.repeating(context -> {
41-
var lastFeedback = context.getInput().lastFeedback();
42-
var feedback = lastFeedback != null ? "Feedback: " + lastFeedback.getFeedback() : "";
40+
var lastAttempt = context.lastAttempt();
41+
var feedback = lastAttempt != null ? "Feedback: " + lastAttempt.getFeedback() : "";
4342
return context.ai()
4443
.withLlm(OpenAiModels.GPT_5_NANO)
4544
.createObject(
@@ -59,7 +58,7 @@ public Agent goatWriter() {
5958
%s
6059
6160
Provide feedback of no more than 40 words on a scale from 0 to 1, where 1 is excellent and 0 is poor.
62-
""".formatted(context.getInput().resultToEvaluate()),
61+
""".formatted(context.getResultToEvaluate()),
6362
TextFeedback.class))
6463
.buildAgent("GoatWriter",
6564
"Write a description of a goat");

examples-java/src/main/java/com/embabel/example/repeatuntil/ReviseStoryUntilSatisfied.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ Story rewriteUntilSatisfied(
4848
.withMaxIterations(7)
4949
.withScoreThreshold(.8)
5050
.repeating(context -> {
51-
var lastFeedback = context.getInput().lastFeedback();
52-
var feedback = lastFeedback != null ? "Consider the following feedback: " + lastFeedback.getFeedback() : "";
51+
var lastAttempt = context.lastAttempt();
52+
var feedback = lastAttempt != null ? "Consider the following feedback: " + lastAttempt.getFeedback() : "";
5353
return writerPromptRunner.createObject(
5454
"""
5555
Write a creative story inspired by the user input: %s
@@ -68,7 +68,7 @@ Story rewriteUntilSatisfied(
6868
6969
User input: %s
7070
""".formatted(
71-
context.getInput().resultToEvaluate(),
71+
context.getResultToEvaluate(),
7272
userInput.getContent()),
7373
TextFeedback.class)
7474
)

0 commit comments

Comments
 (0)