1919import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .GPT_4O ;
2020import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .GPT_4O_MINI ;
2121import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .Parameter .*;
22+ import static com .sap .ai .sdk .orchestration .model .ResponseChatMessage .RoleEnum .ASSISTANT ;
23+ import static com .sap .ai .sdk .orchestration .model .UserChatMessage .RoleEnum .USER ;
2224import static org .apache .hc .core5 .http .HttpStatus .SC_BAD_REQUEST ;
2325import static org .apache .hc .core5 .http .HttpStatus .SC_OK ;
2426import static org .assertj .core .api .Assertions .assertThat ;
3537import com .github .tomakehurst .wiremock .junit5 .WireMockRuntimeInfo ;
3638import com .github .tomakehurst .wiremock .junit5 .WireMockTest ;
3739import com .github .tomakehurst .wiremock .stubbing .Scenario ;
38- import com .sap .ai .sdk .orchestration .model .AssistantChatMessage ;
39- import com .sap .ai .sdk .orchestration .model .ChatMessageContent ;
4040import com .sap .ai .sdk .orchestration .model .DPIEntities ;
4141import com .sap .ai .sdk .orchestration .model .DataRepositoryType ;
4242import com .sap .ai .sdk .orchestration .model .DocumentGroundingFilter ;
5151import com .sap .ai .sdk .orchestration .model .SearchDocumentKeyValueListPair ;
5252import com .sap .ai .sdk .orchestration .model .SearchSelectOptionEnum ;
5353import com .sap .ai .sdk .orchestration .model .Template ;
54+ import com .sap .ai .sdk .orchestration .model .UserChatMessage ;
55+ import com .sap .ai .sdk .orchestration .model .UserChatMessageContent ;
5456import com .sap .cloud .sdk .cloudplatform .connectivity .ApacheHttpClient5Accessor ;
5557import com .sap .cloud .sdk .cloudplatform .connectivity .ApacheHttpClient5Cache ;
5658import com .sap .cloud .sdk .cloudplatform .connectivity .DefaultHttpDestination ;
@@ -277,10 +279,10 @@ void testTemplating() throws IOException {
277279
278280 assertThat (((TextItem ) messageList .get (0 ).content ().items ().get (0 )).text ())
279281 .isEqualTo ("You are a multi language translator" );
280- assertThat (messageList .get (0 ).role ()).isEqualTo ("assistant " ); // JONAS: why is the change needed here?
282+ assertThat (messageList .get (0 ).role ()).isEqualTo ("system " );
281283 assertThat (((TextItem ) messageList .get (1 ).content ().items ().get (0 )).text ())
282284 .isEqualTo ("Reply with 'Orchestration Service is working!' in German" );
283- assertThat (messageList .get (1 ).role ()).isEqualTo ("assistant " );
285+ assertThat (messageList .get (1 ).role ()).isEqualTo ("user " );
284286 assertThat (((TextItem ) messageList .get (2 ).content ().items ().get (0 )).text ())
285287 .isEqualTo ("Orchestration Service funktioniert!" );
286288 assertThat (messageList .get (2 ).role ()).isEqualTo ("assistant" );
@@ -295,7 +297,7 @@ void testTemplating() throws IOException {
295297 assertThat (choices .get (0 ).getIndex ()).isZero ();
296298 assertThat (choices .get (0 ).getMessage ().getContent ())
297299 .isEqualTo ("Le service d'orchestration fonctionne!" );
298- assertThat (choices .get (0 ).getMessage ().getRole (). toString ()) .isEqualTo ("assistant" );
300+ assertThat (choices .get (0 ).getMessage ().getRole ()) .isEqualTo (ASSISTANT );
299301 assertThat (choices .get (0 ).getFinishReason ()).isEqualTo ("stop" );
300302 var usage = result .getTokenUsage ();
301303 assertThat (usage .getCompletionTokens ()).isEqualTo (7 );
@@ -310,7 +312,7 @@ void testTemplating() throws IOException {
310312 assertThat (choices .get (0 ).getIndex ()).isZero ();
311313 assertThat (choices .get (0 ).getMessage ().getContent ())
312314 .isEqualTo ("Le service d'orchestration fonctionne!" );
313- assertThat (choices .get (0 ).getMessage ().getRole (). toString ()) .isEqualTo ("assistant" );
315+ assertThat (choices .get (0 ).getMessage ().getRole ()) .isEqualTo (ASSISTANT );
314316 assertThat (choices .get (0 ).getFinishReason ()).isEqualTo ("stop" );
315317 usage = result .getTokenUsage ();
316318 assertThat (usage .getCompletionTokens ()).isEqualTo (7 );
@@ -708,9 +710,9 @@ void streamChatCompletionDeltas() throws IOException {
708710 final var templating = deltaList .get (0 ).getModuleResults ().getTemplating ();
709711 assertThat (templating ).hasSize (1 );
710712
711- final var templateItem = templating .get (0 ); // JONAS: why?
712- assertThat (templateItem ). isInstanceOf ( AssistantChatMessage . class );
713- assertThat (((ChatMessageContent .InnerString ) (( AssistantChatMessage ) templateItem ) .getContent ()).value ())
713+ final var templateItem = ( UserChatMessage ) templating .get (0 );
714+ assertThat (templateItem . getRole ()). isEqualTo ( USER );
715+ assertThat (((UserChatMessageContent .InnerString ) templateItem .getContent ()).value ())
714716 .isEqualTo ("Hello world! Why is this phrase so famous?" );
715717
716718 assertThat (result1 .getSystemFingerprint ()).isEqualTo ("fp_808245b034" );
@@ -775,7 +777,7 @@ void testMultiMessage() throws IOException {
775777 .isEqualTo (
776778 "Well, this image features the logo of SAP, a software company, set against a gradient blue background transitioning from light to dark. The main color in the image is blue." );
777779 assertThat (result .getAllMessages ()).hasSize (3 );
778- var systemMessage = result .getAllMessages ().get (0 ); // JONAS: why?
780+ var systemMessage = result .getAllMessages ().get (0 );
779781 assertThat (systemMessage .role ()).isEqualTo ("system" );
780782 assertThat (systemMessage .content ().items ()).hasSize (2 );
781783 assertThat (systemMessage .content ().items ().get (0 )).isInstanceOf (TextItem .class );
@@ -813,15 +815,14 @@ void testMultiMessage() throws IOException {
813815 .isEqualTo (
814816 "Well, this image features the logo of SAP, a software company, set against a gradient blue background transitioning from light to dark. The main color in the image is blue." );
815817 assertThat (llmResults .getChoices ().get (0 ).getFinishReason ()).isEqualTo ("stop" );
816- assertThat (llmResults .getChoices ().get (0 ).getMessage ().getRole ()).isEqualTo ("assistant" );
818+ assertThat (llmResults .getChoices ().get (0 ).getMessage ().getRole ()).isEqualTo (ASSISTANT );
817819 var orchestrationResult = (LLMModuleResultSynchronous ) response .getOrchestrationResult ();
818820 assertThat (orchestrationResult .getChoices ()).hasSize (1 );
819821 assertThat (orchestrationResult .getChoices ().get (0 ).getMessage ().getContent ())
820822 .isEqualTo (
821823 "Well, this image features the logo of SAP, a software company, set against a gradient blue background transitioning from light to dark. The main color in the image is blue." );
822824 assertThat (orchestrationResult .getChoices ().get (0 ).getFinishReason ()).isEqualTo ("stop" );
823- assertThat (orchestrationResult .getChoices ().get (0 ).getMessage ().getRole ())
824- .isEqualTo ("assistant" );
825+ assertThat (orchestrationResult .getChoices ().get (0 ).getMessage ().getRole ()).isEqualTo (ASSISTANT );
825826
826827 try (var requestInputStream = fileLoader .apply ("multiMessageRequest.json" )) {
827828 final String requestBody = new String (requestInputStream .readAllBytes ());
0 commit comments