Skip to content

Commit d726540

Browse files
committed
Merge branch 'main' into add-links-orch-docs
2 parents 82f0aee + d921c49 commit d726540

File tree

55 files changed

+3187
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3187
-151
lines changed

docs/guides/ORCHESTRATION_CHAT_COMPLETION.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ The LLM response is available as the first choice under the `result.getOrchestra
102102
Use a prepared template and execute requests with by passing only the input parameters:
103103

104104
```java
105-
var template =
106-
ChatMessage.create()
107-
.role("user")
108-
.content("Reply with 'Orchestration Service is working!' in {{?language}}");
105+
var template = Message.user("Reply with 'Orchestration Service is working!' in {{?language}}");
109106
var templatingConfig = TemplatingModuleConfig.create().template(template);
110107
var configWithTemplate = config.withTemplateConfig(templatingConfig);
111108

@@ -124,10 +121,10 @@ Include a message history to maintain context in the conversation:
124121
```java
125122
var messagesHistory =
126123
List.of(
127-
ChatMessage.create().role("user").content("What is the capital of France?"),
128-
ChatMessage.create().role("assistant").content("The capital of France is Paris."));
124+
Message.user("What is the capital of France?"),
125+
Message.assistant("The capital of France is Paris."));
129126
var message =
130-
ChatMessage.create().role("user").content("What is the typical food there?");
127+
Message.user("What is the typical food there?");
131128

132129
var prompt = new OrchestrationPrompt(message).messageHistory(messagesHistory);
133130

@@ -175,12 +172,8 @@ var maskingConfig =
175172
DpiMasking.anonymization().withEntities(DPIEntities.PHONE, DPIEntities.PERSON);
176173
var configWithMasking = config.withMaskingConfig(maskingConfig);
177174

178-
var systemMessage = ChatMessage.create()
179-
.role("system")
180-
.content("Please evaluate the following user feedback and judge if the sentiment is positive or negative.");
181-
var userMessage = ChatMessage.create()
182-
.role("user")
183-
.content("""
175+
var systemMessage = Message.system("Please evaluate the following user feedback and judge if the sentiment is positive or negative.");
176+
var userMessage = Message.user("""
184177
I think the SDK is good, but could use some further enhancements.
185178
My architect Alice and manager Bob pointed out that we need the grounding capabilities, which aren't supported yet.
186179
""");

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.sap.ai.sdk.orchestration;
22

3+
import com.google.common.annotations.Beta;
34
import com.sap.ai.sdk.orchestration.model.ChatMessage;
45
import javax.annotation.Nonnull;
56

@@ -63,5 +64,6 @@ default ChatMessage createChatMessage() {
6364
* @return the content.
6465
*/
6566
@Nonnull
67+
@Beta
6668
String content();
6769
}

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.sap.ai.sdk.orchestration.model.TokenUsage;
1010
import java.util.ArrayList;
1111
import java.util.List;
12-
import java.util.Objects;
1312
import javax.annotation.Nonnull;
1413
import lombok.RequiredArgsConstructor;
1514
import lombok.Value;
@@ -54,10 +53,21 @@ public TokenUsage getTokenUsage() {
5453
* @return A list of all messages.
5554
*/
5655
@Nonnull
57-
public List<ChatMessage> getAllMessages() {
58-
final var items = Objects.requireNonNull(originalResponse.getModuleResults().getTemplating());
59-
final var messages = new ArrayList<>(items);
60-
messages.add(getCurrentChoice().getMessage());
56+
public List<Message> getAllMessages() {
57+
final var messages = new ArrayList<Message>();
58+
59+
for (final ChatMessage chatMessage : originalResponse.getModuleResults().getTemplating()) {
60+
final var message =
61+
switch (chatMessage.getRole()) {
62+
case "user" -> new UserMessage(chatMessage.getContent());
63+
case "assistant" -> new AssistantMessage(chatMessage.getContent());
64+
case "system" -> new SystemMessage(chatMessage.getContent());
65+
default -> throw new IllegalStateException("Unexpected role: " + chatMessage.getRole());
66+
};
67+
messages.add(message);
68+
}
69+
70+
messages.add(new AssistantMessage(getCurrentChoice().getMessage().getContent()));
6171
return messages;
6272
}
6373

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafety.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Orchestration
33
* Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services.
44
*
5-
* The version of the OpenAPI document: 0.29.3
5+
* The version of the OpenAPI document: 0.36.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyFilterConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Orchestration
33
* Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services.
44
*
5-
* The version of the OpenAPI document: 0.29.3
5+
* The version of the OpenAPI document: 0.36.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureThreshold.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Orchestration
33
* Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services.
44
*
5-
* The version of the OpenAPI document: 0.29.3
5+
* The version of the OpenAPI document: 0.36.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatDelta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Orchestration
33
* Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services.
44
*
5-
* The version of the OpenAPI document: 0.29.3
5+
* The version of the OpenAPI document: 0.36.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Orchestration
33
* Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services.
44
*
5-
* The version of the OpenAPI document: 0.29.3
5+
* The version of the OpenAPI document: 0.36.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Orchestration
33
* Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services.
44
*
5-
* The version of the OpenAPI document: 0.29.3
5+
* The version of the OpenAPI document: 0.36.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Orchestration
33
* Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services.
44
*
5-
* The version of the OpenAPI document: 0.29.3
5+
* The version of the OpenAPI document: 0.36.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

0 commit comments

Comments
 (0)