33import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .GPT_35_TURBO ;
44import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .Parameter .TEMPERATURE ;
55
6- import com .sap .ai .sdk .orchestration .AssistantMessage ;
76import com .sap .ai .sdk .orchestration .AzureContentFilter ;
87import com .sap .ai .sdk .orchestration .AzureFilterThreshold ;
98import com .sap .ai .sdk .orchestration .DpiMasking ;
1211import com .sap .ai .sdk .orchestration .OrchestrationClient ;
1312import com .sap .ai .sdk .orchestration .OrchestrationModuleConfig ;
1413import com .sap .ai .sdk .orchestration .OrchestrationPrompt ;
15- import com .sap .ai .sdk .orchestration .SystemMessage ;
16- import com .sap .ai .sdk .orchestration .UserMessage ;
1714import com .sap .ai .sdk .orchestration .model .DPIEntities ;
1815import com .sap .ai .sdk .orchestration .model .Template ;
1916import java .util .List ;
@@ -54,7 +51,7 @@ public OrchestrationChatResponse completion() {
5451 @ Nonnull
5552 public OrchestrationChatResponse template () {
5653 final var template =
57- new UserMessage ("Reply with 'Orchestration Service is working!' in {{?language}}" );
54+ Message . user ("Reply with 'Orchestration Service is working!' in {{?language}}" );
5855 final var templatingConfig = Template .create ().template (List .of (template .createChatMessage ()));
5956 final var configWithTemplate = config .withTemplateConfig (templatingConfig );
6057
@@ -72,15 +69,16 @@ public OrchestrationChatResponse template() {
7269 @ GetMapping ("/messagesHistory" )
7370 @ Nonnull
7471 public OrchestrationChatResponse messagesHistory () {
75- final List <Message > messagesHistory =
76- List .of (
77- new UserMessage ("What is the capital of France?" ),
78- new AssistantMessage ("The capital of France is Paris." ));
79- final var message = new UserMessage ("What is the typical food there?" );
72+ final var prompt = new OrchestrationPrompt (Message .user ("What is the capital of France?" ));
8073
81- final var prompt = new OrchestrationPrompt ( message ). messageHistory ( messagesHistory );
74+ final var result = client . chatCompletion ( prompt , config );
8275
83- return client .chatCompletion (prompt , config );
76+ // Let's presume a user asks the following follow-up question
77+ final var nextPrompt =
78+ new OrchestrationPrompt (Message .user ("What is the typical food there?" ))
79+ .messageHistory (result .getAllMessages ());
80+
81+ return client .chatCompletion (nextPrompt , config );
8482 }
8583
8684 /**
@@ -120,10 +118,10 @@ public OrchestrationChatResponse filter(
120118 @ Nonnull
121119 public OrchestrationChatResponse maskingAnonymization () {
122120 final var systemMessage =
123- new SystemMessage (
121+ Message . system (
124122 "Please evaluate the following user feedback and judge if the sentiment is positive or negative." );
125123 final var userMessage =
126- new UserMessage (
124+ Message . user (
127125 """
128126 I think the SDK is good, but could use some further enhancements.
129127 My architect Alice and manager Bob pointed out that we need the grounding capabilities, which aren't supported yet.
@@ -146,13 +144,13 @@ public OrchestrationChatResponse maskingAnonymization() {
146144 @ Nonnull
147145 public OrchestrationChatResponse maskingPseudonymization () {
148146 final var systemMessage =
149- new SystemMessage (
147+ Message . system (
150148 """
151149 Please write an initial response to the below user feedback, stating that we are working on the feedback and will get back to them soon.
152150 Please make sure to address the user in person and end with "Best regards, the AI SDK team".
153151 """ );
154152 final var userMessage =
155- new UserMessage (
153+ Message . user (
156154 """
157155 Username: Mallory
158156
0 commit comments