1616package com .embabel .example .horoscope ;
1717
1818import com .embabel .agent .api .annotation .*;
19- import com .embabel .agent .api .common .OperationContext ;
19+ import com .embabel .agent .api .common .Ai ;
2020import com .embabel .agent .config .models .AnthropicModels ;
2121import com .embabel .agent .config .models .OpenAiModels ;
2222import com .embabel .agent .core .CoreToolGroups ;
@@ -50,8 +50,8 @@ public StarNewsFinder(
5050 }
5151
5252 @ Action
53- public Person extractPerson (UserInput userInput , OperationContext context ) {
54- return context . ai ()
53+ public Person extractPerson (UserInput userInput , Ai ai ) {
54+ return ai
5555 .withLlm (OpenAiModels .GPT_41 )
5656 .createObjectIfPossible (
5757 """
@@ -76,8 +76,8 @@ public StarPerson assembleStarPerson(Person person, Starry starry) {
7676 }
7777
7878 @ Action
79- public StarPerson extractStarPerson (UserInput userInput , OperationContext context ) {
80- return context . ai ()
79+ public StarPerson extractStarPerson (UserInput userInput , Ai ai ) {
80+ return ai
8181 .withLlmByRole ("best" )
8282 .createObjectIfPossible (
8383 """
@@ -94,7 +94,10 @@ public Horoscope retrieveHoroscope(StarPerson starPerson) {
9494
9595 // toolGroups specifies tools that are required for this action to run
9696 @ Action (toolGroups = {CoreToolGroups .WEB })
97- public RelevantNewsStories findNewsStories (StarPerson person , Horoscope horoscope , OperationContext context ) {
97+ public RelevantNewsStories findNewsStories (
98+ StarPerson person ,
99+ Horoscope horoscope ,
100+ Ai ai ) {
98101 var prompt = """
99102 %s is an astrology believer with the sign %s.
100103 Their horoscope for today is:
@@ -113,7 +116,7 @@ public RelevantNewsStories findNewsStories(StarPerson person, Horoscope horoscop
113116 find news stories about training courses.""" .formatted (
114117 person .name (), person .sign (), horoscope .summary (), storyCount );
115118
116- return context . ai ()
119+ return ai
117120 .withDefaultLlm ().
118121 createObject (prompt , RelevantNewsStories .class );
119122 }
@@ -132,7 +135,7 @@ public Writeup writeup(
132135 StarPerson person ,
133136 RelevantNewsStories relevantNewsStories ,
134137 Horoscope horoscope ,
135- OperationContext context ) {
138+ Ai ai ) {
136139 var newsItems = relevantNewsStories .getItems ().stream ()
137140 .map (item -> "- " + item .getUrl () + ": " + item .getSummary ())
138141 .collect (Collectors .joining ("\n " ));
@@ -152,7 +155,7 @@ public Writeup writeup(
152155
153156 Format it as Markdown with links.""" .formatted (
154157 person .name (), person .sign (), horoscope .summary (), newsItems );
155- return context . ai ()
158+ return ai
156159 .withLlm (LlmOptions
157160 .withFirstAvailableLlmOf (AnthropicModels .CLAUDE_37_SONNET , OpenAiModels .GPT_41_MINI )
158161 .withTemperature (0.9 ))
0 commit comments