|
1 | 1 | package com.sap.ai.sdk.orchestration; |
2 | 2 |
|
3 | | -import com.sap.ai.sdk.orchestration.model.AzureContentSafety; |
4 | | -import com.sap.ai.sdk.orchestration.model.AzureContentSafetyFilterConfig; |
| 3 | +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyInput; |
| 4 | +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyInputFilterConfig; |
| 5 | +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyOutput; |
| 6 | +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyOutputFilterConfig; |
5 | 7 | import javax.annotation.Nonnull; |
6 | 8 | import javax.annotation.Nullable; |
7 | 9 | import lombok.NoArgsConstructor; |
@@ -48,22 +50,46 @@ public class AzureContentFilter implements ContentFilter { |
48 | 50 |
|
49 | 51 | /** |
50 | 52 | * Converts {@code AzureContentFilter} to its serializable counterpart {@link |
51 | | - * AzureContentSafetyFilterConfig}. |
| 53 | + * AzureContentSafetyInputFilterConfig}. |
52 | 54 | * |
53 | | - * @return the corresponding {@code AzureContentSafetyFilterConfig} object. |
| 55 | + * @return the corresponding {@code AzureContentSafetyInputFilterConfig} object. |
54 | 56 | * @throws IllegalArgumentException if no policies are set. |
55 | 57 | */ |
56 | 58 | @Override |
57 | 59 | @Nonnull |
58 | | - public AzureContentSafetyFilterConfig createConfig() { |
| 60 | + public AzureContentSafetyInputFilterConfig createInputConfig() { |
59 | 61 | if (hate == null && selfHarm == null && sexual == null && violence == null) { |
60 | 62 | throw new IllegalArgumentException("At least one filter category must be set"); |
61 | 63 | } |
62 | 64 |
|
63 | | - return AzureContentSafetyFilterConfig.create() |
64 | | - .type(AzureContentSafetyFilterConfig.TypeEnum.AZURE_CONTENT_SAFETY) |
| 65 | + return AzureContentSafetyInputFilterConfig.create() |
| 66 | + .type(AzureContentSafetyInputFilterConfig.TypeEnum.AZURE_CONTENT_SAFETY) |
65 | 67 | .config( |
66 | | - AzureContentSafety.create() |
| 68 | + AzureContentSafetyInput.create() |
| 69 | + .hate(hate != null ? hate.getAzureThreshold() : null) |
| 70 | + .selfHarm(selfHarm != null ? selfHarm.getAzureThreshold() : null) |
| 71 | + .sexual(sexual != null ? sexual.getAzureThreshold() : null) |
| 72 | + .violence(violence != null ? violence.getAzureThreshold() : null)); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Converts {@code AzureContentFilter} to its serializable counterpart {@link |
| 77 | + * AzureContentSafetyOutputFilterConfig}. |
| 78 | + * |
| 79 | + * @return the corresponding {@code AzureContentSafetyOutputFilterConfig} object. |
| 80 | + * @throws IllegalArgumentException if no policies are set. |
| 81 | + */ |
| 82 | + @Override |
| 83 | + @Nonnull |
| 84 | + public AzureContentSafetyOutputFilterConfig createOutputConfig() { |
| 85 | + if (hate == null && selfHarm == null && sexual == null && violence == null) { |
| 86 | + throw new IllegalArgumentException("At least one filter category must be set"); |
| 87 | + } |
| 88 | + |
| 89 | + return AzureContentSafetyOutputFilterConfig.create() |
| 90 | + .type(AzureContentSafetyOutputFilterConfig.TypeEnum.AZURE_CONTENT_SAFETY) |
| 91 | + .config( |
| 92 | + AzureContentSafetyOutput.create() |
67 | 93 | .hate(hate != null ? hate.getAzureThreshold() : null) |
68 | 94 | .selfHarm(selfHarm != null ? selfHarm.getAzureThreshold() : null) |
69 | 95 | .sexual(sexual != null ? sexual.getAzureThreshold() : null) |
|
0 commit comments