|
16 | 16 | import com.sap.ai.sdk.orchestration.model.ModuleConfigs; |
17 | 17 | import com.sap.ai.sdk.orchestration.model.OrchestrationConfig; |
18 | 18 | import com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination; |
| 19 | +import io.vavr.control.Try; |
19 | 20 | import java.util.List; |
20 | 21 | import java.util.Map; |
21 | | -import java.util.Optional; |
22 | 22 | import java.util.function.Supplier; |
23 | 23 | import java.util.stream.Stream; |
24 | 24 | import javax.annotation.Nonnull; |
25 | | - |
26 | | -import io.vavr.control.Try; |
27 | 25 | import lombok.extern.slf4j.Slf4j; |
28 | 26 | import lombok.val; |
29 | 27 |
|
@@ -120,19 +118,20 @@ private static void throwOnContentFilter(@Nonnull final OrchestrationChatComplet |
120 | 118 | throws OrchestrationOutputFilterException { |
121 | 119 | final String finishReason = delta.getFinishReason(); |
122 | 120 | if (finishReason != null && finishReason.equals("content_filter")) { |
123 | | - final var filterDetails = Try.of(() -> getOutputFilteringChoices(delta)).getOrElseGet(e -> Map.of()); |
| 121 | + final var filterDetails = |
| 122 | + Try.of(() -> getOutputFilteringChoices(delta)).getOrElseGet(e -> Map.of()); |
124 | 123 | final var message = "Content filter filtered the output."; |
125 | 124 | throw new OrchestrationOutputFilterException(message, filterDetails); |
126 | 125 | } |
127 | 126 | } |
128 | 127 |
|
129 | 128 | @SuppressWarnings("unchecked") |
130 | | - private static Map<String, Object> getOutputFilteringChoices(@Nonnull final OrchestrationChatCompletionDelta delta) { |
| 129 | + private static Map<String, Object> getOutputFilteringChoices( |
| 130 | + @Nonnull final OrchestrationChatCompletionDelta delta) { |
131 | 131 | final var f = delta.getModuleResults().getOutputFiltering(); |
132 | 132 | return ((List<Map<String, Object>>) ((Map<String, Object>) f.getData()).get("choices")).get(0); |
133 | 133 | } |
134 | 134 |
|
135 | | - |
136 | 135 | /** |
137 | 136 | * Serializes the given request, executes it and deserializes the response. |
138 | 137 | * |
|
0 commit comments