Skip to content

Commit 78a3bcd

Browse files
authored
Merge branch 'main' into chore/cleanup
2 parents 6a52a4d + a652d4e commit 78a3bcd

File tree

60 files changed

+3266
-156
lines changed

Some content is hidden

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

60 files changed

+3266
-156
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/AzureContentFilter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
* .hate(AzureFilterThreshold.ALLOW_SAFE)
2222
* .selfHarm(AzureFilterThreshold.ALLOW_SAFE_LOW);
2323
* }</pre>
24+
*
25+
* @link <a
26+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/input-filtering">SAP AI
27+
* Core: Orchestration - Input Filtering</a>
28+
* @link <a
29+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/output-filtering">SAP
30+
* AI Core: Orchestration - Output Filtering</a>
2431
*/
2532
@Setter
2633
@NoArgsConstructor

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
/**
77
* Interface representing convenience wrappers of serializable content filter that defines
88
* thresholds for different content categories.
9+
*
10+
* @link <a
11+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/input-filtering">SAP AI
12+
* Core: Orchestration - Input Filtering</a>
13+
* @link <a
14+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/output-filtering">SAP
15+
* AI Core: Orchestration - Output Filtering</a>
916
*/
1017
public interface ContentFilter {
1118

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
/**
2222
* SAP Data Privacy Integration (DPI) can mask personally identifiable information using either
2323
* anonymization or pseudonymization.
24+
*
25+
* @link <a href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/data-masking">SAP
26+
* AI Core: Orchestration - Data Masking</a>
2427
*/
2528
@Value
2629
@Getter(AccessLevel.PACKAGE)

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import com.sap.ai.sdk.orchestration.model.MaskingProviderConfig;
44
import javax.annotation.Nonnull;
55

6-
/** Interface for masking configurations. */
6+
/**
7+
* Interface for masking configurations.
8+
*
9+
* @link <a href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/data-masking">SAP
10+
* AI Core: Orchestration - Data Masking</a>
11+
*/
712
public interface MaskingProvider {
813

914
/**

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/OrchestrationModuleConfig.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
* <li>Input Content Filtering (Optional)
3535
* <li>Output Content Filtering (Optional)
3636
* </ul>
37+
*
38+
* @link <a
39+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/orchestration-workflow">
40+
* SAP AI Core: Orchestration - Orchestration Workflow</a>
3741
*/
3842
@Value
3943
@With
@@ -42,24 +46,49 @@
4246
public class OrchestrationModuleConfig {
4347
/**
4448
* The configured language model settings. This configuration is required when executing requests.
49+
*
50+
* @link <a
51+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/model-configuration">
52+
* SAP AI Core: Orchestration - Model Configuration</a>
4553
*/
4654
@Nullable LLMModuleConfig llmConfig;
4755

4856
/**
4957
* A template to be populated with input parameters. Upon request execution, this template will be
5058
* enhanced with any messages and parameter values from {@link OrchestrationPrompt}.
59+
*
60+
* @link <a href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/templating">SAP
61+
* AI Core: Orchestration - Templating</a>
5162
*/
5263
@Nullable TemplatingModuleConfig templateConfig;
5364

54-
/** A masking configuration to pseudonymous or anonymize sensitive data in the input. */
65+
/**
66+
* A masking configuration to pseudonymous or anonymize sensitive data in the input.
67+
*
68+
* @link <a
69+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/data-masking">SAP AI
70+
* Core: Orchestration - Data Masking</a>
71+
*/
5572
@Nullable MaskingModuleConfig maskingConfig;
5673

57-
/** A content filter to filter the prompt. */
74+
/**
75+
* A content filter to filter the prompt.
76+
*
77+
* @link <a
78+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/input-filtering">SAP
79+
* AI Core: Orchestration - Input Filtering</a>
80+
* @link <a
81+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/output-filtering">SAP
82+
* AI Core: Orchestration - Output Filtering</a>
83+
*/
5884
@Nullable FilteringModuleConfig filteringConfig;
5985

6086
/**
6187
* Creates a new configuration with the given LLM configuration.
6288
*
89+
* @link <a
90+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/model-configuration">
91+
* SAP AI Core: Orchestration - Model Configuration</a>
6392
* @param aiModel The LLM configuration to use.
6493
* @return A new configuration with the given LLM configuration.
6594
*/
@@ -72,6 +101,9 @@ public OrchestrationModuleConfig withLlmConfig(@Nonnull final OrchestrationAiMod
72101
/**
73102
* Creates a new configuration with the given Data Masking configuration.
74103
*
104+
* @link <a
105+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/data-masking">SAP AI
106+
* Core: Orchestration - Data Masking</a>
75107
* @param maskingProvider The Data Masking configuration to use.
76108
* @param maskingProviders Additional Data Masking configurations to use.
77109
* @return A new configuration with the given Data Masking configuration.
@@ -94,6 +126,9 @@ public OrchestrationModuleConfig withMaskingConfig(
94126
*
95127
* <p>Preferred over {@link #withFilteringConfig(FilteringModuleConfig)} for adding input filters.
96128
*
129+
* @link <a
130+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/input-filtering">SAP
131+
* AI Core: Orchestration - Input Filtering</a>
97132
* @param contentFilters one or more content filters to apply to the input.
98133
* @return a new {@code OrchestrationModuleConfig} instance with the specified input filters
99134
* added.
@@ -125,6 +160,9 @@ public OrchestrationModuleConfig withInputFiltering(
125160
* <p>Preferred over {@link #withFilteringConfig(FilteringModuleConfig)} for adding output
126161
* filters.
127162
*
163+
* @link <a
164+
* href="https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/output-filtering">SAP
165+
* AI Core: Orchestration - Output Filtering</a>
128166
* @param contentFilters one or more content filters to apply to the output.
129167
* @return a new {@code OrchestrationModuleConfig} instance with the specified output filters
130168
* added.

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).

0 commit comments

Comments
 (0)