Skip to content

Commit dc32095

Browse files
committed
Minor tweaks
1 parent 200d26d commit dc32095

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationPrompt.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ public OrchestrationPrompt(
6363
*
6464
* @param messagesHistory The chat history to add.
6565
*/
66-
public void setMessageHistory(@Nonnull final List<ChatMessage> messagesHistory) {
66+
public OrchestrationPrompt messageHistory(@Nonnull final List<ChatMessage> messagesHistory) {
6767
this.messagesHistory.clear();
6868
this.messagesHistory.addAll(messagesHistory);
69+
return this;
6970
}
7071
}

orchestration/src/test/java/com/sap/ai/sdk/orchestration/ModuleConfigFactoryTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ void testMergingTemplateConfig() {
6868
void testMessagesHistory() {
6969
var systemMessage = ChatMessage.create().role("system").content("foo");
7070

71-
var prompt = new OrchestrationPrompt("bar");
72-
prompt.setMessageHistory(List.of(systemMessage));
71+
var prompt = new OrchestrationPrompt("bar").messageHistory(List.of(systemMessage));
7372
var actual =
7473
ModuleConfigFactory.toCompletionPostRequestDto(
7574
prompt, new OrchestrationModuleConfig().withLlmConfig(LLM_CONFIG));

orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ void messagesHistory() throws IOException {
275275
final var message =
276276
ChatMessage.create().role("user").content("What is the typical food there?");
277277

278-
prompt = new OrchestrationPrompt(message);
279-
prompt.setMessageHistory(messagesHistory);
278+
prompt = new OrchestrationPrompt(message).messageHistory(messagesHistory);
280279

281280
final var result = client.chatCompletion(prompt, config);
282281

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ public CompletionPostResponse messagesHistory() {
8484
final var message =
8585
ChatMessage.create().role("user").content("What is the typical food there?");
8686

87-
final var prompt = new OrchestrationPrompt(message);
88-
prompt.setMessageHistory(messagesHistory);
87+
final var prompt = new OrchestrationPrompt(message).messageHistory(messagesHistory);
8988

9089
return CLIENT.chatCompletion(prompt, CONFIG);
9190
}

sample-code/spring-app/src/main/resources/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ <h2>Endpoints</h2>
6868
<ul>
6969
<li><a href="/orchestration/completion">/orchestration/completion</a></li>
7070
<li><a href="/orchestration/template">/orchestration/template</a></li>
71+
<li><a href="/orchestration/messagesHistory">/orchestration/messagesHistory</a></li>
7172
<li><a href="/orchestration/filter/NUMBER_4">/orchestration/filter/NUMBER_4</a> Loose filter</li>
7273
<li><a href="/orchestration/filter/NUMBER_0">/orchestration/filter/NUMBER_0</a> Strict filter (fails)</li>
73-
<li><a href="/orchestration/messagesHistory">/orchestration/messagesHistory</a></li>
7474
<li><a href="/orchestration/maskingAnonymization">/orchestration/maskingAnonymization</a></li>
7575
<li><a href="/orchestration/maskingPseudonymization">/orchestration/maskingPseudonymization</a></li>
7676
</ul>

0 commit comments

Comments
 (0)