File tree Expand file tree Collapse file tree 6 files changed +13
-13
lines changed
main/java/com/sap/ai/sdk/orchestration
test/java/com/sap/ai/sdk/orchestration
sample-code/spring-app/src
main/java/com/sap/ai/sdk/app/controllers
test/java/com/sap/ai/sdk/app/controllers Expand file tree Collapse file tree 6 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 2828public class AzureContentFilter implements ContentFilter {
2929
3030 /* The moderation policy for hate content. */
31- @ Nullable AzureModerationPolicy hate ;
31+ @ Nullable AzureFilterThreshold hate ;
3232
3333 /* The moderation policy for self-harm content. */
34- @ Nullable AzureModerationPolicy selfHarm ;
34+ @ Nullable AzureFilterThreshold selfHarm ;
3535
3636 /* The moderation policy for sexual content. */
37- @ Nullable AzureModerationPolicy sexual ;
37+ @ Nullable AzureFilterThreshold sexual ;
3838
3939 /* The moderation policy for violence content. */
40- @ Nullable AzureModerationPolicy violence ;
40+ @ Nullable AzureFilterThreshold violence ;
4141
4242 /**
4343 * Converts {@code AzureContentFilter} to its serializable counterpart {@link
Original file line number Diff line number Diff line change 88/** An Enum wrapping Azure thresholds with readable names. */
99@ Getter
1010@ AllArgsConstructor
11- public enum AzureModerationPolicy {
11+ public enum AzureFilterThreshold {
1212 /** Strict moderation policy. Only safe content is allowed. */
1313 ALLOW_SAFE (AzureThreshold .NUMBER_0 ),
1414
Original file line number Diff line number Diff line change 11package com .sap .ai .sdk .orchestration ;
22
3- import static com .sap .ai .sdk .orchestration .AzureModerationPolicy .ALLOW_SAFE_LOW_MEDIUM ;
3+ import static com .sap .ai .sdk .orchestration .AzureFilterThreshold .ALLOW_SAFE_LOW_MEDIUM ;
44import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .GPT_4O ;
55import static org .assertj .core .api .Assertions .assertThat ;
66import static org .assertj .core .api .Assertions .assertThatThrownBy ;
Original file line number Diff line number Diff line change 1616import static com .github .tomakehurst .wiremock .client .WireMock .stubFor ;
1717import static com .github .tomakehurst .wiremock .client .WireMock .urlPathEqualTo ;
1818import static com .github .tomakehurst .wiremock .client .WireMock .verify ;
19- import static com .sap .ai .sdk .orchestration .AzureModerationPolicy .ALLOW_SAFE ;
20- import static com .sap .ai .sdk .orchestration .AzureModerationPolicy .ALLOW_SAFE_LOW_MEDIUM ;
19+ import static com .sap .ai .sdk .orchestration .AzureFilterThreshold .ALLOW_SAFE ;
20+ import static com .sap .ai .sdk .orchestration .AzureFilterThreshold .ALLOW_SAFE_LOW_MEDIUM ;
2121import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .GPT_35_TURBO_16K ;
2222import static org .apache .hc .core5 .http .HttpStatus .SC_BAD_REQUEST ;
2323import static org .assertj .core .api .Assertions .assertThat ;
Original file line number Diff line number Diff line change 33import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .GPT_35_TURBO ;
44
55import com .sap .ai .sdk .orchestration .AzureContentFilter ;
6- import com .sap .ai .sdk .orchestration .AzureModerationPolicy ;
6+ import com .sap .ai .sdk .orchestration .AzureFilterThreshold ;
77import com .sap .ai .sdk .orchestration .DpiMasking ;
88import com .sap .ai .sdk .orchestration .OrchestrationChatResponse ;
99import com .sap .ai .sdk .orchestration .OrchestrationClient ;
@@ -89,7 +89,7 @@ public OrchestrationChatResponse messagesHistory() {
8989 @ GetMapping ("/filter/{policy}" )
9090 @ Nonnull
9191 public OrchestrationChatResponse filter (
92- @ Nonnull @ PathVariable ("policy" ) final AzureModerationPolicy policy ) {
92+ @ Nonnull @ PathVariable ("policy" ) final AzureFilterThreshold policy ) {
9393 final var prompt =
9494 new OrchestrationPrompt (
9595 """
Original file line number Diff line number Diff line change 33import static org .assertj .core .api .Assertions .assertThat ;
44import static org .assertj .core .api .Assertions .assertThatThrownBy ;
55
6- import com .sap .ai .sdk .orchestration .AzureModerationPolicy ;
6+ import com .sap .ai .sdk .orchestration .AzureFilterThreshold ;
77import com .sap .ai .sdk .orchestration .OrchestrationClientException ;
88import com .sap .ai .sdk .orchestration .client .model .CompletionPostResponse ;
99import com .sap .ai .sdk .orchestration .client .model .LLMChoice ;
@@ -76,7 +76,7 @@ void testTemplate() {
7676
7777 @ Test
7878 void testLenientContentFilter () {
79- var response = controller .filter (AzureModerationPolicy .ALLOW_SAFE_LOW_MEDIUM );
79+ var response = controller .filter (AzureFilterThreshold .ALLOW_SAFE_LOW_MEDIUM );
8080 var result = response .getOriginalResponse ();
8181 var llmChoice =
8282 ((LLMModuleResultSynchronous ) result .getOrchestrationResult ()).getChoices ().get (0 );
@@ -89,7 +89,7 @@ void testLenientContentFilter() {
8989
9090 @ Test
9191 void testStrictContentFilter () {
92- assertThatThrownBy (() -> controller .filter (AzureModerationPolicy .ALLOW_SAFE ))
92+ assertThatThrownBy (() -> controller .filter (AzureFilterThreshold .ALLOW_SAFE ))
9393 .isInstanceOf (OrchestrationClientException .class )
9494 .hasMessageContaining ("400 Bad Request" )
9595 .hasMessageContaining ("Content filtered" );
You can’t perform that action at this time.
0 commit comments