2020import com .embabel .agent .api .annotation .Agent ;
2121import com .embabel .agent .api .annotation .Export ;
2222import com .embabel .agent .api .common .OperationContext ;
23- import com .embabel .agent .api .common .PromptRunner ;
2423import com .embabel .agent .domain .io .UserInput ;
2524import com .embabel .agent .domain .library .HasContent ;
2625import com .embabel .agent .prompt .persona .Persona ;
27- import com .embabel .common .ai .model .AutoModelSelectionCriteria ;
2826import com .embabel .common .ai .model .LlmOptions ;
29- import com .embabel .common .ai .prompt .PromptContributionLocation ;
3027import com .embabel .common .core .types .Timestamped ;
3128import org .springframework .beans .factory .annotation .Value ;
3229import org .springframework .context .annotation .Profile ;
@@ -108,8 +105,9 @@ class WriteAndReviewAgent {
108105 export = @ Export (remote = true , name = "writeAndReviewStory" ))
109106 @ Action
110107 ReviewedStory reviewStory (UserInput userInput , Story story , OperationContext context ) {
111- String review = context .promptRunner ()
112- .withLlm (LlmOptions .fromCriteria (AutoModelSelectionCriteria .INSTANCE ))
108+ var review = context
109+ .ai ()
110+ .withAutoLlm ()
113111 .withPromptContributor (Personas .REVIEWER )
114112 .generateText (String .format ("""
115113 You will be given a short story to review.
@@ -137,12 +135,11 @@ ReviewedStory reviewStory(UserInput userInput, Story story, OperationContext con
137135
138136 @ Action
139137 Story craftStory (UserInput userInput , OperationContext context ) {
140- PromptRunner runner = context .promptRunner ()
141- // Higher temperature for more creative output
142- .withLlm (LlmOptions .fromCriteria (AutoModelSelectionCriteria .INSTANCE ))
143- .withPromptContributor (Personas .WRITER );
144-
145- return runner .createObject (String .format ("""
138+ return context .ai ()
139+ // Higher temperature for more creative output
140+ .withLlm (LlmOptions .withAutoLlm ().withTemperature (.7 ))
141+ .withPromptContributor (Personas .WRITER )
142+ .createObject (String .format ("""
146143 Craft a short story in %d words or less.
147144 The story should be engaging and imaginative.
148145 Use the user's input as inspiration if possible.
@@ -151,8 +148,8 @@ Story craftStory(UserInput userInput, OperationContext context) {
151148 # User input
152149 %s
153150 """ ,
154- storyWordCount ,
155- userInput .getContent ()
156- ).trim (), Story .class );
151+ storyWordCount ,
152+ userInput .getContent ()
153+ ).trim (), Story .class );
157154 }
158155}
0 commit comments