Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.embabel.agent.api.common.workflow.loop.RepeatUntilAcceptableBuilder;
import com.embabel.agent.api.common.workflow.loop.TextFeedback;

import com.embabel.agent.api.models.OpenAiModels;
import com.embabel.agent.core.Agent;
import org.springframework.context.annotation.Bean;
Expand All @@ -38,8 +37,8 @@ public Agent goatWriter() {
.returning(Goat.class)
.withMaxIterations(3)
.repeating(context -> {
var lastFeedback = context.getInput().lastFeedback();
var feedback = lastFeedback != null ? "Feedback: " + lastFeedback.getFeedback() : "";
var lastAttempt = context.lastAttempt();
var feedback = lastAttempt != null ? "Feedback: " + lastAttempt.getFeedback() : "";
return context.ai()
.withLlm(OpenAiModels.GPT_5_NANO)
.createObject(
Expand All @@ -59,7 +58,7 @@ public Agent goatWriter() {
%s

Provide feedback of no more than 40 words on a scale from 0 to 1, where 1 is excellent and 0 is poor.
""".formatted(context.getInput().resultToEvaluate()),
""".formatted(context.getResultToEvaluate()),
TextFeedback.class))
.buildAgent("GoatWriter",
"Write a description of a goat");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Story rewriteUntilSatisfied(
.withMaxIterations(7)
.withScoreThreshold(.8)
.repeating(context -> {
var lastFeedback = context.getInput().lastFeedback();
var feedback = lastFeedback != null ? "Consider the following feedback: " + lastFeedback.getFeedback() : "";
var lastAttempt = context.lastAttempt();
var feedback = lastAttempt != null ? "Consider the following feedback: " + lastAttempt.getFeedback() : "";
return writerPromptRunner.createObject(
"""
Write a creative story inspired by the user input: %s
Expand All @@ -68,7 +68,7 @@ Story rewriteUntilSatisfied(

User input: %s
""".formatted(
context.getInput().resultToEvaluate(),
context.getResultToEvaluate(),
userInput.getContent()),
TextFeedback.class)
)
Expand Down