diff --git a/docs/release_notes.md b/docs/release_notes.md index 81063f944..973c1201a 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -19,10 +19,12 @@ As a result, the accessors for fields `OrchestrationModuleConfig.inputTranslationConfig` and `OrchestrationModuleConfig.outputTranslationConfig` now handle the implementing class explicitly. The same applies to helper methods `DpiMasking#createConfig()` and `MaskingProvider#createConfig()`. - [Orchestration] `OrchestrationTemplate.withTemplate()` has been deprecated. Please use `OrchestrationTemplate.withTemplateMessages()` instead. +- [Orchestration] The method `createConfig()` is removed from `ContentFilter`, `AzureContentFilter` and `LlamaGuardFilter` and is replaced by `createInputFilterConfig()` and `createOutputFilterConfig()`. ### ✨ New Functionality - [Orchestration] Added support for [transforming a JSON output into an entity](https://sap.github.io/ai-sdk/docs/java/orchestration/chat-completion#json_schema) +- [Orchestration] Added `AzureContentFilter#promptShield()` available for input filtering. ### 📈 Improvements diff --git a/orchestration/pom.xml b/orchestration/pom.xml index f33d425a3..69ae93798 100644 --- a/orchestration/pom.xml +++ b/orchestration/pom.xml @@ -31,11 +31,11 @@ ${project.basedir}/../ - 83% + 82% 94% 95% - 78% - 94% + 77% + 93% 100% diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/AzureContentFilter.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/AzureContentFilter.java index ecbbc3a4b..7620fd54c 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/AzureContentFilter.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/AzureContentFilter.java @@ -1,7 +1,9 @@ package com.sap.ai.sdk.orchestration; -import com.sap.ai.sdk.orchestration.model.AzureContentSafety; -import com.sap.ai.sdk.orchestration.model.AzureContentSafetyFilterConfig; +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyInput; +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyInputFilterConfig; +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyOutput; +import com.sap.ai.sdk.orchestration.model.AzureContentSafetyOutputFilterConfig; import javax.annotation.Nonnull; import javax.annotation.Nullable; import lombok.NoArgsConstructor; @@ -34,36 +36,68 @@ @Accessors(fluent = true) public class AzureContentFilter implements ContentFilter { - /* The filter category for hate content. */ + /** The filter category for hate content. */ @Nullable AzureFilterThreshold hate; - /* The filter category for self-harm content. */ + /** The filter category for self-harm content. */ @Nullable AzureFilterThreshold selfHarm; - /* The filter category for sexual content. */ + /** The filter category for sexual content. */ @Nullable AzureFilterThreshold sexual; - /* The filter category for violence content. */ + /** The filter category for violence content. */ @Nullable AzureFilterThreshold violence; /** - * Converts {@code AzureContentFilter} to its serializable counterpart {@link - * AzureContentSafetyFilterConfig}. + * A flag to set prompt shield on input filer. * - * @return the corresponding {@code AzureContentSafetyFilterConfig} object. + * @since 1.9.0 + */ + @Nullable Boolean promptShield; + + /** + * Converts {@link AzureContentFilter} to its serializable counterpart {@link + * AzureContentSafetyInputFilterConfig}. + * + * @return the corresponding {@link AzureContentSafetyInputFilterConfig} object. + * @throws IllegalArgumentException if no policies are set. + */ + @Override + @Nonnull + public AzureContentSafetyInputFilterConfig createInputFilterConfig() { + if (hate == null && selfHarm == null && sexual == null && violence == null) { + throw new IllegalArgumentException("At least one filter category must be set"); + } + + return AzureContentSafetyInputFilterConfig.create() + .type(AzureContentSafetyInputFilterConfig.TypeEnum.AZURE_CONTENT_SAFETY) + .config( + AzureContentSafetyInput.create() + .hate(hate != null ? hate.getAzureThreshold() : null) + .selfHarm(selfHarm != null ? selfHarm.getAzureThreshold() : null) + .sexual(sexual != null ? sexual.getAzureThreshold() : null) + .violence(violence != null ? violence.getAzureThreshold() : null) + .promptShield(promptShield != null ? promptShield : null)); + } + + /** + * Converts {@link AzureContentFilter} to its serializable counterpart {@link + * AzureContentSafetyOutput}. + * + * @return the corresponding {@link AzureContentSafetyOutputFilterConfig} object. * @throws IllegalArgumentException if no policies are set. */ @Override @Nonnull - public AzureContentSafetyFilterConfig createConfig() { + public AzureContentSafetyOutputFilterConfig createOutputFilterConfig() { if (hate == null && selfHarm == null && sexual == null && violence == null) { throw new IllegalArgumentException("At least one filter category must be set"); } - return AzureContentSafetyFilterConfig.create() - .type(AzureContentSafetyFilterConfig.TypeEnum.AZURE_CONTENT_SAFETY) + return AzureContentSafetyOutputFilterConfig.create() + .type(AzureContentSafetyOutputFilterConfig.TypeEnum.AZURE_CONTENT_SAFETY) .config( - AzureContentSafety.create() + AzureContentSafetyOutput.create() .hate(hate != null ? hate.getAzureThreshold() : null) .selfHarm(selfHarm != null ? selfHarm.getAzureThreshold() : null) .sexual(sexual != null ? sexual.getAzureThreshold() : null) diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/ContentFilter.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/ContentFilter.java index f0b2003c6..3eccea64a 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/ContentFilter.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/ContentFilter.java @@ -1,6 +1,7 @@ package com.sap.ai.sdk.orchestration; -import com.sap.ai.sdk.orchestration.model.FilterConfig; +import com.sap.ai.sdk.orchestration.model.InputFilterConfig; +import com.sap.ai.sdk.orchestration.model.OutputFilterConfig; import javax.annotation.Nonnull; /** @@ -17,11 +18,20 @@ public interface ContentFilter { /** - * A method that produces the serializable equivalent {@link FilterConfig} object from data + * A method that produces the serializable equivalent {@link InputFilterConfig} object from data * encapsulated in the {@link ContentFilter} object. * - * @return the corresponding {@code FilterConfig} object. + * @return the corresponding {@link InputFilterConfig} object. */ @Nonnull - FilterConfig createConfig(); + InputFilterConfig createInputFilterConfig(); + + /** + * A method that produces the serializable equivalent {@link OutputFilterConfig} object from data + * encapsulated in the {@link ContentFilter} object. + * + * @return the corresponding {@link OutputFilterConfig} object. + */ + @Nonnull + OutputFilterConfig createOutputFilterConfig(); } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/DpiMasking.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/DpiMasking.java index 90f31bdaf..d9f7b26aa 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/DpiMasking.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/DpiMasking.java @@ -8,6 +8,7 @@ import com.sap.ai.sdk.orchestration.model.DPIConfigMaskGroundingInput; import com.sap.ai.sdk.orchestration.model.DPIEntities; import com.sap.ai.sdk.orchestration.model.DPIEntityConfig; +import com.sap.ai.sdk.orchestration.model.DPIStandardEntity; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -95,7 +96,8 @@ public DpiMasking withAllowList(@Nonnull final List allowList) { @Nonnull @Override public DPIConfig createConfig() { - val entitiesDTO = entities.stream().map(it -> DPIEntityConfig.create().type(it)).toList(); + val entitiesDTO = + entities.stream().map(it -> (DPIEntityConfig) DPIStandardEntity.create().type(it)).toList(); return DPIConfig.create() .type(SAP_DATA_PRIVACY_INTEGRATION) .method(maskingMethod) diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/JacksonMixins.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/JacksonMixins.java index 76b2dd9e1..bd3bade0f 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/JacksonMixins.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/JacksonMixins.java @@ -4,8 +4,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.sap.ai.sdk.orchestration.model.LLMChoice; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMModuleResult; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -13,14 +12,9 @@ final class JacksonMixins { /** Mixin to enforce a specific subtype to be deserialized always. */ @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) - @JsonDeserialize(as = LLMModuleResultSynchronous.class) + @JsonDeserialize(as = LLMModuleResult.class) interface LLMModuleResultMixIn {} - /** Mixin to enforce a specific subtype to be deserialized always. */ - @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) - @JsonDeserialize(as = LLMChoice.class) - interface ModuleResultsOutputUnmaskingInnerMixIn {} - @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = As.EXISTING_PROPERTY, diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/LlamaGuardFilter.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/LlamaGuardFilter.java index b8fa121e6..2d41a321a 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/LlamaGuardFilter.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/LlamaGuardFilter.java @@ -40,7 +40,13 @@ public class LlamaGuardFilter implements ContentFilter { @Nonnull @Override - public LlamaGuard38bFilterConfig createConfig() { + public LlamaGuard38bFilterConfig createInputFilterConfig() { return LlamaGuard38bFilterConfig.create().type(LLAMA_GUARD_3_8B).config(config); } + + @Nonnull + @Override + public LlamaGuard38bFilterConfig createOutputFilterConfig() { + return createInputFilterConfig(); + } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatCompletionDelta.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatCompletionDelta.java index 931ff8029..10c2a0e93 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatCompletionDelta.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatCompletionDelta.java @@ -1,35 +1,27 @@ package com.sap.ai.sdk.orchestration; import com.sap.ai.sdk.core.common.StreamedDelta; -import com.sap.ai.sdk.orchestration.model.CompletionPostResponse; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; -import java.util.Map; +import com.sap.ai.sdk.orchestration.model.CompletionPostResponseStreaming; import javax.annotation.Nonnull; import javax.annotation.Nullable; import lombok.val; /** Orchestration chat completion output delta for streaming. */ -public class OrchestrationChatCompletionDelta extends CompletionPostResponse +public class OrchestrationChatCompletionDelta extends CompletionPostResponseStreaming implements StreamedDelta { @Nonnull @Override - // will be fixed once the generated code add a discriminator which will allow this class to extend - // CompletionPostResponseStreaming - @SuppressWarnings("unchecked") public String getDeltaContent() { - val choices = ((LLMModuleResultSynchronous) getOrchestrationResult()).getChoices(); + val choices = getOrchestrationResult().getChoices(); // Avoid the first delta: "choices":[] if (!choices.isEmpty() // Multiple choices are spread out on multiple deltas // A delta only contains one choice with a variable index && choices.get(0).getIndex() == 0) { - final var message = (Map) choices.get(0).toMap().get("delta"); - // Avoid the second delta: "choices":[{"delta":{"content":"","role":"assistant"}}] - if (message != null && message.get("content") != null) { - return message.get("content").toString(); - } + final var message = choices.get(0).getDelta(); + return message.getContent(); } return ""; } @@ -37,9 +29,6 @@ public String getDeltaContent() { @Nullable @Override public String getFinishReason() { - return ((LLMModuleResultSynchronous) getOrchestrationResult()) - .getChoices() - .get(0) - .getFinishReason(); + return getOrchestrationResult().getChoices().get(0).getFinishReason(); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatResponse.java index eb44cce71..95629f82c 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatResponse.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatResponse.java @@ -10,7 +10,6 @@ import com.sap.ai.sdk.orchestration.model.ChatMessageContent; import com.sap.ai.sdk.orchestration.model.CompletionPostResponse; import com.sap.ai.sdk.orchestration.model.LLMChoice; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; import com.sap.ai.sdk.orchestration.model.SystemChatMessage; import com.sap.ai.sdk.orchestration.model.TokenUsage; import com.sap.ai.sdk.orchestration.model.ToolChatMessage; @@ -53,7 +52,7 @@ public String getContent() throws OrchestrationClientException { */ @Nonnull public TokenUsage getTokenUsage() { - return ((LLMModuleResultSynchronous) originalResponse.getOrchestrationResult()).getUsage(); + return originalResponse.getOrchestrationResult().getUsage(); } /** @@ -106,9 +105,7 @@ public List getAllMessages() throws IllegalArgumentException { @Nonnull public LLMChoice getChoice() { // We expect choices to be defined and never empty. - return ((LLMModuleResultSynchronous) originalResponse.getOrchestrationResult()) - .getChoices() - .get(0); + return originalResponse.getOrchestrationResult().getChoices().get(0); } /** @@ -126,7 +123,8 @@ public LLMChoice getChoice() { @Nonnull public T asEntity(@Nonnull final Class type) throws OrchestrationClientException { final String refusal = - ((LLMModuleResultSynchronous) getOriginalResponse().getOrchestrationResult()) + getOriginalResponse() + .getOrchestrationResult() .getChoices() .get(0) .getMessage() diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClient.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClient.java index 9efe16064..0f07c291f 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClient.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClient.java @@ -8,29 +8,18 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.annotations.Beta; import com.sap.ai.sdk.core.AiCoreService; -import com.sap.ai.sdk.core.DeploymentResolutionException; -import com.sap.ai.sdk.core.common.ClientResponseHandler; -import com.sap.ai.sdk.core.common.ClientStreamingHandler; -import com.sap.ai.sdk.core.common.StreamedDelta; import com.sap.ai.sdk.orchestration.model.CompletionPostRequest; import com.sap.ai.sdk.orchestration.model.CompletionPostResponse; +import com.sap.ai.sdk.orchestration.model.EmbeddingsPostRequest; +import com.sap.ai.sdk.orchestration.model.EmbeddingsPostResponse; import com.sap.ai.sdk.orchestration.model.ModuleConfigs; import com.sap.ai.sdk.orchestration.model.OrchestrationConfig; -import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Accessor; import com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination; -import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; -import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException; -import com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException; -import java.io.IOException; import java.util.function.Supplier; import java.util.stream.Stream; import javax.annotation.Nonnull; import lombok.extern.slf4j.Slf4j; import lombok.val; -import org.apache.hc.client5.http.classic.methods.HttpPost; -import org.apache.hc.core5.http.ContentType; -import org.apache.hc.core5.http.io.entity.StringEntity; -import org.apache.hc.core5.http.message.BasicClassicHttpRequest; /** Client to execute requests to the orchestration service. */ @Slf4j @@ -39,12 +28,13 @@ public class OrchestrationClient { static final ObjectMapper JACKSON = getOrchestrationObjectMapper(); - @Nonnull private final Supplier destinationSupplier; + private final OrchestrationHttpExecutor executor; /** Default constructor. */ public OrchestrationClient() { - destinationSupplier = + final Supplier destinationSupplier = () -> new AiCoreService().getInferenceDestination().forScenario(DEFAULT_SCENARIO); + this.executor = new OrchestrationHttpExecutor(destinationSupplier); } /** @@ -64,7 +54,7 @@ public OrchestrationClient() { */ @Beta public OrchestrationClient(@Nonnull final HttpDestination destination) { - this.destinationSupplier = () -> destination; + this.executor = new OrchestrationHttpExecutor(() -> destination); } /** @@ -150,15 +140,7 @@ private static void throwOnContentFilter(@Nonnull final OrchestrationChatComplet @Nonnull public CompletionPostResponse executeRequest(@Nonnull final CompletionPostRequest request) throws OrchestrationClientException { - final String jsonRequest; - try { - jsonRequest = JACKSON.writeValueAsString(request); - log.debug("Serialized request into JSON payload: {}", jsonRequest); - } catch (final JsonProcessingException e) { - throw new OrchestrationClientException("Failed to serialize request parameters", e); - } - - return executeRequest(jsonRequest); + return executor.execute("/completion", request, CompletionPostResponse.class); } /** @@ -199,38 +181,8 @@ public OrchestrationChatResponse executeRequestFromJsonModuleConfig( } requestJson.set("orchestration_config", moduleConfigJson); - final String body; - try { - body = JACKSON.writeValueAsString(requestJson); - } catch (JsonProcessingException e) { - throw new OrchestrationClientException("Failed to serialize request to JSON", e); - } - return new OrchestrationChatResponse(executeRequest(body)); - } - - @Nonnull - CompletionPostResponse executeRequest(@Nonnull final String request) { - val postRequest = new HttpPost("/completion"); - postRequest.setEntity(new StringEntity(request, ContentType.APPLICATION_JSON)); - - try { - val destination = destinationSupplier.get(); - log.debug("Using destination {} to connect to orchestration service", destination); - val client = ApacheHttpClient5Accessor.getHttpClient(destination); - val handler = - new ClientResponseHandler<>( - CompletionPostResponse.class, - OrchestrationError.class, - OrchestrationClientException::new) - .objectMapper(JACKSON); - return client.execute(postRequest, handler); - } catch (DeploymentResolutionException - | DestinationAccessException - | DestinationNotFoundException - | HttpClientInstantiationException - | IOException e) { - throw new OrchestrationClientException("Failed to execute request", e); - } + return new OrchestrationChatResponse( + executor.execute("/completion", requestJson, CompletionPostResponse.class)); } /** @@ -245,42 +197,20 @@ CompletionPostResponse executeRequest(@Nonnull final String request) { public Stream streamChatCompletionDeltas( @Nonnull final CompletionPostRequest request) throws OrchestrationClientException { request.getOrchestrationConfig().setStream(true); - return executeStream("/completion", request, OrchestrationChatCompletionDelta.class); - } - - @Nonnull - private Stream executeStream( - @Nonnull final String path, - @Nonnull final Object payload, - @Nonnull final Class deltaType) { - final var request = new HttpPost(path); - serializeAndSetHttpEntity(request, payload); - return streamRequest(request, deltaType); - } - - private static void serializeAndSetHttpEntity( - @Nonnull final BasicClassicHttpRequest request, @Nonnull final Object payload) { - try { - final var json = JACKSON.writeValueAsString(payload); - request.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); - } catch (final JsonProcessingException e) { - throw new OrchestrationClientException("Failed to serialize request parameters", e); - } + return executor.stream(request); } + /** + * Generate embeddings for the given request. + * + * @param request the request containing the input text and other parameters. + * @return the response containing the embeddings. + * @throws OrchestrationClientException if the request fails + * @since 1.9.0 + */ @Nonnull - private Stream streamRequest( - final BasicClassicHttpRequest request, @Nonnull final Class deltaType) { - try { - val destination = destinationSupplier.get(); - log.debug("Using destination {} to connect to orchestration service", destination); - val client = ApacheHttpClient5Accessor.getHttpClient(destination); - return new ClientStreamingHandler<>( - deltaType, OrchestrationError.class, OrchestrationClientException::new) - .objectMapper(JACKSON) - .handleStreamingResponse(client.executeOpen(null, request, null)); - } catch (final IOException e) { - throw new OrchestrationClientException("Request to the Orchestration service failed", e); - } + EmbeddingsPostResponse embed(@Nonnull final EmbeddingsPostRequest request) + throws OrchestrationClientException { + return executor.execute("/v2/embeddings", request, EmbeddingsPostResponse.class); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java new file mode 100644 index 000000000..b5c51bfc8 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java @@ -0,0 +1,98 @@ +package com.sap.ai.sdk.orchestration; + +import static com.sap.ai.sdk.orchestration.OrchestrationJacksonConfiguration.getOrchestrationObjectMapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.sap.ai.sdk.core.DeploymentResolutionException; +import com.sap.ai.sdk.core.common.ClientResponseHandler; +import com.sap.ai.sdk.core.common.ClientStreamingHandler; +import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Accessor; +import com.sap.cloud.sdk.cloudplatform.connectivity.HttpDestination; +import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; +import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException; +import com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException; +import java.io.IOException; +import java.util.function.Supplier; +import java.util.stream.Stream; +import javax.annotation.Nonnull; +import lombok.extern.slf4j.Slf4j; +import lombok.val; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; + +@Slf4j +class OrchestrationHttpExecutor { + private final Supplier destinationSupplier; + private static final ObjectMapper JACKSON = getOrchestrationObjectMapper(); + + OrchestrationHttpExecutor(@Nonnull final Supplier destinationSupplier) + throws OrchestrationClientException { + this.destinationSupplier = destinationSupplier; + } + + @Nonnull + T execute( + @Nonnull final String path, + @Nonnull final Object payload, + @Nonnull final Class responseType) { + try { + val json = JACKSON.writeValueAsString(payload); + log.debug("Serialized request into JSON payload: {}", json); + val request = new HttpPost(path); + request.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); + + val client = getHttpClient(); + + val handler = + new ClientResponseHandler<>( + responseType, OrchestrationError.class, OrchestrationClientException::new) + .objectMapper(JACKSON); + return client.execute(request, handler); + + } catch (JsonProcessingException e) { + throw new OrchestrationClientException("Failed to serialize request payload for " + path, e); + } catch (DeploymentResolutionException + | DestinationAccessException + | DestinationNotFoundException + | HttpClientInstantiationException + | IOException e) { + throw new OrchestrationClientException( + "Request to Orchestration service failed for " + path, e); + } + } + + @Nonnull + Stream stream(@Nonnull final Object payload) { + try { + + val json = JACKSON.writeValueAsString(payload); + val request = new HttpPost("/completion"); + request.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); + val client = getHttpClient(); + + return new ClientStreamingHandler<>( + OrchestrationChatCompletionDelta.class, + OrchestrationError.class, + OrchestrationClientException::new) + .objectMapper(JACKSON) + .handleStreamingResponse(client.executeOpen(null, request, null)); + + } catch (JsonProcessingException e) { + throw new OrchestrationClientException( + "Failed to serialize payload for streaming request", e); + } catch (IOException e) { + throw new OrchestrationClientException( + "Streaming request to the Orchestration service failed", e); + } + } + + @Nonnull + private HttpClient getHttpClient() { + val destination = destinationSupplier.get(); + log.debug("Using destination {} to connect to orchestration service", destination); + return ApacheHttpClient5Accessor.getHttpClient(destination); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationJacksonConfiguration.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationJacksonConfiguration.java index be009b1a7..3cb017575 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationJacksonConfiguration.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationJacksonConfiguration.java @@ -6,8 +6,6 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.google.common.annotations.Beta; import com.sap.ai.sdk.orchestration.model.ChatMessage; -import com.sap.ai.sdk.orchestration.model.LLMModuleResult; -import com.sap.ai.sdk.orchestration.model.ModuleResultsOutputUnmaskingInner; import com.sap.ai.sdk.orchestration.model.TemplateResponseFormat; import javax.annotation.Nonnull; import lombok.AccessLevel; @@ -37,11 +35,6 @@ public static ObjectMapper getOrchestrationObjectMapper() { val jackson = getDefaultObjectMapper(); - // Add mix-ins - jackson.addMixIn(LLMModuleResult.class, JacksonMixins.LLMModuleResultMixIn.class); - jackson.addMixIn( - ModuleResultsOutputUnmaskingInner.class, - JacksonMixins.ModuleResultsOutputUnmaskingInnerMixIn.class); jackson.addMixIn(ChatMessage.class, JacksonMixins.ChatMessageMixin.class); final var module = diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfig.java index f2a83f88f..1b8b7ca19 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfig.java @@ -159,7 +159,10 @@ public OrchestrationModuleConfig withInputFiltering( allFilters.addAll(Arrays.asList(contentFilters)); final var filterConfigs = - allFilters.stream().filter(Objects::nonNull).map(ContentFilter::createConfig).toList(); + allFilters.stream() + .filter(Objects::nonNull) + .map(ContentFilter::createInputFilterConfig) + .toList(); final var inputFilter = InputFilteringConfig.create().filters(filterConfigs); @@ -194,7 +197,10 @@ public OrchestrationModuleConfig withOutputFiltering( allFilters.addAll(Arrays.asList(contentFilters)); final var filterConfigs = - allFilters.stream().filter(Objects::nonNull).map(ContentFilter::createConfig).toList(); + allFilters.stream() + .filter(Objects::nonNull) + .map(ContentFilter::createOutputFilterConfig) + .toList(); final var outputFilter = OutputFilteringConfig.create().filters(filterConfigs); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInput.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInput.java new file mode 100644 index 000000000..4c4ccd4af --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInput.java @@ -0,0 +1,320 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Filter configuration for Azure Content Safety */ +// CHECKSTYLE:OFF +public class AzureContentSafetyInput +// CHECKSTYLE:ON +{ + @JsonProperty("Hate") + private AzureThreshold hate; + + @JsonProperty("SelfHarm") + private AzureThreshold selfHarm; + + @JsonProperty("Sexual") + private AzureThreshold sexual; + + @JsonProperty("Violence") + private AzureThreshold violence; + + @JsonProperty("PromptShield") + private Boolean promptShield = false; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for AzureContentSafetyInput. */ + protected AzureContentSafetyInput() {} + + /** + * Set the hate of this {@link AzureContentSafetyInput} instance and return the same instance. + * + * @param hate The hate of this {@link AzureContentSafetyInput} + * @return The same instance of this {@link AzureContentSafetyInput} class + */ + @Nonnull + public AzureContentSafetyInput hate(@Nullable final AzureThreshold hate) { + this.hate = hate; + return this; + } + + /** + * Get hate + * + * @return hate The hate of this {@link AzureContentSafetyInput} instance. + */ + @Nonnull + public AzureThreshold getHate() { + return hate; + } + + /** + * Set the hate of this {@link AzureContentSafetyInput} instance. + * + * @param hate The hate of this {@link AzureContentSafetyInput} + */ + public void setHate(@Nullable final AzureThreshold hate) { + this.hate = hate; + } + + /** + * Set the selfHarm of this {@link AzureContentSafetyInput} instance and return the same instance. + * + * @param selfHarm The selfHarm of this {@link AzureContentSafetyInput} + * @return The same instance of this {@link AzureContentSafetyInput} class + */ + @Nonnull + public AzureContentSafetyInput selfHarm(@Nullable final AzureThreshold selfHarm) { + this.selfHarm = selfHarm; + return this; + } + + /** + * Get selfHarm + * + * @return selfHarm The selfHarm of this {@link AzureContentSafetyInput} instance. + */ + @Nonnull + public AzureThreshold getSelfHarm() { + return selfHarm; + } + + /** + * Set the selfHarm of this {@link AzureContentSafetyInput} instance. + * + * @param selfHarm The selfHarm of this {@link AzureContentSafetyInput} + */ + public void setSelfHarm(@Nullable final AzureThreshold selfHarm) { + this.selfHarm = selfHarm; + } + + /** + * Set the sexual of this {@link AzureContentSafetyInput} instance and return the same instance. + * + * @param sexual The sexual of this {@link AzureContentSafetyInput} + * @return The same instance of this {@link AzureContentSafetyInput} class + */ + @Nonnull + public AzureContentSafetyInput sexual(@Nullable final AzureThreshold sexual) { + this.sexual = sexual; + return this; + } + + /** + * Get sexual + * + * @return sexual The sexual of this {@link AzureContentSafetyInput} instance. + */ + @Nonnull + public AzureThreshold getSexual() { + return sexual; + } + + /** + * Set the sexual of this {@link AzureContentSafetyInput} instance. + * + * @param sexual The sexual of this {@link AzureContentSafetyInput} + */ + public void setSexual(@Nullable final AzureThreshold sexual) { + this.sexual = sexual; + } + + /** + * Set the violence of this {@link AzureContentSafetyInput} instance and return the same instance. + * + * @param violence The violence of this {@link AzureContentSafetyInput} + * @return The same instance of this {@link AzureContentSafetyInput} class + */ + @Nonnull + public AzureContentSafetyInput violence(@Nullable final AzureThreshold violence) { + this.violence = violence; + return this; + } + + /** + * Get violence + * + * @return violence The violence of this {@link AzureContentSafetyInput} instance. + */ + @Nonnull + public AzureThreshold getViolence() { + return violence; + } + + /** + * Set the violence of this {@link AzureContentSafetyInput} instance. + * + * @param violence The violence of this {@link AzureContentSafetyInput} + */ + public void setViolence(@Nullable final AzureThreshold violence) { + this.violence = violence; + } + + /** + * Set the promptShield of this {@link AzureContentSafetyInput} instance and return the same + * instance. + * + * @param promptShield A flag to use prompt shield + * @return The same instance of this {@link AzureContentSafetyInput} class + */ + @Nonnull + public AzureContentSafetyInput promptShield(@Nullable final Boolean promptShield) { + this.promptShield = promptShield; + return this; + } + + /** + * A flag to use prompt shield + * + * @return promptShield The promptShield of this {@link AzureContentSafetyInput} instance. + */ + @Nonnull + public Boolean isPromptShield() { + return promptShield; + } + + /** + * Set the promptShield of this {@link AzureContentSafetyInput} instance. + * + * @param promptShield A flag to use prompt shield + */ + public void setPromptShield(@Nullable final Boolean promptShield) { + this.promptShield = promptShield; + } + + /** + * Get the names of the unrecognizable properties of the {@link AzureContentSafetyInput}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AzureContentSafetyInput} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "AzureContentSafetyInput has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link AzureContentSafetyInput} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (hate != null) declaredFields.put("hate", hate); + if (selfHarm != null) declaredFields.put("selfHarm", selfHarm); + if (sexual != null) declaredFields.put("sexual", sexual); + if (violence != null) declaredFields.put("violence", violence); + if (promptShield != null) declaredFields.put("promptShield", promptShield); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link AzureContentSafetyInput} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AzureContentSafetyInput azureContentSafetyInput = (AzureContentSafetyInput) o; + return Objects.equals(this.cloudSdkCustomFields, azureContentSafetyInput.cloudSdkCustomFields) + && Objects.equals(this.hate, azureContentSafetyInput.hate) + && Objects.equals(this.selfHarm, azureContentSafetyInput.selfHarm) + && Objects.equals(this.sexual, azureContentSafetyInput.sexual) + && Objects.equals(this.violence, azureContentSafetyInput.violence) + && Objects.equals(this.promptShield, azureContentSafetyInput.promptShield); + } + + @Override + public int hashCode() { + return Objects.hash(hate, selfHarm, sexual, violence, promptShield, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AzureContentSafetyInput {\n"); + sb.append(" hate: ").append(toIndentedString(hate)).append("\n"); + sb.append(" selfHarm: ").append(toIndentedString(selfHarm)).append("\n"); + sb.append(" sexual: ").append(toIndentedString(sexual)).append("\n"); + sb.append(" violence: ").append(toIndentedString(violence)).append("\n"); + sb.append(" promptShield: ").append(toIndentedString(promptShield)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link AzureContentSafetyInput} instance. No arguments are required. */ + public static AzureContentSafetyInput create() { + return new AzureContentSafetyInput(); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java similarity index 71% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyFilterConfig.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java index 1ee8e13fd..3de44c4d5 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyFilterConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java @@ -25,17 +25,17 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** AzureContentSafetyFilterConfig */ +/** AzureContentSafetyInputFilterConfig */ // CHECKSTYLE:OFF -public class AzureContentSafetyFilterConfig implements FilterConfig +public class AzureContentSafetyInputFilterConfig implements InputFilterConfig // CHECKSTYLE:ON { /** Name of the filter provider type */ public enum TypeEnum { - /** The AZURE_CONTENT_SAFETY option of this AzureContentSafetyFilterConfig */ + /** The AZURE_CONTENT_SAFETY option of this AzureContentSafetyInputFilterConfig */ AZURE_CONTENT_SAFETY("azure_content_safety"), - /** The UNKNOWN_DEFAULT_OPEN_API option of this AzureContentSafetyFilterConfig */ + /** The UNKNOWN_DEFAULT_OPEN_API option of this AzureContentSafetyInputFilterConfig */ UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -70,7 +70,7 @@ public String toString() { * Get the enum value from a String value * * @param value The String value - * @return The enum value of type AzureContentSafetyFilterConfig + * @return The enum value of type AzureContentSafetyInputFilterConfig */ @JsonCreator @Nonnull @@ -88,23 +88,23 @@ public static TypeEnum fromValue(@Nonnull final String value) { private TypeEnum type; @JsonProperty("config") - private AzureContentSafety config; + private AzureContentSafetyInput config; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for AzureContentSafetyFilterConfig. */ - protected AzureContentSafetyFilterConfig() {} + /** Default constructor for AzureContentSafetyInputFilterConfig. */ + protected AzureContentSafetyInputFilterConfig() {} /** - * Set the type of this {@link AzureContentSafetyFilterConfig} instance and return the same + * Set the type of this {@link AzureContentSafetyInputFilterConfig} instance and return the same * instance. * * @param type Name of the filter provider type - * @return The same instance of this {@link AzureContentSafetyFilterConfig} class + * @return The same instance of this {@link AzureContentSafetyInputFilterConfig} class */ @Nonnull - public AzureContentSafetyFilterConfig type(@Nonnull final TypeEnum type) { + public AzureContentSafetyInputFilterConfig type(@Nonnull final TypeEnum type) { this.type = type; return this; } @@ -112,7 +112,7 @@ public AzureContentSafetyFilterConfig type(@Nonnull final TypeEnum type) { /** * Name of the filter provider type * - * @return type The type of this {@link AzureContentSafetyFilterConfig} instance. + * @return type The type of this {@link AzureContentSafetyInputFilterConfig} instance. */ @Nonnull public TypeEnum getType() { @@ -120,7 +120,7 @@ public TypeEnum getType() { } /** - * Set the type of this {@link AzureContentSafetyFilterConfig} instance. + * Set the type of this {@link AzureContentSafetyInputFilterConfig} instance. * * @param type Name of the filter provider type */ @@ -129,14 +129,15 @@ public void setType(@Nonnull final TypeEnum type) { } /** - * Set the config of this {@link AzureContentSafetyFilterConfig} instance and return the same + * Set the config of this {@link AzureContentSafetyInputFilterConfig} instance and return the same * instance. * - * @param config The config of this {@link AzureContentSafetyFilterConfig} - * @return The same instance of this {@link AzureContentSafetyFilterConfig} class + * @param config The config of this {@link AzureContentSafetyInputFilterConfig} + * @return The same instance of this {@link AzureContentSafetyInputFilterConfig} class */ @Nonnull - public AzureContentSafetyFilterConfig config(@Nullable final AzureContentSafety config) { + public AzureContentSafetyInputFilterConfig config( + @Nullable final AzureContentSafetyInput config) { this.config = config; return this; } @@ -144,24 +145,25 @@ public AzureContentSafetyFilterConfig config(@Nullable final AzureContentSafety /** * Get config * - * @return config The config of this {@link AzureContentSafetyFilterConfig} instance. + * @return config The config of this {@link AzureContentSafetyInputFilterConfig} instance. */ @Nonnull - public AzureContentSafety getConfig() { + public AzureContentSafetyInput getConfig() { return config; } /** - * Set the config of this {@link AzureContentSafetyFilterConfig} instance. + * Set the config of this {@link AzureContentSafetyInputFilterConfig} instance. * - * @param config The config of this {@link AzureContentSafetyFilterConfig} + * @param config The config of this {@link AzureContentSafetyInputFilterConfig} */ - public void setConfig(@Nullable final AzureContentSafety config) { + public void setConfig(@Nullable final AzureContentSafetyInput config) { this.config = config; } /** - * Get the names of the unrecognizable properties of the {@link AzureContentSafetyFilterConfig}. + * Get the names of the unrecognizable properties of the {@link + * AzureContentSafetyInputFilterConfig}. * * @return The set of properties names */ @@ -172,7 +174,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link AzureContentSafetyFilterConfig} + * Get the value of an unrecognizable property of this {@link AzureContentSafetyInputFilterConfig} * instance. * * @deprecated Use {@link #toMap()} instead. @@ -185,13 +187,13 @@ public Set getCustomFieldNames() { public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { throw new NoSuchElementException( - "AzureContentSafetyFilterConfig has no field with name '" + name + "'."); + "AzureContentSafetyInputFilterConfig has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link AzureContentSafetyFilterConfig} instance + * Get the value of all properties of this {@link AzureContentSafetyInputFilterConfig} instance * including unrecognized properties. * * @return The map of all properties @@ -206,8 +208,8 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link AzureContentSafetyFilterConfig} instance. If the - * map previously contained a mapping for the key, the old value is replaced by the specified + * Set an unrecognizable property of this {@link AzureContentSafetyInputFilterConfig} instance. If + * the map previously contained a mapping for the key, the old value is replaced by the specified * value. * * @param customFieldName The name of the property @@ -226,12 +228,12 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final AzureContentSafetyFilterConfig azureContentSafetyFilterConfig = - (AzureContentSafetyFilterConfig) o; + final AzureContentSafetyInputFilterConfig azureContentSafetyInputFilterConfig = + (AzureContentSafetyInputFilterConfig) o; return Objects.equals( - this.cloudSdkCustomFields, azureContentSafetyFilterConfig.cloudSdkCustomFields) - && Objects.equals(this.type, azureContentSafetyFilterConfig.type) - && Objects.equals(this.config, azureContentSafetyFilterConfig.config); + this.cloudSdkCustomFields, azureContentSafetyInputFilterConfig.cloudSdkCustomFields) + && Objects.equals(this.type, azureContentSafetyInputFilterConfig.type) + && Objects.equals(this.config, azureContentSafetyInputFilterConfig.config); } @Override @@ -243,7 +245,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class AzureContentSafetyFilterConfig {\n"); + sb.append("class AzureContentSafetyInputFilterConfig {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" config: ").append(toIndentedString(config)).append("\n"); cloudSdkCustomFields.forEach( @@ -265,20 +267,20 @@ private String toIndentedString(final java.lang.Object o) { /** * Create a type-safe, fluent-api builder object to construct a new {@link - * AzureContentSafetyFilterConfig} instance with all required arguments. + * AzureContentSafetyInputFilterConfig} instance with all required arguments. */ public static Builder create() { - return (type) -> new AzureContentSafetyFilterConfig().type(type); + return (type) -> new AzureContentSafetyInputFilterConfig().type(type); } /** Builder helper class. */ public interface Builder { /** - * Set the type of this {@link AzureContentSafetyFilterConfig} instance. + * Set the type of this {@link AzureContentSafetyInputFilterConfig} instance. * * @param type Name of the filter provider type - * @return The AzureContentSafetyFilterConfig instance. + * @return The AzureContentSafetyInputFilterConfig instance. */ - AzureContentSafetyFilterConfig type(@Nonnull final TypeEnum type); + AzureContentSafetyInputFilterConfig type(@Nonnull final TypeEnum type); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafety.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java similarity index 72% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafety.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java index dcece0626..f428f183a 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafety.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java @@ -25,7 +25,7 @@ /** Filter configuration for Azure Content Safety */ // CHECKSTYLE:OFF -public class AzureContentSafety +public class AzureContentSafetyOutput // CHECKSTYLE:ON { @JsonProperty("Hate") @@ -43,17 +43,17 @@ public class AzureContentSafety @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for AzureContentSafety. */ - protected AzureContentSafety() {} + /** Default constructor for AzureContentSafetyOutput. */ + protected AzureContentSafetyOutput() {} /** - * Set the hate of this {@link AzureContentSafety} instance and return the same instance. + * Set the hate of this {@link AzureContentSafetyOutput} instance and return the same instance. * - * @param hate The hate of this {@link AzureContentSafety} - * @return The same instance of this {@link AzureContentSafety} class + * @param hate The hate of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class */ @Nonnull - public AzureContentSafety hate(@Nullable final AzureThreshold hate) { + public AzureContentSafetyOutput hate(@Nullable final AzureThreshold hate) { this.hate = hate; return this; } @@ -61,7 +61,7 @@ public AzureContentSafety hate(@Nullable final AzureThreshold hate) { /** * Get hate * - * @return hate The hate of this {@link AzureContentSafety} instance. + * @return hate The hate of this {@link AzureContentSafetyOutput} instance. */ @Nonnull public AzureThreshold getHate() { @@ -69,22 +69,23 @@ public AzureThreshold getHate() { } /** - * Set the hate of this {@link AzureContentSafety} instance. + * Set the hate of this {@link AzureContentSafetyOutput} instance. * - * @param hate The hate of this {@link AzureContentSafety} + * @param hate The hate of this {@link AzureContentSafetyOutput} */ public void setHate(@Nullable final AzureThreshold hate) { this.hate = hate; } /** - * Set the selfHarm of this {@link AzureContentSafety} instance and return the same instance. + * Set the selfHarm of this {@link AzureContentSafetyOutput} instance and return the same + * instance. * - * @param selfHarm The selfHarm of this {@link AzureContentSafety} - * @return The same instance of this {@link AzureContentSafety} class + * @param selfHarm The selfHarm of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class */ @Nonnull - public AzureContentSafety selfHarm(@Nullable final AzureThreshold selfHarm) { + public AzureContentSafetyOutput selfHarm(@Nullable final AzureThreshold selfHarm) { this.selfHarm = selfHarm; return this; } @@ -92,7 +93,7 @@ public AzureContentSafety selfHarm(@Nullable final AzureThreshold selfHarm) { /** * Get selfHarm * - * @return selfHarm The selfHarm of this {@link AzureContentSafety} instance. + * @return selfHarm The selfHarm of this {@link AzureContentSafetyOutput} instance. */ @Nonnull public AzureThreshold getSelfHarm() { @@ -100,22 +101,22 @@ public AzureThreshold getSelfHarm() { } /** - * Set the selfHarm of this {@link AzureContentSafety} instance. + * Set the selfHarm of this {@link AzureContentSafetyOutput} instance. * - * @param selfHarm The selfHarm of this {@link AzureContentSafety} + * @param selfHarm The selfHarm of this {@link AzureContentSafetyOutput} */ public void setSelfHarm(@Nullable final AzureThreshold selfHarm) { this.selfHarm = selfHarm; } /** - * Set the sexual of this {@link AzureContentSafety} instance and return the same instance. + * Set the sexual of this {@link AzureContentSafetyOutput} instance and return the same instance. * - * @param sexual The sexual of this {@link AzureContentSafety} - * @return The same instance of this {@link AzureContentSafety} class + * @param sexual The sexual of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class */ @Nonnull - public AzureContentSafety sexual(@Nullable final AzureThreshold sexual) { + public AzureContentSafetyOutput sexual(@Nullable final AzureThreshold sexual) { this.sexual = sexual; return this; } @@ -123,7 +124,7 @@ public AzureContentSafety sexual(@Nullable final AzureThreshold sexual) { /** * Get sexual * - * @return sexual The sexual of this {@link AzureContentSafety} instance. + * @return sexual The sexual of this {@link AzureContentSafetyOutput} instance. */ @Nonnull public AzureThreshold getSexual() { @@ -131,22 +132,23 @@ public AzureThreshold getSexual() { } /** - * Set the sexual of this {@link AzureContentSafety} instance. + * Set the sexual of this {@link AzureContentSafetyOutput} instance. * - * @param sexual The sexual of this {@link AzureContentSafety} + * @param sexual The sexual of this {@link AzureContentSafetyOutput} */ public void setSexual(@Nullable final AzureThreshold sexual) { this.sexual = sexual; } /** - * Set the violence of this {@link AzureContentSafety} instance and return the same instance. + * Set the violence of this {@link AzureContentSafetyOutput} instance and return the same + * instance. * - * @param violence The violence of this {@link AzureContentSafety} - * @return The same instance of this {@link AzureContentSafety} class + * @param violence The violence of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class */ @Nonnull - public AzureContentSafety violence(@Nullable final AzureThreshold violence) { + public AzureContentSafetyOutput violence(@Nullable final AzureThreshold violence) { this.violence = violence; return this; } @@ -154,7 +156,7 @@ public AzureContentSafety violence(@Nullable final AzureThreshold violence) { /** * Get violence * - * @return violence The violence of this {@link AzureContentSafety} instance. + * @return violence The violence of this {@link AzureContentSafetyOutput} instance. */ @Nonnull public AzureThreshold getViolence() { @@ -162,16 +164,16 @@ public AzureThreshold getViolence() { } /** - * Set the violence of this {@link AzureContentSafety} instance. + * Set the violence of this {@link AzureContentSafetyOutput} instance. * - * @param violence The violence of this {@link AzureContentSafety} + * @param violence The violence of this {@link AzureContentSafetyOutput} */ public void setViolence(@Nullable final AzureThreshold violence) { this.violence = violence; } /** - * Get the names of the unrecognizable properties of the {@link AzureContentSafety}. + * Get the names of the unrecognizable properties of the {@link AzureContentSafetyOutput}. * * @return The set of properties names */ @@ -182,7 +184,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link AzureContentSafety} instance. + * Get the value of an unrecognizable property of this {@link AzureContentSafetyOutput} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -193,13 +195,14 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException("AzureContentSafety has no field with name '" + name + "'."); + throw new NoSuchElementException( + "AzureContentSafetyOutput has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link AzureContentSafety} instance including + * Get the value of all properties of this {@link AzureContentSafetyOutput} instance including * unrecognized properties. * * @return The map of all properties @@ -216,7 +219,7 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link AzureContentSafety} instance. If the map + * Set an unrecognizable property of this {@link AzureContentSafetyOutput} instance. If the map * previously contained a mapping for the key, the old value is replaced by the specified value. * * @param customFieldName The name of the property @@ -235,12 +238,12 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final AzureContentSafety azureContentSafety = (AzureContentSafety) o; - return Objects.equals(this.cloudSdkCustomFields, azureContentSafety.cloudSdkCustomFields) - && Objects.equals(this.hate, azureContentSafety.hate) - && Objects.equals(this.selfHarm, azureContentSafety.selfHarm) - && Objects.equals(this.sexual, azureContentSafety.sexual) - && Objects.equals(this.violence, azureContentSafety.violence); + final AzureContentSafetyOutput azureContentSafetyOutput = (AzureContentSafetyOutput) o; + return Objects.equals(this.cloudSdkCustomFields, azureContentSafetyOutput.cloudSdkCustomFields) + && Objects.equals(this.hate, azureContentSafetyOutput.hate) + && Objects.equals(this.selfHarm, azureContentSafetyOutput.selfHarm) + && Objects.equals(this.sexual, azureContentSafetyOutput.sexual) + && Objects.equals(this.violence, azureContentSafetyOutput.violence); } @Override @@ -252,7 +255,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class AzureContentSafety {\n"); + sb.append("class AzureContentSafetyOutput {\n"); sb.append(" hate: ").append(toIndentedString(hate)).append("\n"); sb.append(" selfHarm: ").append(toIndentedString(selfHarm)).append("\n"); sb.append(" sexual: ").append(toIndentedString(sexual)).append("\n"); @@ -274,8 +277,8 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - /** Create a new {@link AzureContentSafety} instance. No arguments are required. */ - public static AzureContentSafety create() { - return new AzureContentSafety(); + /** Create a new {@link AzureContentSafetyOutput} instance. No arguments are required. */ + public static AzureContentSafetyOutput create() { + return new AzureContentSafetyOutput(); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutputFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutputFilterConfig.java new file mode 100644 index 000000000..c083b6c20 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutputFilterConfig.java @@ -0,0 +1,286 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** AzureContentSafetyOutputFilterConfig */ +// CHECKSTYLE:OFF +public class AzureContentSafetyOutputFilterConfig implements OutputFilterConfig +// CHECKSTYLE:ON +{ + /** Name of the filter provider type */ + public enum TypeEnum { + /** The AZURE_CONTENT_SAFETY option of this AzureContentSafetyOutputFilterConfig */ + AZURE_CONTENT_SAFETY("azure_content_safety"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this AzureContentSafetyOutputFilterConfig */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type AzureContentSafetyOutputFilterConfig + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("config") + private AzureContentSafetyOutput config; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for AzureContentSafetyOutputFilterConfig. */ + protected AzureContentSafetyOutputFilterConfig() {} + + /** + * Set the type of this {@link AzureContentSafetyOutputFilterConfig} instance and return the same + * instance. + * + * @param type Name of the filter provider type + * @return The same instance of this {@link AzureContentSafetyOutputFilterConfig} class + */ + @Nonnull + public AzureContentSafetyOutputFilterConfig type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * Name of the filter provider type + * + * @return type The type of this {@link AzureContentSafetyOutputFilterConfig} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link AzureContentSafetyOutputFilterConfig} instance. + * + * @param type Name of the filter provider type + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the config of this {@link AzureContentSafetyOutputFilterConfig} instance and return the + * same instance. + * + * @param config The config of this {@link AzureContentSafetyOutputFilterConfig} + * @return The same instance of this {@link AzureContentSafetyOutputFilterConfig} class + */ + @Nonnull + public AzureContentSafetyOutputFilterConfig config( + @Nullable final AzureContentSafetyOutput config) { + this.config = config; + return this; + } + + /** + * Get config + * + * @return config The config of this {@link AzureContentSafetyOutputFilterConfig} instance. + */ + @Nonnull + public AzureContentSafetyOutput getConfig() { + return config; + } + + /** + * Set the config of this {@link AzureContentSafetyOutputFilterConfig} instance. + * + * @param config The config of this {@link AzureContentSafetyOutputFilterConfig} + */ + public void setConfig(@Nullable final AzureContentSafetyOutput config) { + this.config = config; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * AzureContentSafetyOutputFilterConfig}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * AzureContentSafetyOutputFilterConfig} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "AzureContentSafetyOutputFilterConfig has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link AzureContentSafetyOutputFilterConfig} instance + * including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (type != null) declaredFields.put("type", type); + if (config != null) declaredFields.put("config", config); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link AzureContentSafetyOutputFilterConfig} instance. + * If the map previously contained a mapping for the key, the old value is replaced by the + * specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AzureContentSafetyOutputFilterConfig azureContentSafetyOutputFilterConfig = + (AzureContentSafetyOutputFilterConfig) o; + return Objects.equals( + this.cloudSdkCustomFields, azureContentSafetyOutputFilterConfig.cloudSdkCustomFields) + && Objects.equals(this.type, azureContentSafetyOutputFilterConfig.type) + && Objects.equals(this.config, azureContentSafetyOutputFilterConfig.config); + } + + @Override + public int hashCode() { + return Objects.hash(type, config, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AzureContentSafetyOutputFilterConfig {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" config: ").append(toIndentedString(config)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link + * AzureContentSafetyOutputFilterConfig} instance with all required arguments. + */ + public static Builder create() { + return (type) -> new AzureContentSafetyOutputFilterConfig().type(type); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the type of this {@link AzureContentSafetyOutputFilterConfig} instance. + * + * @param type Name of the filter provider type + * @return The AzureContentSafetyOutputFilterConfig instance. + */ + AzureContentSafetyOutputFilterConfig type(@Nonnull final TypeEnum type); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprob.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprob.java new file mode 100644 index 000000000..61dc8142d --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprob.java @@ -0,0 +1,354 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ChatCompletionTokenLogprob */ +// CHECKSTYLE:OFF +public class ChatCompletionTokenLogprob +// CHECKSTYLE:ON +{ + @JsonProperty("token") + private String token; + + @JsonProperty("logprob") + private Float logprob; + + @JsonProperty("bytes") + private List bytes = new ArrayList<>(); + + @JsonProperty("top_logprobs") + private List topLogprobs = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ChatCompletionTokenLogprob. */ + protected ChatCompletionTokenLogprob() {} + + /** + * Set the token of this {@link ChatCompletionTokenLogprob} instance and return the same instance. + * + * @param token The token. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob token(@Nonnull final String token) { + this.token = token; + return this; + } + + /** + * The token. + * + * @return token The token of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nonnull + public String getToken() { + return token; + } + + /** + * Set the token of this {@link ChatCompletionTokenLogprob} instance. + * + * @param token The token. + */ + public void setToken(@Nonnull final String token) { + this.token = token; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprob} instance and return the same + * instance. + * + * @param logprob The log probability of this token. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob logprob(@Nonnull final Float logprob) { + this.logprob = logprob; + return this; + } + + /** + * The log probability of this token. + * + * @return logprob The logprob of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nonnull + public Float getLogprob() { + return logprob; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprob} instance. + * + * @param logprob The log probability of this token. + */ + public void setLogprob(@Nonnull final Float logprob) { + this.logprob = logprob; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprob} instance and return the same instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are multi-byte. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob bytes(@Nullable final List bytes) { + this.bytes = bytes; + return this; + } + + /** + * Add one bytes instance to this {@link ChatCompletionTokenLogprob}. + * + * @param bytesItem The bytes that should be added + * @return The same instance of type {@link ChatCompletionTokenLogprob} + */ + @Nonnull + public ChatCompletionTokenLogprob addBytesItem(@Nonnull final Integer bytesItem) { + if (this.bytes == null) { + this.bytes = new ArrayList<>(); + } + this.bytes.add(bytesItem); + return this; + } + + /** + * A list of integers representing the UTF-8 bytes representation of the token. Useful in + * instances where characters are multi-byte. + * + * @return bytes The bytes of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nonnull + public List getBytes() { + return bytes; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprob} instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are multi-byte. + */ + public void setBytes(@Nullable final List bytes) { + this.bytes = bytes; + } + + /** + * Set the topLogprobs of this {@link ChatCompletionTokenLogprob} instance and return the same + * instance. + * + * @param topLogprobs List of the most likely tokens and their log probability, at this token + * position. In rare cases, there may be fewer than the number of requested + * `top_logprobs`. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob topLogprobs( + @Nullable final List topLogprobs) { + this.topLogprobs = topLogprobs; + return this; + } + + /** + * Add one topLogprobs instance to this {@link ChatCompletionTokenLogprob}. + * + * @param topLogprobsItem The topLogprobs that should be added + * @return The same instance of type {@link ChatCompletionTokenLogprob} + */ + @Nonnull + public ChatCompletionTokenLogprob addTopLogprobsItem( + @Nonnull final ChatCompletionTokenLogprobTopLogprobsInner topLogprobsItem) { + if (this.topLogprobs == null) { + this.topLogprobs = new ArrayList<>(); + } + this.topLogprobs.add(topLogprobsItem); + return this; + } + + /** + * List of the most likely tokens and their log probability, at this token position. In rare + * cases, there may be fewer than the number of requested `top_logprobs`. + * + * @return topLogprobs The topLogprobs of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nonnull + public List getTopLogprobs() { + return topLogprobs; + } + + /** + * Set the topLogprobs of this {@link ChatCompletionTokenLogprob} instance. + * + * @param topLogprobs List of the most likely tokens and their log probability, at this token + * position. In rare cases, there may be fewer than the number of requested + * `top_logprobs`. + */ + public void setTopLogprobs( + @Nullable final List topLogprobs) { + this.topLogprobs = topLogprobs; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionTokenLogprob}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionTokenLogprob} + * instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionTokenLogprob has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ChatCompletionTokenLogprob} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (token != null) declaredFields.put("token", token); + if (logprob != null) declaredFields.put("logprob", logprob); + if (bytes != null) declaredFields.put("bytes", bytes); + if (topLogprobs != null) declaredFields.put("topLogprobs", topLogprobs); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionTokenLogprob} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionTokenLogprob chatCompletionTokenLogprob = (ChatCompletionTokenLogprob) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionTokenLogprob.cloudSdkCustomFields) + && Objects.equals(this.token, chatCompletionTokenLogprob.token) + && Objects.equals(this.logprob, chatCompletionTokenLogprob.logprob) + && Objects.equals(this.bytes, chatCompletionTokenLogprob.bytes) + && Objects.equals(this.topLogprobs, chatCompletionTokenLogprob.topLogprobs); + } + + @Override + public int hashCode() { + return Objects.hash(token, logprob, bytes, topLogprobs, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionTokenLogprob {\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" logprob: ").append(toIndentedString(logprob)).append("\n"); + sb.append(" bytes: ").append(toIndentedString(bytes)).append("\n"); + sb.append(" topLogprobs: ").append(toIndentedString(topLogprobs)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link + * ChatCompletionTokenLogprob} instance with all required arguments. + */ + public static Builder create() { + return (token) -> (logprob) -> new ChatCompletionTokenLogprob().token(token).logprob(logprob); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the token of this {@link ChatCompletionTokenLogprob} instance. + * + * @param token The token. + * @return The ChatCompletionTokenLogprob builder. + */ + Builder1 token(@Nonnull final String token); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the logprob of this {@link ChatCompletionTokenLogprob} instance. + * + * @param logprob The log probability of this token. + * @return The ChatCompletionTokenLogprob instance. + */ + ChatCompletionTokenLogprob logprob(@Nonnull final Float logprob); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprobTopLogprobsInner.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprobTopLogprobsInner.java new file mode 100644 index 000000000..ad7c7bf0a --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprobTopLogprobsInner.java @@ -0,0 +1,301 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ChatCompletionTokenLogprobTopLogprobsInner */ +// CHECKSTYLE:OFF +public class ChatCompletionTokenLogprobTopLogprobsInner +// CHECKSTYLE:ON +{ + @JsonProperty("token") + private String token; + + @JsonProperty("logprob") + private Float logprob; + + @JsonProperty("bytes") + private List bytes = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ChatCompletionTokenLogprobTopLogprobsInner. */ + protected ChatCompletionTokenLogprobTopLogprobsInner() {} + + /** + * Set the token of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance and return + * the same instance. + * + * @param token The token. + * @return The same instance of this {@link ChatCompletionTokenLogprobTopLogprobsInner} class + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner token(@Nonnull final String token) { + this.token = token; + return this; + } + + /** + * The token. + * + * @return token The token of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + */ + @Nonnull + public String getToken() { + return token; + } + + /** + * Set the token of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param token The token. + */ + public void setToken(@Nonnull final String token) { + this.token = token; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance and return + * the same instance. + * + * @param logprob The log probability of this token. + * @return The same instance of this {@link ChatCompletionTokenLogprobTopLogprobsInner} class + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner logprob(@Nonnull final Float logprob) { + this.logprob = logprob; + return this; + } + + /** + * The log probability of this token. + * + * @return logprob The logprob of this {@link ChatCompletionTokenLogprobTopLogprobsInner} + * instance. + */ + @Nonnull + public Float getLogprob() { + return logprob; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param logprob The log probability of this token. + */ + public void setLogprob(@Nonnull final Float logprob) { + this.logprob = logprob; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance and return + * the same instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are multi-byte. + * @return The same instance of this {@link ChatCompletionTokenLogprobTopLogprobsInner} class + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner bytes(@Nullable final List bytes) { + this.bytes = bytes; + return this; + } + + /** + * Add one bytes instance to this {@link ChatCompletionTokenLogprobTopLogprobsInner}. + * + * @param bytesItem The bytes that should be added + * @return The same instance of type {@link ChatCompletionTokenLogprobTopLogprobsInner} + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner addBytesItem(@Nonnull final Integer bytesItem) { + if (this.bytes == null) { + this.bytes = new ArrayList<>(); + } + this.bytes.add(bytesItem); + return this; + } + + /** + * A list of integers representing the UTF-8 bytes representation of the token. Useful in + * instances where characters are multi-byte. + * + * @return bytes The bytes of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + */ + @Nonnull + public List getBytes() { + return bytes; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are multi-byte. + */ + public void setBytes(@Nullable final List bytes) { + this.bytes = bytes; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionTokenLogprobTopLogprobsInner}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionTokenLogprobTopLogprobsInner has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ChatCompletionTokenLogprobTopLogprobsInner} + * instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (token != null) declaredFields.put("token", token); + if (logprob != null) declaredFields.put("logprob", logprob); + if (bytes != null) declaredFields.put("bytes", bytes); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionTokenLogprobTopLogprobsInner} + * instance. If the map previously contained a mapping for the key, the old value is replaced by + * the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionTokenLogprobTopLogprobsInner chatCompletionTokenLogprobTopLogprobsInner = + (ChatCompletionTokenLogprobTopLogprobsInner) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionTokenLogprobTopLogprobsInner.cloudSdkCustomFields) + && Objects.equals(this.token, chatCompletionTokenLogprobTopLogprobsInner.token) + && Objects.equals(this.logprob, chatCompletionTokenLogprobTopLogprobsInner.logprob) + && Objects.equals(this.bytes, chatCompletionTokenLogprobTopLogprobsInner.bytes); + } + + @Override + public int hashCode() { + return Objects.hash(token, logprob, bytes, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionTokenLogprobTopLogprobsInner {\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" logprob: ").append(toIndentedString(logprob)).append("\n"); + sb.append(" bytes: ").append(toIndentedString(bytes)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link + * ChatCompletionTokenLogprobTopLogprobsInner} instance with all required arguments. + */ + public static Builder create() { + return (token) -> + (logprob) -> new ChatCompletionTokenLogprobTopLogprobsInner().token(token).logprob(logprob); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the token of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param token The token. + * @return The ChatCompletionTokenLogprobTopLogprobsInner builder. + */ + Builder1 token(@Nonnull final String token); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the logprob of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param logprob The log probability of this token. + * @return The ChatCompletionTokenLogprobTopLogprobsInner instance. + */ + ChatCompletionTokenLogprobTopLogprobsInner logprob(@Nonnull final Float logprob); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChoiceLogprobs.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChoiceLogprobs.java new file mode 100644 index 000000000..363d74e53 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChoiceLogprobs.java @@ -0,0 +1,239 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Log probabilities for the choice. */ +// CHECKSTYLE:OFF +public class ChoiceLogprobs +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private List content = new ArrayList<>(); + + @JsonProperty("refusal") + private List refusal = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ChoiceLogprobs. */ + protected ChoiceLogprobs() {} + + /** + * Set the content of this {@link ChoiceLogprobs} instance and return the same instance. + * + * @param content A list of message content tokens with log probability information. + * @return The same instance of this {@link ChoiceLogprobs} class + */ + @Nonnull + public ChoiceLogprobs content(@Nullable final List content) { + this.content = content; + return this; + } + + /** + * Add one content instance to this {@link ChoiceLogprobs}. + * + * @param contentItem The content that should be added + * @return The same instance of type {@link ChoiceLogprobs} + */ + @Nonnull + public ChoiceLogprobs addContentItem(@Nonnull final ChatCompletionTokenLogprob contentItem) { + if (this.content == null) { + this.content = new ArrayList<>(); + } + this.content.add(contentItem); + return this; + } + + /** + * A list of message content tokens with log probability information. + * + * @return content The content of this {@link ChoiceLogprobs} instance. + */ + @Nonnull + public List getContent() { + return content; + } + + /** + * Set the content of this {@link ChoiceLogprobs} instance. + * + * @param content A list of message content tokens with log probability information. + */ + public void setContent(@Nullable final List content) { + this.content = content; + } + + /** + * Set the refusal of this {@link ChoiceLogprobs} instance and return the same instance. + * + * @param refusal A list of message refusal tokens with log probability information. + * @return The same instance of this {@link ChoiceLogprobs} class + */ + @Nonnull + public ChoiceLogprobs refusal(@Nullable final List refusal) { + this.refusal = refusal; + return this; + } + + /** + * Add one refusal instance to this {@link ChoiceLogprobs}. + * + * @param refusalItem The refusal that should be added + * @return The same instance of type {@link ChoiceLogprobs} + */ + @Nonnull + public ChoiceLogprobs addRefusalItem(@Nonnull final ChatCompletionTokenLogprob refusalItem) { + if (this.refusal == null) { + this.refusal = new ArrayList<>(); + } + this.refusal.add(refusalItem); + return this; + } + + /** + * A list of message refusal tokens with log probability information. + * + * @return refusal The refusal of this {@link ChoiceLogprobs} instance. + */ + @Nonnull + public List getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link ChoiceLogprobs} instance. + * + * @param refusal A list of message refusal tokens with log probability information. + */ + public void setRefusal(@Nullable final List refusal) { + this.refusal = refusal; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChoiceLogprobs}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChoiceLogprobs} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("ChoiceLogprobs has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ChoiceLogprobs} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (content != null) declaredFields.put("content", content); + if (refusal != null) declaredFields.put("refusal", refusal); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link ChoiceLogprobs} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChoiceLogprobs choiceLogprobs = (ChoiceLogprobs) o; + return Objects.equals(this.cloudSdkCustomFields, choiceLogprobs.cloudSdkCustomFields) + && Objects.equals(this.content, choiceLogprobs.content) + && Objects.equals(this.refusal, choiceLogprobs.refusal); + } + + @Override + public int hashCode() { + return Objects.hash(content, refusal, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChoiceLogprobs {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link ChoiceLogprobs} instance. No arguments are required. */ + public static ChoiceLogprobs create() { + return new ChoiceLogprobs(); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseStreaming.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseStreaming.java index 4c0b23d24..f68c93146 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseStreaming.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseStreaming.java @@ -32,7 +32,7 @@ public class CompletionPostResponseStreaming private String requestId; @JsonProperty("module_results") - private ModuleResults moduleResults; + private ModuleResultsStreaming moduleResults; @JsonProperty("orchestration_result") private LLMModuleResultStreaming orchestrationResult; @@ -84,7 +84,7 @@ public void setRequestId(@Nonnull final String requestId) { */ @Nonnull public CompletionPostResponseStreaming moduleResults( - @Nullable final ModuleResults moduleResults) { + @Nullable final ModuleResultsStreaming moduleResults) { this.moduleResults = moduleResults; return this; } @@ -96,7 +96,7 @@ public CompletionPostResponseStreaming moduleResults( * instance. */ @Nonnull - public ModuleResults getModuleResults() { + public ModuleResultsStreaming getModuleResults() { return moduleResults; } @@ -105,7 +105,7 @@ public ModuleResults getModuleResults() { * * @param moduleResults The moduleResults of this {@link CompletionPostResponseStreaming} */ - public void setModuleResults(@Nullable final ModuleResults moduleResults) { + public void setModuleResults(@Nullable final ModuleResultsStreaming moduleResults) { this.moduleResults = moduleResults; } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java new file mode 100644 index 000000000..a7487b6de --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java @@ -0,0 +1,237 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** DPICustomEntity */ +// CHECKSTYLE:OFF +public class DPICustomEntity implements DPIEntityConfig +// CHECKSTYLE:ON +{ + @JsonProperty("regex") + private String regex; + + @JsonProperty("replacement_strategy") + private DPIMethodConstant replacementStrategy; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for DPICustomEntity. */ + protected DPICustomEntity() {} + + /** + * Set the regex of this {@link DPICustomEntity} instance and return the same instance. + * + * @param regex Regular expression to match the entity + * @return The same instance of this {@link DPICustomEntity} class + */ + @Nonnull + public DPICustomEntity regex(@Nonnull final String regex) { + this.regex = regex; + return this; + } + + /** + * Regular expression to match the entity + * + * @return regex The regex of this {@link DPICustomEntity} instance. + */ + @Nonnull + public String getRegex() { + return regex; + } + + /** + * Set the regex of this {@link DPICustomEntity} instance. + * + * @param regex Regular expression to match the entity + */ + public void setRegex(@Nonnull final String regex) { + this.regex = regex; + } + + /** + * Set the replacementStrategy of this {@link DPICustomEntity} instance and return the same + * instance. + * + * @param replacementStrategy The replacementStrategy of this {@link DPICustomEntity} + * @return The same instance of this {@link DPICustomEntity} class + */ + @Nonnull + public DPICustomEntity replacementStrategy(@Nonnull final DPIMethodConstant replacementStrategy) { + this.replacementStrategy = replacementStrategy; + return this; + } + + /** + * Get replacementStrategy + * + * @return replacementStrategy The replacementStrategy of this {@link DPICustomEntity} instance. + */ + @Nonnull + public DPIMethodConstant getReplacementStrategy() { + return replacementStrategy; + } + + /** + * Set the replacementStrategy of this {@link DPICustomEntity} instance. + * + * @param replacementStrategy The replacementStrategy of this {@link DPICustomEntity} + */ + public void setReplacementStrategy(@Nonnull final DPIMethodConstant replacementStrategy) { + this.replacementStrategy = replacementStrategy; + } + + /** + * Get the names of the unrecognizable properties of the {@link DPICustomEntity}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link DPICustomEntity} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("DPICustomEntity has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link DPICustomEntity} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (regex != null) declaredFields.put("regex", regex); + if (replacementStrategy != null) declaredFields.put("replacementStrategy", replacementStrategy); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link DPICustomEntity} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final DPICustomEntity dpICustomEntity = (DPICustomEntity) o; + return Objects.equals(this.cloudSdkCustomFields, dpICustomEntity.cloudSdkCustomFields) + && Objects.equals(this.regex, dpICustomEntity.regex) + && Objects.equals(this.replacementStrategy, dpICustomEntity.replacementStrategy); + } + + @Override + public int hashCode() { + return Objects.hash(regex, replacementStrategy, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DPICustomEntity {\n"); + sb.append(" regex: ").append(toIndentedString(regex)).append("\n"); + sb.append(" replacementStrategy: ") + .append(toIndentedString(replacementStrategy)) + .append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link DPICustomEntity} + * instance with all required arguments. + */ + public static Builder create() { + return (regex) -> + (replacementStrategy) -> + new DPICustomEntity().regex(regex).replacementStrategy(replacementStrategy); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the regex of this {@link DPICustomEntity} instance. + * + * @param regex Regular expression to match the entity + * @return The DPICustomEntity builder. + */ + Builder1 regex(@Nonnull final String regex); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the replacementStrategy of this {@link DPICustomEntity} instance. + * + * @param replacementStrategy The replacementStrategy of this {@link DPICustomEntity} + * @return The DPICustomEntity instance. + */ + DPICustomEntity replacementStrategy(@Nonnull final DPIMethodConstant replacementStrategy); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntities.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntities.java index 54e5f99ce..e0d17c434 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntities.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntities.java @@ -59,6 +59,8 @@ public enum DPIEntities { PRONOUNS_GENDER("profile-pronouns-gender"), + ETHNICITY("profile-ethnicity"), + GENDER("profile-gender"), SEXUAL_ORIENTATION("profile-sexual-orientation"), diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java index 20dfca1f8..5448e04cb 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java @@ -11,174 +11,13 @@ package com.sap.ai.sdk.orchestration.model; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; /** DPIEntityConfig */ -// CHECKSTYLE:OFF -public class DPIEntityConfig -// CHECKSTYLE:ON -{ - @JsonProperty("type") - private DPIEntities type; - - @JsonAnySetter @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** Default constructor for DPIEntityConfig. */ - protected DPIEntityConfig() {} - - /** - * Set the type of this {@link DPIEntityConfig} instance and return the same instance. - * - * @param type Type of entity to be masked - * @return The same instance of this {@link DPIEntityConfig} class - */ - @Nonnull - public DPIEntityConfig type(@Nonnull final DPIEntities type) { - this.type = type; - return this; - } - - /** - * Type of entity to be masked - * - * @return type The type of this {@link DPIEntityConfig} instance. - */ - @Nonnull - public DPIEntities getType() { - return type; - } - - /** - * Set the type of this {@link DPIEntityConfig} instance. - * - * @param type Type of entity to be masked - */ - public void setType(@Nonnull final DPIEntities type) { - this.type = type; - } - - /** - * Get the names of the unrecognizable properties of the {@link DPIEntityConfig}. - * - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link DPIEntityConfig} instance. - * - * @deprecated Use {@link #toMap()} instead. - * @param name The name of the property - * @return The value of the property - * @throws NoSuchElementException If no property with the given name could be found. - */ - @Nullable - @Deprecated - public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { - if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException("DPIEntityConfig has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Get the value of all properties of this {@link DPIEntityConfig} instance including unrecognized - * properties. - * - * @return The map of all properties - */ - @JsonIgnore - @Nonnull - public Map toMap() { - final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); - if (type != null) declaredFields.put("type", type); - return declaredFields; - } - - /** - * Set an unrecognizable property of this {@link DPIEntityConfig} instance. If the map previously - * contained a mapping for the key, the old value is replaced by the specified value. - * - * @param customFieldName The name of the property - * @param customFieldValue The value of the property - */ - @JsonIgnore - public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { - cloudSdkCustomFields.put(customFieldName, customFieldValue); - } - - @Override - public boolean equals(@Nullable final java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final DPIEntityConfig dpIEntityConfig = (DPIEntityConfig) o; - return Objects.equals(this.cloudSdkCustomFields, dpIEntityConfig.cloudSdkCustomFields) - && Objects.equals(this.type, dpIEntityConfig.type); - } - - @Override - public int hashCode() { - return Objects.hash(type, cloudSdkCustomFields); - } - - @Override - @Nonnull - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class DPIEntityConfig {\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - cloudSdkCustomFields.forEach( - (k, v) -> - sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Create a type-safe, fluent-api builder object to construct a new {@link DPIEntityConfig} - * instance with all required arguments. - */ - public static Builder create() { - return (type) -> new DPIEntityConfig().type(type); - } - - /** Builder helper class. */ - public interface Builder { - /** - * Set the type of this {@link DPIEntityConfig} instance. - * - * @param type Type of entity to be masked - * @return The DPIEntityConfig instance. - */ - DPIEntityConfig type(@Nonnull final DPIEntities type); - } -} +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = DPICustomEntity.class), + @JsonSubTypes.Type(value = DPIStandardEntity.class), +}) +public interface DPIEntityConfig {} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodConstant.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodConstant.java new file mode 100644 index 000000000..9a1441942 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodConstant.java @@ -0,0 +1,288 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Replaces the entity with the specified value followed by an incrementing number */ +// CHECKSTYLE:OFF +public class DPIMethodConstant implements DPIStandardEntityReplacementStrategy +// CHECKSTYLE:ON +{ + /** Gets or Sets method */ + public enum MethodEnum { + /** The CONSTANT option of this DPIMethodConstant */ + CONSTANT("constant"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this DPIMethodConstant */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + MethodEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type DPIMethodConstant + */ + @JsonCreator + @Nonnull + public static MethodEnum fromValue(@Nonnull final String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("method") + private MethodEnum method; + + @JsonProperty("value") + private String value; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for DPIMethodConstant. */ + protected DPIMethodConstant() {} + + /** + * Set the method of this {@link DPIMethodConstant} instance and return the same instance. + * + * @param method The method of this {@link DPIMethodConstant} + * @return The same instance of this {@link DPIMethodConstant} class + */ + @Nonnull + public DPIMethodConstant method(@Nonnull final MethodEnum method) { + this.method = method; + return this; + } + + /** + * Get method + * + * @return method The method of this {@link DPIMethodConstant} instance. + */ + @Nonnull + public MethodEnum getMethod() { + return method; + } + + /** + * Set the method of this {@link DPIMethodConstant} instance. + * + * @param method The method of this {@link DPIMethodConstant} + */ + public void setMethod(@Nonnull final MethodEnum method) { + this.method = method; + } + + /** + * Set the value of this {@link DPIMethodConstant} instance and return the same instance. + * + * @param value Value to be used for replacement + * @return The same instance of this {@link DPIMethodConstant} class + */ + @Nonnull + public DPIMethodConstant value(@Nonnull final String value) { + this.value = value; + return this; + } + + /** + * Value to be used for replacement + * + * @return value The value of this {@link DPIMethodConstant} instance. + */ + @Nonnull + public String getValue() { + return value; + } + + /** + * Set the value of this {@link DPIMethodConstant} instance. + * + * @param value Value to be used for replacement + */ + public void setValue(@Nonnull final String value) { + this.value = value; + } + + /** + * Get the names of the unrecognizable properties of the {@link DPIMethodConstant}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link DPIMethodConstant} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("DPIMethodConstant has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link DPIMethodConstant} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (method != null) declaredFields.put("method", method); + if (value != null) declaredFields.put("value", value); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link DPIMethodConstant} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final DPIMethodConstant dpIMethodConstant = (DPIMethodConstant) o; + return Objects.equals(this.cloudSdkCustomFields, dpIMethodConstant.cloudSdkCustomFields) + && Objects.equals(this.method, dpIMethodConstant.method) + && Objects.equals(this.value, dpIMethodConstant.value); + } + + @Override + public int hashCode() { + return Objects.hash(method, value, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DPIMethodConstant {\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link DPIMethodConstant} + * instance with all required arguments. + */ + public static Builder create() { + return (method) -> (value) -> new DPIMethodConstant().method(method).value(value); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the method of this {@link DPIMethodConstant} instance. + * + * @param method The method of this {@link DPIMethodConstant} + * @return The DPIMethodConstant builder. + */ + Builder1 method(@Nonnull final MethodEnum method); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the value of this {@link DPIMethodConstant} instance. + * + * @param value Value to be used for replacement + * @return The DPIMethodConstant instance. + */ + DPIMethodConstant value(@Nonnull final String value); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodFabricatedData.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodFabricatedData.java new file mode 100644 index 000000000..fd98ad3ad --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodFabricatedData.java @@ -0,0 +1,241 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Replaces the entity with a randomly generated value appropriate to its type. */ +// CHECKSTYLE:OFF +public class DPIMethodFabricatedData implements DPIStandardEntityReplacementStrategy +// CHECKSTYLE:ON +{ + /** Gets or Sets method */ + public enum MethodEnum { + /** The FABRICATED_DATA option of this DPIMethodFabricatedData */ + FABRICATED_DATA("fabricated_data"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this DPIMethodFabricatedData */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + MethodEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type DPIMethodFabricatedData + */ + @JsonCreator + @Nonnull + public static MethodEnum fromValue(@Nonnull final String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("method") + private MethodEnum method; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for DPIMethodFabricatedData. */ + protected DPIMethodFabricatedData() {} + + /** + * Set the method of this {@link DPIMethodFabricatedData} instance and return the same instance. + * + * @param method The method of this {@link DPIMethodFabricatedData} + * @return The same instance of this {@link DPIMethodFabricatedData} class + */ + @Nonnull + public DPIMethodFabricatedData method(@Nonnull final MethodEnum method) { + this.method = method; + return this; + } + + /** + * Get method + * + * @return method The method of this {@link DPIMethodFabricatedData} instance. + */ + @Nonnull + public MethodEnum getMethod() { + return method; + } + + /** + * Set the method of this {@link DPIMethodFabricatedData} instance. + * + * @param method The method of this {@link DPIMethodFabricatedData} + */ + public void setMethod(@Nonnull final MethodEnum method) { + this.method = method; + } + + /** + * Get the names of the unrecognizable properties of the {@link DPIMethodFabricatedData}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link DPIMethodFabricatedData} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "DPIMethodFabricatedData has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link DPIMethodFabricatedData} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (method != null) declaredFields.put("method", method); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link DPIMethodFabricatedData} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final DPIMethodFabricatedData dpIMethodFabricatedData = (DPIMethodFabricatedData) o; + return Objects.equals(this.cloudSdkCustomFields, dpIMethodFabricatedData.cloudSdkCustomFields) + && Objects.equals(this.method, dpIMethodFabricatedData.method); + } + + @Override + public int hashCode() { + return Objects.hash(method, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DPIMethodFabricatedData {\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link + * DPIMethodFabricatedData} instance with all required arguments. + */ + public static Builder create() { + return (method) -> new DPIMethodFabricatedData().method(method); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the method of this {@link DPIMethodFabricatedData} instance. + * + * @param method The method of this {@link DPIMethodFabricatedData} + * @return The DPIMethodFabricatedData instance. + */ + DPIMethodFabricatedData method(@Nonnull final MethodEnum method); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntity.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntity.java new file mode 100644 index 000000000..2b93c0692 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntity.java @@ -0,0 +1,226 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** DPIStandardEntity */ +// CHECKSTYLE:OFF +public class DPIStandardEntity implements DPIEntityConfig +// CHECKSTYLE:ON +{ + @JsonProperty("type") + private DPIEntities type; + + @JsonProperty("replacement_strategy") + private DPIStandardEntityReplacementStrategy replacementStrategy; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for DPIStandardEntity. */ + protected DPIStandardEntity() {} + + /** + * Set the type of this {@link DPIStandardEntity} instance and return the same instance. + * + * @param type The type of this {@link DPIStandardEntity} + * @return The same instance of this {@link DPIStandardEntity} class + */ + @Nonnull + public DPIStandardEntity type(@Nonnull final DPIEntities type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type The type of this {@link DPIStandardEntity} instance. + */ + @Nonnull + public DPIEntities getType() { + return type; + } + + /** + * Set the type of this {@link DPIStandardEntity} instance. + * + * @param type The type of this {@link DPIStandardEntity} + */ + public void setType(@Nonnull final DPIEntities type) { + this.type = type; + } + + /** + * Set the replacementStrategy of this {@link DPIStandardEntity} instance and return the same + * instance. + * + * @param replacementStrategy The replacementStrategy of this {@link DPIStandardEntity} + * @return The same instance of this {@link DPIStandardEntity} class + */ + @Nonnull + public DPIStandardEntity replacementStrategy( + @Nullable final DPIStandardEntityReplacementStrategy replacementStrategy) { + this.replacementStrategy = replacementStrategy; + return this; + } + + /** + * Get replacementStrategy + * + * @return replacementStrategy The replacementStrategy of this {@link DPIStandardEntity} instance. + */ + @Nonnull + public DPIStandardEntityReplacementStrategy getReplacementStrategy() { + return replacementStrategy; + } + + /** + * Set the replacementStrategy of this {@link DPIStandardEntity} instance. + * + * @param replacementStrategy The replacementStrategy of this {@link DPIStandardEntity} + */ + public void setReplacementStrategy( + @Nullable final DPIStandardEntityReplacementStrategy replacementStrategy) { + this.replacementStrategy = replacementStrategy; + } + + /** + * Get the names of the unrecognizable properties of the {@link DPIStandardEntity}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link DPIStandardEntity} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("DPIStandardEntity has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link DPIStandardEntity} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (type != null) declaredFields.put("type", type); + if (replacementStrategy != null) declaredFields.put("replacementStrategy", replacementStrategy); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link DPIStandardEntity} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final DPIStandardEntity dpIStandardEntity = (DPIStandardEntity) o; + return Objects.equals(this.cloudSdkCustomFields, dpIStandardEntity.cloudSdkCustomFields) + && Objects.equals(this.type, dpIStandardEntity.type) + && Objects.equals(this.replacementStrategy, dpIStandardEntity.replacementStrategy); + } + + @Override + public int hashCode() { + return Objects.hash(type, replacementStrategy, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DPIStandardEntity {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" replacementStrategy: ") + .append(toIndentedString(replacementStrategy)) + .append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link DPIStandardEntity} + * instance with all required arguments. + */ + public static Builder create() { + return (type) -> new DPIStandardEntity().type(type); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the type of this {@link DPIStandardEntity} instance. + * + * @param type The type of this {@link DPIStandardEntity} + * @return The DPIStandardEntity instance. + */ + DPIStandardEntity type(@Nonnull final DPIEntities type); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntityReplacementStrategy.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntityReplacementStrategy.java new file mode 100644 index 000000000..930aeb75a --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntityReplacementStrategy.java @@ -0,0 +1,23 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** Replacement strategy to be used for the entity */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = DPIMethodConstant.class), + @JsonSubTypes.Type(value = DPIMethodFabricatedData.class), +}) +public interface DPIStandardEntityReplacementStrategy {} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Embedding.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Embedding.java new file mode 100644 index 000000000..712a16b91 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Embedding.java @@ -0,0 +1,52 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import java.math.BigDecimal; +import java.util.List; +import javax.annotation.Nonnull; + +/** Embedding */ +public interface Embedding { + /** Helper class to create a String that implements {@link Embedding}. */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) + implements Embedding {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerString create(@Nonnull final String val) { + return new InnerString(val); + } + + /** Helper class to create a list of BigDecimal that implements {@link Embedding}. */ + record InnerBigDecimals( + @com.fasterxml.jackson.annotation.JsonValue @Nonnull List values) + implements Embedding {} + + /** + * Creator to enable deserialization of a list of BigDecimal. + * + * @param val the value to use + * @return a new instance of {@link InnerBigDecimals}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerBigDecimals create(@Nonnull final List val) { + return new InnerBigDecimals(val); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingResult.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingResult.java new file mode 100644 index 000000000..12dfde521 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingResult.java @@ -0,0 +1,338 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Represents an embedding vector returned by embedding endpoint. */ +// CHECKSTYLE:OFF +public class EmbeddingResult +// CHECKSTYLE:ON +{ + /** The object type, which is always \"embedding\". */ + public enum ObjectEnum { + /** The EMBEDDING option of this EmbeddingResult */ + EMBEDDING("embedding"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this EmbeddingResult */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ObjectEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type EmbeddingResult + */ + @JsonCreator + @Nonnull + public static ObjectEnum fromValue(@Nonnull final String value) { + for (ObjectEnum b : ObjectEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("object") + private ObjectEnum _object; + + @JsonProperty("embedding") + private Embedding embedding; + + @JsonProperty("index") + private Integer index; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingResult. */ + protected EmbeddingResult() {} + + /** + * Set the _object of this {@link EmbeddingResult} instance and return the same instance. + * + * @param _object The object type, which is always \"embedding\". + * @return The same instance of this {@link EmbeddingResult} class + */ + @Nonnull + public EmbeddingResult _object(@Nonnull final ObjectEnum _object) { + this._object = _object; + return this; + } + + /** + * The object type, which is always \"embedding\". + * + * @return _object The _object of this {@link EmbeddingResult} instance. + */ + @Nonnull + public ObjectEnum getObject() { + return _object; + } + + /** + * Set the _object of this {@link EmbeddingResult} instance. + * + * @param _object The object type, which is always \"embedding\". + */ + public void setObject(@Nonnull final ObjectEnum _object) { + this._object = _object; + } + + /** + * Set the embedding of this {@link EmbeddingResult} instance and return the same instance. + * + * @param embedding The embedding of this {@link EmbeddingResult} + * @return The same instance of this {@link EmbeddingResult} class + */ + @Nonnull + public EmbeddingResult embedding(@Nonnull final Embedding embedding) { + this.embedding = embedding; + return this; + } + + /** + * Get embedding + * + * @return embedding The embedding of this {@link EmbeddingResult} instance. + */ + @Nonnull + public Embedding getEmbedding() { + return embedding; + } + + /** + * Set the embedding of this {@link EmbeddingResult} instance. + * + * @param embedding The embedding of this {@link EmbeddingResult} + */ + public void setEmbedding(@Nonnull final Embedding embedding) { + this.embedding = embedding; + } + + /** + * Set the index of this {@link EmbeddingResult} instance and return the same instance. + * + * @param index The index of the embedding in the list of embeddings. + * @return The same instance of this {@link EmbeddingResult} class + */ + @Nonnull + public EmbeddingResult index(@Nonnull final Integer index) { + this.index = index; + return this; + } + + /** + * The index of the embedding in the list of embeddings. + * + * @return index The index of this {@link EmbeddingResult} instance. + */ + @Nonnull + public Integer getIndex() { + return index; + } + + /** + * Set the index of this {@link EmbeddingResult} instance. + * + * @param index The index of the embedding in the list of embeddings. + */ + public void setIndex(@Nonnull final Integer index) { + this.index = index; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingResult}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingResult} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("EmbeddingResult has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingResult} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (_object != null) declaredFields.put("_object", _object); + if (embedding != null) declaredFields.put("embedding", embedding); + if (index != null) declaredFields.put("index", index); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingResult} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingResult embeddingResult = (EmbeddingResult) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingResult.cloudSdkCustomFields) + && Objects.equals(this._object, embeddingResult._object) + && Objects.equals(this.embedding, embeddingResult.embedding) + && Objects.equals(this.index, embeddingResult.index); + } + + @Override + public int hashCode() { + return Objects.hash(_object, embedding, index, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingResult {\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" embedding: ").append(toIndentedString(embedding)).append("\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingResult} + * instance with all required arguments. + */ + public static Builder create() { + return (_object) -> + (embedding) -> + (index) -> new EmbeddingResult()._object(_object).embedding(embedding).index(index); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the _object of this {@link EmbeddingResult} instance. + * + * @param _object The object type, which is always \"embedding\". + * @return The EmbeddingResult builder. + */ + Builder1 _object(@Nonnull final ObjectEnum _object); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the embedding of this {@link EmbeddingResult} instance. + * + * @param embedding The embedding of this {@link EmbeddingResult} + * @return The EmbeddingResult builder. + */ + Builder2 embedding(@Nonnull final Embedding embedding); + } + + /** Builder helper class. */ + public interface Builder2 { + /** + * Set the index of this {@link EmbeddingResult} instance. + * + * @param index The index of the embedding in the list of embeddings. + * @return The EmbeddingResult instance. + */ + EmbeddingResult index(@Nonnull final Integer index); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInput.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInput.java new file mode 100644 index 000000000..7a8007616 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInput.java @@ -0,0 +1,283 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsInput */ +// CHECKSTYLE:OFF +public class EmbeddingsInput +// CHECKSTYLE:ON +{ + @JsonProperty("text") + private EmbeddingsInputText text; + + /** Gets or Sets type */ + public enum TypeEnum { + /** The TEXT option of this EmbeddingsInput */ + TEXT("text"), + + /** The DOCUMENT option of this EmbeddingsInput */ + DOCUMENT("document"), + + /** The QUERY option of this EmbeddingsInput */ + QUERY("query"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this EmbeddingsInput */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type EmbeddingsInput + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsInput. */ + protected EmbeddingsInput() {} + + /** + * Set the text of this {@link EmbeddingsInput} instance and return the same instance. + * + * @param text The text of this {@link EmbeddingsInput} + * @return The same instance of this {@link EmbeddingsInput} class + */ + @Nonnull + public EmbeddingsInput text(@Nonnull final EmbeddingsInputText text) { + this.text = text; + return this; + } + + /** + * Get text + * + * @return text The text of this {@link EmbeddingsInput} instance. + */ + @Nonnull + public EmbeddingsInputText getText() { + return text; + } + + /** + * Set the text of this {@link EmbeddingsInput} instance. + * + * @param text The text of this {@link EmbeddingsInput} + */ + public void setText(@Nonnull final EmbeddingsInputText text) { + this.text = text; + } + + /** + * Set the type of this {@link EmbeddingsInput} instance and return the same instance. + * + * @param type The type of this {@link EmbeddingsInput} + * @return The same instance of this {@link EmbeddingsInput} class + */ + @Nonnull + public EmbeddingsInput type(@Nullable final TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type The type of this {@link EmbeddingsInput} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link EmbeddingsInput} instance. + * + * @param type The type of this {@link EmbeddingsInput} + */ + public void setType(@Nullable final TypeEnum type) { + this.type = type; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsInput}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsInput} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("EmbeddingsInput has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsInput} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (text != null) declaredFields.put("text", text); + if (type != null) declaredFields.put("type", type); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsInput} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsInput embeddingsInput = (EmbeddingsInput) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsInput.cloudSdkCustomFields) + && Objects.equals(this.text, embeddingsInput.text) + && Objects.equals(this.type, embeddingsInput.type); + } + + @Override + public int hashCode() { + return Objects.hash(text, type, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsInput {\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingsInput} + * instance with all required arguments. + */ + public static Builder create() { + return (text) -> new EmbeddingsInput().text(text); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the text of this {@link EmbeddingsInput} instance. + * + * @param text The text of this {@link EmbeddingsInput} + * @return The EmbeddingsInput instance. + */ + EmbeddingsInput text(@Nonnull final EmbeddingsInputText text); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInputText.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInputText.java new file mode 100644 index 000000000..3e726dfbd --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInputText.java @@ -0,0 +1,50 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import java.util.List; +import javax.annotation.Nonnull; + +/** Text input for which embeddings need to be generated */ +public interface EmbeddingsInputText { + /** Helper class to create a String that implements {@link EmbeddingsInputText}. */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) + implements EmbeddingsInputText {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerString create(@Nonnull final String val) { + return new InnerString(val); + } + + /** Helper class to create a list of String that implements {@link EmbeddingsInputText}. */ + record InnerStrings(@com.fasterxml.jackson.annotation.JsonValue @Nonnull List values) + implements EmbeddingsInputText {} + + /** + * Creator to enable deserialization of a list of String. + * + * @param val the value to use + * @return a new instance of {@link InnerStrings}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerStrings create(@Nonnull final List val) { + return new InnerStrings(val); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelConfig.java new file mode 100644 index 000000000..c246b72aa --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelConfig.java @@ -0,0 +1,185 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsModelConfig */ +// CHECKSTYLE:OFF +public class EmbeddingsModelConfig +// CHECKSTYLE:ON +{ + @JsonProperty("model") + private EmbeddingsModelDetails model; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsModelConfig. */ + protected EmbeddingsModelConfig() {} + + /** + * Set the model of this {@link EmbeddingsModelConfig} instance and return the same instance. + * + * @param model The model of this {@link EmbeddingsModelConfig} + * @return The same instance of this {@link EmbeddingsModelConfig} class + */ + @Nonnull + public EmbeddingsModelConfig model(@Nonnull final EmbeddingsModelDetails model) { + this.model = model; + return this; + } + + /** + * Get model + * + * @return model The model of this {@link EmbeddingsModelConfig} instance. + */ + @Nonnull + public EmbeddingsModelDetails getModel() { + return model; + } + + /** + * Set the model of this {@link EmbeddingsModelConfig} instance. + * + * @param model The model of this {@link EmbeddingsModelConfig} + */ + public void setModel(@Nonnull final EmbeddingsModelDetails model) { + this.model = model; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsModelConfig}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsModelConfig} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsModelConfig has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsModelConfig} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (model != null) declaredFields.put("model", model); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsModelConfig} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsModelConfig embeddingsModelConfig = (EmbeddingsModelConfig) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsModelConfig.cloudSdkCustomFields) + && Objects.equals(this.model, embeddingsModelConfig.model); + } + + @Override + public int hashCode() { + return Objects.hash(model, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsModelConfig {\n"); + sb.append(" model: ").append(toIndentedString(model)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingsModelConfig} + * instance with all required arguments. + */ + public static Builder create() { + return (model) -> new EmbeddingsModelConfig().model(model); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the model of this {@link EmbeddingsModelConfig} instance. + * + * @param model The model of this {@link EmbeddingsModelConfig} + * @return The EmbeddingsModelConfig instance. + */ + EmbeddingsModelConfig model(@Nonnull final EmbeddingsModelDetails model); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelDetails.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelDetails.java new file mode 100644 index 000000000..1907156c8 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelDetails.java @@ -0,0 +1,259 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsModelDetails */ +// CHECKSTYLE:OFF +public class EmbeddingsModelDetails +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("version") + private String version = "latest"; + + @JsonProperty("params") + private EmbeddingsModelParams params; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsModelDetails. */ + protected EmbeddingsModelDetails() {} + + /** + * Set the name of this {@link EmbeddingsModelDetails} instance and return the same instance. + * + * @param name The name of this {@link EmbeddingsModelDetails} + * @return The same instance of this {@link EmbeddingsModelDetails} class + */ + @Nonnull + public EmbeddingsModelDetails name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name The name of this {@link EmbeddingsModelDetails} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link EmbeddingsModelDetails} instance. + * + * @param name The name of this {@link EmbeddingsModelDetails} + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the version of this {@link EmbeddingsModelDetails} instance and return the same instance. + * + * @param version The version of this {@link EmbeddingsModelDetails} + * @return The same instance of this {@link EmbeddingsModelDetails} class + */ + @Nonnull + public EmbeddingsModelDetails version(@Nullable final String version) { + this.version = version; + return this; + } + + /** + * Get version + * + * @return version The version of this {@link EmbeddingsModelDetails} instance. + */ + @Nonnull + public String getVersion() { + return version; + } + + /** + * Set the version of this {@link EmbeddingsModelDetails} instance. + * + * @param version The version of this {@link EmbeddingsModelDetails} + */ + public void setVersion(@Nullable final String version) { + this.version = version; + } + + /** + * Set the params of this {@link EmbeddingsModelDetails} instance and return the same instance. + * + * @param params The params of this {@link EmbeddingsModelDetails} + * @return The same instance of this {@link EmbeddingsModelDetails} class + */ + @Nonnull + public EmbeddingsModelDetails params(@Nullable final EmbeddingsModelParams params) { + this.params = params; + return this; + } + + /** + * Get params + * + * @return params The params of this {@link EmbeddingsModelDetails} instance. + */ + @Nonnull + public EmbeddingsModelParams getParams() { + return params; + } + + /** + * Set the params of this {@link EmbeddingsModelDetails} instance. + * + * @param params The params of this {@link EmbeddingsModelDetails} + */ + public void setParams(@Nullable final EmbeddingsModelParams params) { + this.params = params; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsModelDetails}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsModelDetails} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsModelDetails has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsModelDetails} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (name != null) declaredFields.put("name", name); + if (version != null) declaredFields.put("version", version); + if (params != null) declaredFields.put("params", params); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsModelDetails} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsModelDetails embeddingsModelDetails = (EmbeddingsModelDetails) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsModelDetails.cloudSdkCustomFields) + && Objects.equals(this.name, embeddingsModelDetails.name) + && Objects.equals(this.version, embeddingsModelDetails.version) + && Objects.equals(this.params, embeddingsModelDetails.params); + } + + @Override + public int hashCode() { + return Objects.hash(name, version, params, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsModelDetails {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" params: ").append(toIndentedString(params)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingsModelDetails} + * instance with all required arguments. + */ + public static Builder create() { + return (name) -> new EmbeddingsModelDetails().name(name); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the name of this {@link EmbeddingsModelDetails} instance. + * + * @param name The name of this {@link EmbeddingsModelDetails} + * @return The EmbeddingsModelDetails instance. + */ + EmbeddingsModelDetails name(@Nonnull final String name); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelParams.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelParams.java new file mode 100644 index 000000000..9bc236003 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelParams.java @@ -0,0 +1,313 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Additional parameters for generating input's embeddings. Default values are used for + * mandatory parameters. + */ +// CHECKSTYLE:OFF +public class EmbeddingsModelParams +// CHECKSTYLE:ON +{ + @JsonProperty("dimensions") + private Integer dimensions; + + /** OpenAI's spec allows for 'float' and 'base64' encoding formats. */ + public enum EncodingFormatEnum { + /** The FLOAT option of this EmbeddingsModelParams */ + FLOAT("float"), + + /** The BASE64 option of this EmbeddingsModelParams */ + BASE64("base64"), + + /** The BINARY option of this EmbeddingsModelParams */ + BINARY("binary"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this EmbeddingsModelParams */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EncodingFormatEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type EmbeddingsModelParams + */ + @JsonCreator + @Nonnull + public static EncodingFormatEnum fromValue(@Nonnull final String value) { + for (EncodingFormatEnum b : EncodingFormatEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("encoding_format") + private EncodingFormatEnum encodingFormat; + + @JsonProperty("normalize") + private Boolean normalize; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsModelParams. */ + protected EmbeddingsModelParams() {} + + /** + * Set the dimensions of this {@link EmbeddingsModelParams} instance and return the same instance. + * + * @param dimensions The number of dimensions the resulting output embeddings should have. + * @return The same instance of this {@link EmbeddingsModelParams} class + */ + @Nonnull + public EmbeddingsModelParams dimensions(@Nullable final Integer dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * The number of dimensions the resulting output embeddings should have. + * + * @return dimensions The dimensions of this {@link EmbeddingsModelParams} instance. + */ + @Nonnull + public Integer getDimensions() { + return dimensions; + } + + /** + * Set the dimensions of this {@link EmbeddingsModelParams} instance. + * + * @param dimensions The number of dimensions the resulting output embeddings should have. + */ + public void setDimensions(@Nullable final Integer dimensions) { + this.dimensions = dimensions; + } + + /** + * Set the encodingFormat of this {@link EmbeddingsModelParams} instance and return the same + * instance. + * + * @param encodingFormat OpenAI's spec allows for 'float' and 'base64' + * encoding formats. + * @return The same instance of this {@link EmbeddingsModelParams} class + */ + @Nonnull + public EmbeddingsModelParams encodingFormat(@Nullable final EncodingFormatEnum encodingFormat) { + this.encodingFormat = encodingFormat; + return this; + } + + /** + * OpenAI's spec allows for 'float' and 'base64' encoding formats. + * + * @return encodingFormat The encodingFormat of this {@link EmbeddingsModelParams} instance. + */ + @Nonnull + public EncodingFormatEnum getEncodingFormat() { + return encodingFormat; + } + + /** + * Set the encodingFormat of this {@link EmbeddingsModelParams} instance. + * + * @param encodingFormat OpenAI's spec allows for 'float' and 'base64' + * encoding formats. + */ + public void setEncodingFormat(@Nullable final EncodingFormatEnum encodingFormat) { + this.encodingFormat = encodingFormat; + } + + /** + * Set the normalize of this {@link EmbeddingsModelParams} instance and return the same instance. + * + * @param normalize The normalize of this {@link EmbeddingsModelParams} + * @return The same instance of this {@link EmbeddingsModelParams} class + */ + @Nonnull + public EmbeddingsModelParams normalize(@Nullable final Boolean normalize) { + this.normalize = normalize; + return this; + } + + /** + * Get normalize + * + * @return normalize The normalize of this {@link EmbeddingsModelParams} instance. + */ + @Nonnull + public Boolean isNormalize() { + return normalize; + } + + /** + * Set the normalize of this {@link EmbeddingsModelParams} instance. + * + * @param normalize The normalize of this {@link EmbeddingsModelParams} + */ + public void setNormalize(@Nullable final Boolean normalize) { + this.normalize = normalize; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsModelParams}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsModelParams} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsModelParams has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsModelParams} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (dimensions != null) declaredFields.put("dimensions", dimensions); + if (encodingFormat != null) declaredFields.put("encodingFormat", encodingFormat); + if (normalize != null) declaredFields.put("normalize", normalize); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsModelParams} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsModelParams embeddingsModelParams = (EmbeddingsModelParams) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsModelParams.cloudSdkCustomFields) + && Objects.equals(this.dimensions, embeddingsModelParams.dimensions) + && Objects.equals(this.encodingFormat, embeddingsModelParams.encodingFormat) + && Objects.equals(this.normalize, embeddingsModelParams.normalize); + } + + @Override + public int hashCode() { + return Objects.hash(dimensions, encodingFormat, normalize, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsModelParams {\n"); + sb.append(" dimensions: ").append(toIndentedString(dimensions)).append("\n"); + sb.append(" encodingFormat: ").append(toIndentedString(encodingFormat)).append("\n"); + sb.append(" normalize: ").append(toIndentedString(normalize)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link EmbeddingsModelParams} instance. No arguments are required. */ + public static EmbeddingsModelParams create() { + return new EmbeddingsModelParams(); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModuleConfigs.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModuleConfigs.java new file mode 100644 index 000000000..2de5063ab --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModuleConfigs.java @@ -0,0 +1,223 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsModuleConfigs */ +// CHECKSTYLE:OFF +public class EmbeddingsModuleConfigs +// CHECKSTYLE:ON +{ + @JsonProperty("embeddings") + private EmbeddingsModelConfig embeddings; + + @JsonProperty("masking") + private MaskingModuleConfig masking; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsModuleConfigs. */ + protected EmbeddingsModuleConfigs() {} + + /** + * Set the embeddings of this {@link EmbeddingsModuleConfigs} instance and return the same + * instance. + * + * @param embeddings The embeddings of this {@link EmbeddingsModuleConfigs} + * @return The same instance of this {@link EmbeddingsModuleConfigs} class + */ + @Nonnull + public EmbeddingsModuleConfigs embeddings(@Nonnull final EmbeddingsModelConfig embeddings) { + this.embeddings = embeddings; + return this; + } + + /** + * Get embeddings + * + * @return embeddings The embeddings of this {@link EmbeddingsModuleConfigs} instance. + */ + @Nonnull + public EmbeddingsModelConfig getEmbeddings() { + return embeddings; + } + + /** + * Set the embeddings of this {@link EmbeddingsModuleConfigs} instance. + * + * @param embeddings The embeddings of this {@link EmbeddingsModuleConfigs} + */ + public void setEmbeddings(@Nonnull final EmbeddingsModelConfig embeddings) { + this.embeddings = embeddings; + } + + /** + * Set the masking of this {@link EmbeddingsModuleConfigs} instance and return the same instance. + * + * @param masking The masking of this {@link EmbeddingsModuleConfigs} + * @return The same instance of this {@link EmbeddingsModuleConfigs} class + */ + @Nonnull + public EmbeddingsModuleConfigs masking(@Nullable final MaskingModuleConfig masking) { + this.masking = masking; + return this; + } + + /** + * Get masking + * + * @return masking The masking of this {@link EmbeddingsModuleConfigs} instance. + */ + @Nonnull + public MaskingModuleConfig getMasking() { + return masking; + } + + /** + * Set the masking of this {@link EmbeddingsModuleConfigs} instance. + * + * @param masking The masking of this {@link EmbeddingsModuleConfigs} + */ + public void setMasking(@Nullable final MaskingModuleConfig masking) { + this.masking = masking; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsModuleConfigs}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsModuleConfigs} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsModuleConfigs has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsModuleConfigs} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (embeddings != null) declaredFields.put("embeddings", embeddings); + if (masking != null) declaredFields.put("masking", masking); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsModuleConfigs} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsModuleConfigs embeddingsModuleConfigs = (EmbeddingsModuleConfigs) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsModuleConfigs.cloudSdkCustomFields) + && Objects.equals(this.embeddings, embeddingsModuleConfigs.embeddings) + && Objects.equals(this.masking, embeddingsModuleConfigs.masking); + } + + @Override + public int hashCode() { + return Objects.hash(embeddings, masking, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsModuleConfigs {\n"); + sb.append(" embeddings: ").append(toIndentedString(embeddings)).append("\n"); + sb.append(" masking: ").append(toIndentedString(masking)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link + * EmbeddingsModuleConfigs} instance with all required arguments. + */ + public static Builder create() { + return (embeddings) -> new EmbeddingsModuleConfigs().embeddings(embeddings); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the embeddings of this {@link EmbeddingsModuleConfigs} instance. + * + * @param embeddings The embeddings of this {@link EmbeddingsModuleConfigs} + * @return The EmbeddingsModuleConfigs instance. + */ + EmbeddingsModuleConfigs embeddings(@Nonnull final EmbeddingsModelConfig embeddings); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsOrchestrationConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsOrchestrationConfig.java new file mode 100644 index 000000000..ca2d26b1d --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsOrchestrationConfig.java @@ -0,0 +1,190 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsOrchestrationConfig */ +// CHECKSTYLE:OFF +public class EmbeddingsOrchestrationConfig +// CHECKSTYLE:ON +{ + @JsonProperty("modules") + private EmbeddingsModuleConfigs modules; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsOrchestrationConfig. */ + protected EmbeddingsOrchestrationConfig() {} + + /** + * Set the modules of this {@link EmbeddingsOrchestrationConfig} instance and return the same + * instance. + * + * @param modules The modules of this {@link EmbeddingsOrchestrationConfig} + * @return The same instance of this {@link EmbeddingsOrchestrationConfig} class + */ + @Nonnull + public EmbeddingsOrchestrationConfig modules(@Nonnull final EmbeddingsModuleConfigs modules) { + this.modules = modules; + return this; + } + + /** + * Get modules + * + * @return modules The modules of this {@link EmbeddingsOrchestrationConfig} instance. + */ + @Nonnull + public EmbeddingsModuleConfigs getModules() { + return modules; + } + + /** + * Set the modules of this {@link EmbeddingsOrchestrationConfig} instance. + * + * @param modules The modules of this {@link EmbeddingsOrchestrationConfig} + */ + public void setModules(@Nonnull final EmbeddingsModuleConfigs modules) { + this.modules = modules; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsOrchestrationConfig}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsOrchestrationConfig} + * instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsOrchestrationConfig has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsOrchestrationConfig} instance + * including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (modules != null) declaredFields.put("modules", modules); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsOrchestrationConfig} instance. If the + * map previously contained a mapping for the key, the old value is replaced by the specified + * value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsOrchestrationConfig embeddingsOrchestrationConfig = + (EmbeddingsOrchestrationConfig) o; + return Objects.equals( + this.cloudSdkCustomFields, embeddingsOrchestrationConfig.cloudSdkCustomFields) + && Objects.equals(this.modules, embeddingsOrchestrationConfig.modules); + } + + @Override + public int hashCode() { + return Objects.hash(modules, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsOrchestrationConfig {\n"); + sb.append(" modules: ").append(toIndentedString(modules)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link + * EmbeddingsOrchestrationConfig} instance with all required arguments. + */ + public static Builder create() { + return (modules) -> new EmbeddingsOrchestrationConfig().modules(modules); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the modules of this {@link EmbeddingsOrchestrationConfig} instance. + * + * @param modules The modules of this {@link EmbeddingsOrchestrationConfig} + * @return The EmbeddingsOrchestrationConfig instance. + */ + EmbeddingsOrchestrationConfig modules(@Nonnull final EmbeddingsModuleConfigs modules); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostRequest.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostRequest.java new file mode 100644 index 000000000..b8e4c9480 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostRequest.java @@ -0,0 +1,233 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsPostRequest */ +// CHECKSTYLE:OFF +public class EmbeddingsPostRequest +// CHECKSTYLE:ON +{ + @JsonProperty("config") + private EmbeddingsOrchestrationConfig config; + + @JsonProperty("input") + private EmbeddingsInput input; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsPostRequest. */ + protected EmbeddingsPostRequest() {} + + /** + * Set the config of this {@link EmbeddingsPostRequest} instance and return the same instance. + * + * @param config The config of this {@link EmbeddingsPostRequest} + * @return The same instance of this {@link EmbeddingsPostRequest} class + */ + @Nonnull + public EmbeddingsPostRequest config(@Nonnull final EmbeddingsOrchestrationConfig config) { + this.config = config; + return this; + } + + /** + * Get config + * + * @return config The config of this {@link EmbeddingsPostRequest} instance. + */ + @Nonnull + public EmbeddingsOrchestrationConfig getConfig() { + return config; + } + + /** + * Set the config of this {@link EmbeddingsPostRequest} instance. + * + * @param config The config of this {@link EmbeddingsPostRequest} + */ + public void setConfig(@Nonnull final EmbeddingsOrchestrationConfig config) { + this.config = config; + } + + /** + * Set the input of this {@link EmbeddingsPostRequest} instance and return the same instance. + * + * @param input The input of this {@link EmbeddingsPostRequest} + * @return The same instance of this {@link EmbeddingsPostRequest} class + */ + @Nonnull + public EmbeddingsPostRequest input(@Nonnull final EmbeddingsInput input) { + this.input = input; + return this; + } + + /** + * Get input + * + * @return input The input of this {@link EmbeddingsPostRequest} instance. + */ + @Nonnull + public EmbeddingsInput getInput() { + return input; + } + + /** + * Set the input of this {@link EmbeddingsPostRequest} instance. + * + * @param input The input of this {@link EmbeddingsPostRequest} + */ + public void setInput(@Nonnull final EmbeddingsInput input) { + this.input = input; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsPostRequest}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsPostRequest} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsPostRequest has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsPostRequest} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (config != null) declaredFields.put("config", config); + if (input != null) declaredFields.put("input", input); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsPostRequest} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsPostRequest embeddingsPostRequest = (EmbeddingsPostRequest) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsPostRequest.cloudSdkCustomFields) + && Objects.equals(this.config, embeddingsPostRequest.config) + && Objects.equals(this.input, embeddingsPostRequest.input); + } + + @Override + public int hashCode() { + return Objects.hash(config, input, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsPostRequest {\n"); + sb.append(" config: ").append(toIndentedString(config)).append("\n"); + sb.append(" input: ").append(toIndentedString(input)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingsPostRequest} + * instance with all required arguments. + */ + public static Builder create() { + return (config) -> (input) -> new EmbeddingsPostRequest().config(config).input(input); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the config of this {@link EmbeddingsPostRequest} instance. + * + * @param config The config of this {@link EmbeddingsPostRequest} + * @return The EmbeddingsPostRequest builder. + */ + Builder1 config(@Nonnull final EmbeddingsOrchestrationConfig config); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the input of this {@link EmbeddingsPostRequest} instance. + * + * @param input The input of this {@link EmbeddingsPostRequest} + * @return The EmbeddingsPostRequest instance. + */ + EmbeddingsPostRequest input(@Nonnull final EmbeddingsInput input); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostResponse.java new file mode 100644 index 000000000..16dba27d2 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostResponse.java @@ -0,0 +1,265 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsPostResponse */ +// CHECKSTYLE:OFF +public class EmbeddingsPostResponse +// CHECKSTYLE:ON +{ + @JsonProperty("request_id") + private String requestId; + + @JsonProperty("intermediate_results") + private ModuleResultsBase intermediateResults; + + @JsonProperty("final_result") + private EmbeddingsResponse finalResult; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsPostResponse. */ + protected EmbeddingsPostResponse() {} + + /** + * Set the requestId of this {@link EmbeddingsPostResponse} instance and return the same instance. + * + * @param requestId The requestId of this {@link EmbeddingsPostResponse} + * @return The same instance of this {@link EmbeddingsPostResponse} class + */ + @Nonnull + public EmbeddingsPostResponse requestId(@Nonnull final String requestId) { + this.requestId = requestId; + return this; + } + + /** + * Get requestId + * + * @return requestId The requestId of this {@link EmbeddingsPostResponse} instance. + */ + @Nonnull + public String getRequestId() { + return requestId; + } + + /** + * Set the requestId of this {@link EmbeddingsPostResponse} instance. + * + * @param requestId The requestId of this {@link EmbeddingsPostResponse} + */ + public void setRequestId(@Nonnull final String requestId) { + this.requestId = requestId; + } + + /** + * Set the intermediateResults of this {@link EmbeddingsPostResponse} instance and return the same + * instance. + * + * @param intermediateResults The intermediateResults of this {@link EmbeddingsPostResponse} + * @return The same instance of this {@link EmbeddingsPostResponse} class + */ + @Nonnull + public EmbeddingsPostResponse intermediateResults( + @Nullable final ModuleResultsBase intermediateResults) { + this.intermediateResults = intermediateResults; + return this; + } + + /** + * Get intermediateResults + * + * @return intermediateResults The intermediateResults of this {@link EmbeddingsPostResponse} + * instance. + */ + @Nonnull + public ModuleResultsBase getIntermediateResults() { + return intermediateResults; + } + + /** + * Set the intermediateResults of this {@link EmbeddingsPostResponse} instance. + * + * @param intermediateResults The intermediateResults of this {@link EmbeddingsPostResponse} + */ + public void setIntermediateResults(@Nullable final ModuleResultsBase intermediateResults) { + this.intermediateResults = intermediateResults; + } + + /** + * Set the finalResult of this {@link EmbeddingsPostResponse} instance and return the same + * instance. + * + * @param finalResult The finalResult of this {@link EmbeddingsPostResponse} + * @return The same instance of this {@link EmbeddingsPostResponse} class + */ + @Nonnull + public EmbeddingsPostResponse finalResult(@Nullable final EmbeddingsResponse finalResult) { + this.finalResult = finalResult; + return this; + } + + /** + * Get finalResult + * + * @return finalResult The finalResult of this {@link EmbeddingsPostResponse} instance. + */ + @Nonnull + public EmbeddingsResponse getFinalResult() { + return finalResult; + } + + /** + * Set the finalResult of this {@link EmbeddingsPostResponse} instance. + * + * @param finalResult The finalResult of this {@link EmbeddingsPostResponse} + */ + public void setFinalResult(@Nullable final EmbeddingsResponse finalResult) { + this.finalResult = finalResult; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsPostResponse}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsPostResponse} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsPostResponse has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsPostResponse} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (requestId != null) declaredFields.put("requestId", requestId); + if (intermediateResults != null) declaredFields.put("intermediateResults", intermediateResults); + if (finalResult != null) declaredFields.put("finalResult", finalResult); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsPostResponse} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsPostResponse embeddingsPostResponse = (EmbeddingsPostResponse) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsPostResponse.cloudSdkCustomFields) + && Objects.equals(this.requestId, embeddingsPostResponse.requestId) + && Objects.equals(this.intermediateResults, embeddingsPostResponse.intermediateResults) + && Objects.equals(this.finalResult, embeddingsPostResponse.finalResult); + } + + @Override + public int hashCode() { + return Objects.hash(requestId, intermediateResults, finalResult, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsPostResponse {\n"); + sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); + sb.append(" intermediateResults: ") + .append(toIndentedString(intermediateResults)) + .append("\n"); + sb.append(" finalResult: ").append(toIndentedString(finalResult)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingsPostResponse} + * instance with all required arguments. + */ + public static Builder create() { + return (requestId) -> new EmbeddingsPostResponse().requestId(requestId); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the requestId of this {@link EmbeddingsPostResponse} instance. + * + * @param requestId The requestId of this {@link EmbeddingsPostResponse} + * @return The EmbeddingsPostResponse instance. + */ + EmbeddingsPostResponse requestId(@Nonnull final String requestId); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsResponse.java new file mode 100644 index 000000000..c247199bb --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsResponse.java @@ -0,0 +1,416 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** The response from request to embedding model following OpenAI specification. */ +// CHECKSTYLE:OFF +public class EmbeddingsResponse +// CHECKSTYLE:ON +{ + /** The object type, which is always \"list\". */ + public enum ObjectEnum { + /** The LIST option of this EmbeddingsResponse */ + LIST("list"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this EmbeddingsResponse */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ObjectEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type EmbeddingsResponse + */ + @JsonCreator + @Nonnull + public static ObjectEnum fromValue(@Nonnull final String value) { + for (ObjectEnum b : ObjectEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("object") + private ObjectEnum _object; + + @JsonProperty("data") + private List data = new ArrayList<>(); + + @JsonProperty("model") + private String model; + + @JsonProperty("usage") + private EmbeddingsUsage usage; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsResponse. */ + protected EmbeddingsResponse() {} + + /** + * Set the _object of this {@link EmbeddingsResponse} instance and return the same instance. + * + * @param _object The object type, which is always \"list\". + * @return The same instance of this {@link EmbeddingsResponse} class + */ + @Nonnull + public EmbeddingsResponse _object(@Nonnull final ObjectEnum _object) { + this._object = _object; + return this; + } + + /** + * The object type, which is always \"list\". + * + * @return _object The _object of this {@link EmbeddingsResponse} instance. + */ + @Nonnull + public ObjectEnum getObject() { + return _object; + } + + /** + * Set the _object of this {@link EmbeddingsResponse} instance. + * + * @param _object The object type, which is always \"list\". + */ + public void setObject(@Nonnull final ObjectEnum _object) { + this._object = _object; + } + + /** + * Set the data of this {@link EmbeddingsResponse} instance and return the same instance. + * + * @param data The list of embeddings generated by the model. + * @return The same instance of this {@link EmbeddingsResponse} class + */ + @Nonnull + public EmbeddingsResponse data(@Nonnull final List data) { + this.data = data; + return this; + } + + /** + * Add one data instance to this {@link EmbeddingsResponse}. + * + * @param dataItem The data that should be added + * @return The same instance of type {@link EmbeddingsResponse} + */ + @Nonnull + public EmbeddingsResponse addDataItem(@Nonnull final EmbeddingResult dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * The list of embeddings generated by the model. + * + * @return data The data of this {@link EmbeddingsResponse} instance. + */ + @Nonnull + public List getData() { + return data; + } + + /** + * Set the data of this {@link EmbeddingsResponse} instance. + * + * @param data The list of embeddings generated by the model. + */ + public void setData(@Nonnull final List data) { + this.data = data; + } + + /** + * Set the model of this {@link EmbeddingsResponse} instance and return the same instance. + * + * @param model The name of the model used to generate the embedding. + * @return The same instance of this {@link EmbeddingsResponse} class + */ + @Nonnull + public EmbeddingsResponse model(@Nonnull final String model) { + this.model = model; + return this; + } + + /** + * The name of the model used to generate the embedding. + * + * @return model The model of this {@link EmbeddingsResponse} instance. + */ + @Nonnull + public String getModel() { + return model; + } + + /** + * Set the model of this {@link EmbeddingsResponse} instance. + * + * @param model The name of the model used to generate the embedding. + */ + public void setModel(@Nonnull final String model) { + this.model = model; + } + + /** + * Set the usage of this {@link EmbeddingsResponse} instance and return the same instance. + * + * @param usage The usage of this {@link EmbeddingsResponse} + * @return The same instance of this {@link EmbeddingsResponse} class + */ + @Nonnull + public EmbeddingsResponse usage(@Nonnull final EmbeddingsUsage usage) { + this.usage = usage; + return this; + } + + /** + * Get usage + * + * @return usage The usage of this {@link EmbeddingsResponse} instance. + */ + @Nonnull + public EmbeddingsUsage getUsage() { + return usage; + } + + /** + * Set the usage of this {@link EmbeddingsResponse} instance. + * + * @param usage The usage of this {@link EmbeddingsResponse} + */ + public void setUsage(@Nonnull final EmbeddingsUsage usage) { + this.usage = usage; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsResponse}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsResponse} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("EmbeddingsResponse has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsResponse} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (_object != null) declaredFields.put("_object", _object); + if (data != null) declaredFields.put("data", data); + if (model != null) declaredFields.put("model", model); + if (usage != null) declaredFields.put("usage", usage); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsResponse} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsResponse embeddingsResponse = (EmbeddingsResponse) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsResponse.cloudSdkCustomFields) + && Objects.equals(this._object, embeddingsResponse._object) + && Objects.equals(this.data, embeddingsResponse.data) + && Objects.equals(this.model, embeddingsResponse.model) + && Objects.equals(this.usage, embeddingsResponse.usage); + } + + @Override + public int hashCode() { + return Objects.hash(_object, data, model, usage, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsResponse {\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" model: ").append(toIndentedString(model)).append("\n"); + sb.append(" usage: ").append(toIndentedString(usage)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingsResponse} + * instance with all required arguments. + */ + public static Builder create() { + return (_object) -> + (data) -> + (model) -> + (usage) -> + new EmbeddingsResponse()._object(_object).data(data).model(model).usage(usage); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the _object of this {@link EmbeddingsResponse} instance. + * + * @param _object The object type, which is always \"list\". + * @return The EmbeddingsResponse builder. + */ + Builder1 _object(@Nonnull final ObjectEnum _object); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the data of this {@link EmbeddingsResponse} instance. + * + * @param data The list of embeddings generated by the model. + * @return The EmbeddingsResponse builder. + */ + Builder2 data(@Nonnull final List data); + + /** + * Set the data of this {@link EmbeddingsResponse} instance. + * + * @param data The list of embeddings generated by the model. + * @return The EmbeddingsResponse builder. + */ + default Builder2 data(@Nonnull final EmbeddingResult... data) { + return data(Arrays.asList(data)); + } + } + + /** Builder helper class. */ + public interface Builder2 { + /** + * Set the model of this {@link EmbeddingsResponse} instance. + * + * @param model The name of the model used to generate the embedding. + * @return The EmbeddingsResponse builder. + */ + Builder3 model(@Nonnull final String model); + } + + /** Builder helper class. */ + public interface Builder3 { + /** + * Set the usage of this {@link EmbeddingsResponse} instance. + * + * @param usage The usage of this {@link EmbeddingsResponse} + * @return The EmbeddingsResponse instance. + */ + EmbeddingsResponse usage(@Nonnull final EmbeddingsUsage usage); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsUsage.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsUsage.java new file mode 100644 index 000000000..1dee2f56b --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsUsage.java @@ -0,0 +1,233 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** The usage information for the request. */ +// CHECKSTYLE:OFF +public class EmbeddingsUsage +// CHECKSTYLE:ON +{ + @JsonProperty("prompt_tokens") + private Integer promptTokens; + + @JsonProperty("total_tokens") + private Integer totalTokens; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsUsage. */ + protected EmbeddingsUsage() {} + + /** + * Set the promptTokens of this {@link EmbeddingsUsage} instance and return the same instance. + * + * @param promptTokens The number of tokens used by the prompt. + * @return The same instance of this {@link EmbeddingsUsage} class + */ + @Nonnull + public EmbeddingsUsage promptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; + return this; + } + + /** + * The number of tokens used by the prompt. + * + * @return promptTokens The promptTokens of this {@link EmbeddingsUsage} instance. + */ + @Nonnull + public Integer getPromptTokens() { + return promptTokens; + } + + /** + * Set the promptTokens of this {@link EmbeddingsUsage} instance. + * + * @param promptTokens The number of tokens used by the prompt. + */ + public void setPromptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; + } + + /** + * Set the totalTokens of this {@link EmbeddingsUsage} instance and return the same instance. + * + * @param totalTokens The total number of tokens used by the request. + * @return The same instance of this {@link EmbeddingsUsage} class + */ + @Nonnull + public EmbeddingsUsage totalTokens(@Nonnull final Integer totalTokens) { + this.totalTokens = totalTokens; + return this; + } + + /** + * The total number of tokens used by the request. + * + * @return totalTokens The totalTokens of this {@link EmbeddingsUsage} instance. + */ + @Nonnull + public Integer getTotalTokens() { + return totalTokens; + } + + /** + * Set the totalTokens of this {@link EmbeddingsUsage} instance. + * + * @param totalTokens The total number of tokens used by the request. + */ + public void setTotalTokens(@Nonnull final Integer totalTokens) { + this.totalTokens = totalTokens; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsUsage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsUsage} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("EmbeddingsUsage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link EmbeddingsUsage} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (promptTokens != null) declaredFields.put("promptTokens", promptTokens); + if (totalTokens != null) declaredFields.put("totalTokens", totalTokens); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsUsage} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsUsage embeddingsUsage = (EmbeddingsUsage) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsUsage.cloudSdkCustomFields) + && Objects.equals(this.promptTokens, embeddingsUsage.promptTokens) + && Objects.equals(this.totalTokens, embeddingsUsage.totalTokens); + } + + @Override + public int hashCode() { + return Objects.hash(promptTokens, totalTokens, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsUsage {\n"); + sb.append(" promptTokens: ").append(toIndentedString(promptTokens)).append("\n"); + sb.append(" totalTokens: ").append(toIndentedString(totalTokens)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingsUsage} + * instance with all required arguments. + */ + public static Builder create() { + return (promptTokens) -> + (totalTokens) -> new EmbeddingsUsage().promptTokens(promptTokens).totalTokens(totalTokens); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the promptTokens of this {@link EmbeddingsUsage} instance. + * + * @param promptTokens The number of tokens used by the prompt. + * @return The EmbeddingsUsage builder. + */ + Builder1 promptTokens(@Nonnull final Integer promptTokens); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the totalTokens of this {@link EmbeddingsUsage} instance. + * + * @param totalTokens The total number of tokens used by the request. + * @return The EmbeddingsUsage instance. + */ + EmbeddingsUsage totalTokens(@Nonnull final Integer totalTokens); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseStreaming.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseStreaming.java new file mode 100644 index 000000000..496390e32 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseStreaming.java @@ -0,0 +1,376 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ErrorResponseStreaming */ +// CHECKSTYLE:OFF +public class ErrorResponseStreaming +// CHECKSTYLE:ON +{ + @JsonProperty("request_id") + private String requestId; + + @JsonProperty("code") + private Integer code; + + @JsonProperty("message") + private String message; + + @JsonProperty("location") + private String location; + + @JsonProperty("module_results") + private ModuleResultsStreaming moduleResults; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ErrorResponseStreaming. */ + protected ErrorResponseStreaming() {} + + /** + * Set the requestId of this {@link ErrorResponseStreaming} instance and return the same instance. + * + * @param requestId The requestId of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class + */ + @Nonnull + public ErrorResponseStreaming requestId(@Nonnull final String requestId) { + this.requestId = requestId; + return this; + } + + /** + * Get requestId + * + * @return requestId The requestId of this {@link ErrorResponseStreaming} instance. + */ + @Nonnull + public String getRequestId() { + return requestId; + } + + /** + * Set the requestId of this {@link ErrorResponseStreaming} instance. + * + * @param requestId The requestId of this {@link ErrorResponseStreaming} + */ + public void setRequestId(@Nonnull final String requestId) { + this.requestId = requestId; + } + + /** + * Set the code of this {@link ErrorResponseStreaming} instance and return the same instance. + * + * @param code The code of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class + */ + @Nonnull + public ErrorResponseStreaming code(@Nonnull final Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code The code of this {@link ErrorResponseStreaming} instance. + */ + @Nonnull + public Integer getCode() { + return code; + } + + /** + * Set the code of this {@link ErrorResponseStreaming} instance. + * + * @param code The code of this {@link ErrorResponseStreaming} + */ + public void setCode(@Nonnull final Integer code) { + this.code = code; + } + + /** + * Set the message of this {@link ErrorResponseStreaming} instance and return the same instance. + * + * @param message The message of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class + */ + @Nonnull + public ErrorResponseStreaming message(@Nonnull final String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message The message of this {@link ErrorResponseStreaming} instance. + */ + @Nonnull + public String getMessage() { + return message; + } + + /** + * Set the message of this {@link ErrorResponseStreaming} instance. + * + * @param message The message of this {@link ErrorResponseStreaming} + */ + public void setMessage(@Nonnull final String message) { + this.message = message; + } + + /** + * Set the location of this {@link ErrorResponseStreaming} instance and return the same instance. + * + * @param location Where the error occurred + * @return The same instance of this {@link ErrorResponseStreaming} class + */ + @Nonnull + public ErrorResponseStreaming location(@Nonnull final String location) { + this.location = location; + return this; + } + + /** + * Where the error occurred + * + * @return location The location of this {@link ErrorResponseStreaming} instance. + */ + @Nonnull + public String getLocation() { + return location; + } + + /** + * Set the location of this {@link ErrorResponseStreaming} instance. + * + * @param location Where the error occurred + */ + public void setLocation(@Nonnull final String location) { + this.location = location; + } + + /** + * Set the moduleResults of this {@link ErrorResponseStreaming} instance and return the same + * instance. + * + * @param moduleResults The moduleResults of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class + */ + @Nonnull + public ErrorResponseStreaming moduleResults( + @Nullable final ModuleResultsStreaming moduleResults) { + this.moduleResults = moduleResults; + return this; + } + + /** + * Get moduleResults + * + * @return moduleResults The moduleResults of this {@link ErrorResponseStreaming} instance. + */ + @Nonnull + public ModuleResultsStreaming getModuleResults() { + return moduleResults; + } + + /** + * Set the moduleResults of this {@link ErrorResponseStreaming} instance. + * + * @param moduleResults The moduleResults of this {@link ErrorResponseStreaming} + */ + public void setModuleResults(@Nullable final ModuleResultsStreaming moduleResults) { + this.moduleResults = moduleResults; + } + + /** + * Get the names of the unrecognizable properties of the {@link ErrorResponseStreaming}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ErrorResponseStreaming} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ErrorResponseStreaming has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ErrorResponseStreaming} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (requestId != null) declaredFields.put("requestId", requestId); + if (code != null) declaredFields.put("code", code); + if (message != null) declaredFields.put("message", message); + if (location != null) declaredFields.put("location", location); + if (moduleResults != null) declaredFields.put("moduleResults", moduleResults); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link ErrorResponseStreaming} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ErrorResponseStreaming errorResponseStreaming = (ErrorResponseStreaming) o; + return Objects.equals(this.cloudSdkCustomFields, errorResponseStreaming.cloudSdkCustomFields) + && Objects.equals(this.requestId, errorResponseStreaming.requestId) + && Objects.equals(this.code, errorResponseStreaming.code) + && Objects.equals(this.message, errorResponseStreaming.message) + && Objects.equals(this.location, errorResponseStreaming.location) + && Objects.equals(this.moduleResults, errorResponseStreaming.moduleResults); + } + + @Override + public int hashCode() { + return Objects.hash(requestId, code, message, location, moduleResults, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponseStreaming {\n"); + sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" moduleResults: ").append(toIndentedString(moduleResults)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link ErrorResponseStreaming} + * instance with all required arguments. + */ + public static Builder create() { + return (requestId) -> + (code) -> + (message) -> + (location) -> + new ErrorResponseStreaming() + .requestId(requestId) + .code(code) + .message(message) + .location(location); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the requestId of this {@link ErrorResponseStreaming} instance. + * + * @param requestId The requestId of this {@link ErrorResponseStreaming} + * @return The ErrorResponseStreaming builder. + */ + Builder1 requestId(@Nonnull final String requestId); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the code of this {@link ErrorResponseStreaming} instance. + * + * @param code The code of this {@link ErrorResponseStreaming} + * @return The ErrorResponseStreaming builder. + */ + Builder2 code(@Nonnull final Integer code); + } + + /** Builder helper class. */ + public interface Builder2 { + /** + * Set the message of this {@link ErrorResponseStreaming} instance. + * + * @param message The message of this {@link ErrorResponseStreaming} + * @return The ErrorResponseStreaming builder. + */ + Builder3 message(@Nonnull final String message); + } + + /** Builder helper class. */ + public interface Builder3 { + /** + * Set the location of this {@link ErrorResponseStreaming} instance. + * + * @param location Where the error occurred + * @return The ErrorResponseStreaming instance. + */ + ErrorResponseStreaming location(@Nonnull final String location); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/FilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java similarity index 88% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/FilterConfig.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java index 8fb497341..2f2daf275 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/FilterConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java @@ -14,10 +14,10 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -/** FilterConfig */ +/** InputFilterConfig */ @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({ - @JsonSubTypes.Type(value = AzureContentSafetyFilterConfig.class), + @JsonSubTypes.Type(value = AzureContentSafetyInputFilterConfig.class), @JsonSubTypes.Type(value = LlamaGuard38bFilterConfig.class), }) -public interface FilterConfig {} +public interface InputFilterConfig {} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilteringConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilteringConfig.java index d71c9fb49..10da7556f 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilteringConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilteringConfig.java @@ -32,7 +32,7 @@ public class InputFilteringConfig // CHECKSTYLE:ON { @JsonProperty("filters") - private List filters = new ArrayList<>(); + private List filters = new ArrayList<>(); @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -44,11 +44,11 @@ protected InputFilteringConfig() {} * Set the filters of this {@link InputFilteringConfig} instance and return the same instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (input filtering). * @return The same instance of this {@link InputFilteringConfig} class */ @Nonnull - public InputFilteringConfig filters(@Nonnull final List filters) { + public InputFilteringConfig filters(@Nonnull final List filters) { this.filters = filters; return this; } @@ -60,7 +60,7 @@ public InputFilteringConfig filters(@Nonnull final List filters) { * @return The same instance of type {@link InputFilteringConfig} */ @Nonnull - public InputFilteringConfig addFiltersItem(@Nonnull final FilterConfig filtersItem) { + public InputFilteringConfig addFiltersItem(@Nonnull final InputFilterConfig filtersItem) { if (this.filters == null) { this.filters = new ArrayList<>(); } @@ -70,12 +70,12 @@ public InputFilteringConfig addFiltersItem(@Nonnull final FilterConfig filtersIt /** * Configuration for content filtering services that should be used for the given filtering step - * (input filtering or output filtering). + * (input filtering). * * @return filters The filters of this {@link InputFilteringConfig} instance. */ @Nonnull - public List getFilters() { + public List getFilters() { return filters; } @@ -83,9 +83,9 @@ public List getFilters() { * Set the filters of this {@link InputFilteringConfig} instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (input filtering). */ - public void setFilters(@Nonnull final List filters) { + public void setFilters(@Nonnull final List filters) { this.filters = filters; } @@ -199,19 +199,19 @@ public interface Builder { * Set the filters of this {@link InputFilteringConfig} instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (input filtering). * @return The InputFilteringConfig instance. */ - InputFilteringConfig filters(@Nonnull final List filters); + InputFilteringConfig filters(@Nonnull final List filters); /** * Set the filters of this {@link InputFilteringConfig} instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (input filtering). * @return The InputFilteringConfig instance. */ - default InputFilteringConfig filters(@Nonnull final FilterConfig... filters) { + default InputFilteringConfig filters(@Nonnull final InputFilterConfig... filters) { return filters(Arrays.asList(filters)); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java index 482d0b217..42f17cdb7 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java @@ -15,10 +15,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; @@ -28,7 +25,7 @@ /** LLMChoice */ // CHECKSTYLE:OFF -public class LLMChoice implements ModuleResultsOutputUnmaskingInner +public class LLMChoice // CHECKSTYLE:ON { @JsonProperty("index") @@ -38,7 +35,7 @@ public class LLMChoice implements ModuleResultsOutputUnmaskingInner private ResponseChatMessage message; @JsonProperty("logprobs") - private Map> logprobs = new HashMap<>(); + private ChoiceLogprobs logprobs; @JsonProperty("finish_reason") private String finishReason; @@ -114,48 +111,31 @@ public void setMessage(@Nonnull final ResponseChatMessage message) { /** * Set the logprobs of this {@link LLMChoice} instance and return the same instance. * - * @param logprobs Log probabilities + * @param logprobs The logprobs of this {@link LLMChoice} * @return The same instance of this {@link LLMChoice} class */ @Nonnull - public LLMChoice logprobs(@Nullable final Map> logprobs) { + public LLMChoice logprobs(@Nullable final ChoiceLogprobs logprobs) { this.logprobs = logprobs; return this; } /** - * Put one logprobs instance to this {@link LLMChoice} instance. - * - * @param key The String key of this logprobs instance - * @param logprobsItem The logprobs that should be added under the given key - * @return The same instance of type {@link LLMChoice} - */ - @Nonnull - public LLMChoice putlogprobsItem( - @Nonnull final String key, @Nonnull final List logprobsItem) { - if (this.logprobs == null) { - this.logprobs = new HashMap<>(); - } - this.logprobs.put(key, logprobsItem); - return this; - } - - /** - * Log probabilities + * Get logprobs * * @return logprobs The logprobs of this {@link LLMChoice} instance. */ @Nonnull - public Map> getLogprobs() { + public ChoiceLogprobs getLogprobs() { return logprobs; } /** * Set the logprobs of this {@link LLMChoice} instance. * - * @param logprobs Log probabilities + * @param logprobs The logprobs of this {@link LLMChoice} */ - public void setLogprobs(@Nullable final Map> logprobs) { + public void setLogprobs(@Nullable final ChoiceLogprobs logprobs) { this.logprobs = logprobs; } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceStreaming.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceStreaming.java index 4eb906ac1..070ee864d 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceStreaming.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceStreaming.java @@ -15,10 +15,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.math.BigDecimal; -import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; @@ -28,7 +25,7 @@ /** LLMChoiceStreaming */ // CHECKSTYLE:OFF -public class LLMChoiceStreaming implements ModuleResultsOutputUnmaskingInner +public class LLMChoiceStreaming // CHECKSTYLE:ON { @JsonProperty("index") @@ -38,7 +35,7 @@ public class LLMChoiceStreaming implements ModuleResultsOutputUnmaskingInner private ChatDelta delta; @JsonProperty("logprobs") - private Map> logprobs = new HashMap<>(); + private ChoiceLogprobs logprobs; @JsonProperty("finish_reason") private String finishReason; @@ -114,48 +111,31 @@ public void setDelta(@Nonnull final ChatDelta delta) { /** * Set the logprobs of this {@link LLMChoiceStreaming} instance and return the same instance. * - * @param logprobs Log probabilities + * @param logprobs The logprobs of this {@link LLMChoiceStreaming} * @return The same instance of this {@link LLMChoiceStreaming} class */ @Nonnull - public LLMChoiceStreaming logprobs(@Nullable final Map> logprobs) { + public LLMChoiceStreaming logprobs(@Nullable final ChoiceLogprobs logprobs) { this.logprobs = logprobs; return this; } /** - * Put one logprobs instance to this {@link LLMChoiceStreaming} instance. - * - * @param key The String key of this logprobs instance - * @param logprobsItem The logprobs that should be added under the given key - * @return The same instance of type {@link LLMChoiceStreaming} - */ - @Nonnull - public LLMChoiceStreaming putlogprobsItem( - @Nonnull final String key, @Nonnull final List logprobsItem) { - if (this.logprobs == null) { - this.logprobs = new HashMap<>(); - } - this.logprobs.put(key, logprobsItem); - return this; - } - - /** - * Log probabilities + * Get logprobs * * @return logprobs The logprobs of this {@link LLMChoiceStreaming} instance. */ @Nonnull - public Map> getLogprobs() { + public ChoiceLogprobs getLogprobs() { return logprobs; } /** * Set the logprobs of this {@link LLMChoiceStreaming} instance. * - * @param logprobs Log probabilities + * @param logprobs The logprobs of this {@link LLMChoiceStreaming} */ - public void setLogprobs(@Nullable final Map> logprobs) { + public void setLogprobs(@Nullable final ChoiceLogprobs logprobs) { this.logprobs = logprobs; } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java index a07479937..10063bb70 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java @@ -11,13 +11,493 @@ package com.sap.ai.sdk.orchestration.model; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** Output of LLM module. Follows the OpenAI spec. */ -@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) -@JsonSubTypes({ - @JsonSubTypes.Type(value = LLMModuleResultStreaming.class), - @JsonSubTypes.Type(value = LLMModuleResultSynchronous.class), -}) -public interface LLMModuleResult {} +// CHECKSTYLE:OFF +public class LLMModuleResult +// CHECKSTYLE:ON +{ + @JsonProperty("id") + private String id; + + @JsonProperty("object") + private String _object; + + @JsonProperty("created") + private Integer created; + + @JsonProperty("model") + private String model; + + @JsonProperty("system_fingerprint") + private String systemFingerprint; + + @JsonProperty("choices") + private List choices = new ArrayList<>(); + + @JsonProperty("usage") + private TokenUsage usage; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for LLMModuleResult. */ + protected LLMModuleResult() {} + + /** + * Set the id of this {@link LLMModuleResult} instance and return the same instance. + * + * @param id ID of the response + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult id(@Nonnull final String id) { + this.id = id; + return this; + } + + /** + * ID of the response + * + * @return id The id of this {@link LLMModuleResult} instance. + */ + @Nonnull + public String getId() { + return id; + } + + /** + * Set the id of this {@link LLMModuleResult} instance. + * + * @param id ID of the response + */ + public void setId(@Nonnull final String id) { + this.id = id; + } + + /** + * Set the _object of this {@link LLMModuleResult} instance and return the same instance. + * + * @param _object Object type + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult _object(@Nonnull final String _object) { + this._object = _object; + return this; + } + + /** + * Object type + * + * @return _object The _object of this {@link LLMModuleResult} instance. + */ + @Nonnull + public String getObject() { + return _object; + } + + /** + * Set the _object of this {@link LLMModuleResult} instance. + * + * @param _object Object type + */ + public void setObject(@Nonnull final String _object) { + this._object = _object; + } + + /** + * Set the created of this {@link LLMModuleResult} instance and return the same instance. + * + * @param created Unix timestamp + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult created(@Nonnull final Integer created) { + this.created = created; + return this; + } + + /** + * Unix timestamp + * + * @return created The created of this {@link LLMModuleResult} instance. + */ + @Nonnull + public Integer getCreated() { + return created; + } + + /** + * Set the created of this {@link LLMModuleResult} instance. + * + * @param created Unix timestamp + */ + public void setCreated(@Nonnull final Integer created) { + this.created = created; + } + + /** + * Set the model of this {@link LLMModuleResult} instance and return the same instance. + * + * @param model Model name + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult model(@Nonnull final String model) { + this.model = model; + return this; + } + + /** + * Model name + * + * @return model The model of this {@link LLMModuleResult} instance. + */ + @Nonnull + public String getModel() { + return model; + } + + /** + * Set the model of this {@link LLMModuleResult} instance. + * + * @param model Model name + */ + public void setModel(@Nonnull final String model) { + this.model = model; + } + + /** + * Set the systemFingerprint of this {@link LLMModuleResult} instance and return the same + * instance. + * + * @param systemFingerprint System fingerprint + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult systemFingerprint(@Nullable final String systemFingerprint) { + this.systemFingerprint = systemFingerprint; + return this; + } + + /** + * System fingerprint + * + * @return systemFingerprint The systemFingerprint of this {@link LLMModuleResult} instance. + */ + @Nonnull + public String getSystemFingerprint() { + return systemFingerprint; + } + + /** + * Set the systemFingerprint of this {@link LLMModuleResult} instance. + * + * @param systemFingerprint System fingerprint + */ + public void setSystemFingerprint(@Nullable final String systemFingerprint) { + this.systemFingerprint = systemFingerprint; + } + + /** + * Set the choices of this {@link LLMModuleResult} instance and return the same instance. + * + * @param choices Choices + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult choices(@Nonnull final List choices) { + this.choices = choices; + return this; + } + + /** + * Add one choices instance to this {@link LLMModuleResult}. + * + * @param choicesItem The choices that should be added + * @return The same instance of type {@link LLMModuleResult} + */ + @Nonnull + public LLMModuleResult addChoicesItem(@Nonnull final LLMChoice choicesItem) { + if (this.choices == null) { + this.choices = new ArrayList<>(); + } + this.choices.add(choicesItem); + return this; + } + + /** + * Choices + * + * @return choices The choices of this {@link LLMModuleResult} instance. + */ + @Nonnull + public List getChoices() { + return choices; + } + + /** + * Set the choices of this {@link LLMModuleResult} instance. + * + * @param choices Choices + */ + public void setChoices(@Nonnull final List choices) { + this.choices = choices; + } + + /** + * Set the usage of this {@link LLMModuleResult} instance and return the same instance. + * + * @param usage The usage of this {@link LLMModuleResult} + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult usage(@Nonnull final TokenUsage usage) { + this.usage = usage; + return this; + } + + /** + * Get usage + * + * @return usage The usage of this {@link LLMModuleResult} instance. + */ + @Nonnull + public TokenUsage getUsage() { + return usage; + } + + /** + * Set the usage of this {@link LLMModuleResult} instance. + * + * @param usage The usage of this {@link LLMModuleResult} + */ + public void setUsage(@Nonnull final TokenUsage usage) { + this.usage = usage; + } + + /** + * Get the names of the unrecognizable properties of the {@link LLMModuleResult}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link LLMModuleResult} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("LLMModuleResult has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link LLMModuleResult} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (id != null) declaredFields.put("id", id); + if (_object != null) declaredFields.put("_object", _object); + if (created != null) declaredFields.put("created", created); + if (model != null) declaredFields.put("model", model); + if (systemFingerprint != null) declaredFields.put("systemFingerprint", systemFingerprint); + if (choices != null) declaredFields.put("choices", choices); + if (usage != null) declaredFields.put("usage", usage); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link LLMModuleResult} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final LLMModuleResult llMModuleResult = (LLMModuleResult) o; + return Objects.equals(this.cloudSdkCustomFields, llMModuleResult.cloudSdkCustomFields) + && Objects.equals(this.id, llMModuleResult.id) + && Objects.equals(this._object, llMModuleResult._object) + && Objects.equals(this.created, llMModuleResult.created) + && Objects.equals(this.model, llMModuleResult.model) + && Objects.equals(this.systemFingerprint, llMModuleResult.systemFingerprint) + && Objects.equals(this.choices, llMModuleResult.choices) + && Objects.equals(this.usage, llMModuleResult.usage); + } + + @Override + public int hashCode() { + return Objects.hash( + id, _object, created, model, systemFingerprint, choices, usage, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class LLMModuleResult {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" model: ").append(toIndentedString(model)).append("\n"); + sb.append(" systemFingerprint: ").append(toIndentedString(systemFingerprint)).append("\n"); + sb.append(" choices: ").append(toIndentedString(choices)).append("\n"); + sb.append(" usage: ").append(toIndentedString(usage)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link LLMModuleResult} + * instance with all required arguments. + */ + public static Builder create() { + return (id) -> + (_object) -> + (created) -> + (model) -> + (choices) -> + (usage) -> + new LLMModuleResult() + .id(id) + ._object(_object) + .created(created) + .model(model) + .choices(choices) + .usage(usage); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the id of this {@link LLMModuleResult} instance. + * + * @param id ID of the response + * @return The LLMModuleResult builder. + */ + Builder1 id(@Nonnull final String id); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the _object of this {@link LLMModuleResult} instance. + * + * @param _object Object type + * @return The LLMModuleResult builder. + */ + Builder2 _object(@Nonnull final String _object); + } + + /** Builder helper class. */ + public interface Builder2 { + /** + * Set the created of this {@link LLMModuleResult} instance. + * + * @param created Unix timestamp + * @return The LLMModuleResult builder. + */ + Builder3 created(@Nonnull final Integer created); + } + + /** Builder helper class. */ + public interface Builder3 { + /** + * Set the model of this {@link LLMModuleResult} instance. + * + * @param model Model name + * @return The LLMModuleResult builder. + */ + Builder4 model(@Nonnull final String model); + } + + /** Builder helper class. */ + public interface Builder4 { + /** + * Set the choices of this {@link LLMModuleResult} instance. + * + * @param choices Choices + * @return The LLMModuleResult builder. + */ + Builder5 choices(@Nonnull final List choices); + + /** + * Set the choices of this {@link LLMModuleResult} instance. + * + * @param choices Choices + * @return The LLMModuleResult builder. + */ + default Builder5 choices(@Nonnull final LLMChoice... choices) { + return choices(Arrays.asList(choices)); + } + } + + /** Builder helper class. */ + public interface Builder5 { + /** + * Set the usage of this {@link LLMModuleResult} instance. + * + * @param usage The usage of this {@link LLMModuleResult} + * @return The LLMModuleResult instance. + */ + LLMModuleResult usage(@Nonnull final TokenUsage usage); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java index f996ab8b0..394a8d3b1 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java @@ -28,7 +28,7 @@ /** Output of LLM module. Follows the OpenAI spec. */ // CHECKSTYLE:OFF -public class LLMModuleResultStreaming implements LLMModuleResult +public class LLMModuleResultStreaming // CHECKSTYLE:ON { @JsonProperty("id") diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultSynchronous.java deleted file mode 100644 index 5db99a16c..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultSynchronous.java +++ /dev/null @@ -1,510 +0,0 @@ -/* - * Internal Orchestration Service API - * 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. - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sap.ai.sdk.orchestration.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** Output of LLM module. Follows the OpenAI spec. */ -// CHECKSTYLE:OFF -public class LLMModuleResultSynchronous implements LLMModuleResult -// CHECKSTYLE:ON -{ - @JsonProperty("id") - private String id; - - @JsonProperty("object") - private String _object; - - @JsonProperty("created") - private Integer created; - - @JsonProperty("model") - private String model; - - @JsonProperty("system_fingerprint") - private String systemFingerprint; - - @JsonProperty("choices") - private List choices = new ArrayList<>(); - - @JsonProperty("usage") - private TokenUsage usage; - - @JsonAnySetter @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** Default constructor for LLMModuleResultSynchronous. */ - protected LLMModuleResultSynchronous() {} - - /** - * Set the id of this {@link LLMModuleResultSynchronous} instance and return the same instance. - * - * @param id ID of the response - * @return The same instance of this {@link LLMModuleResultSynchronous} class - */ - @Nonnull - public LLMModuleResultSynchronous id(@Nonnull final String id) { - this.id = id; - return this; - } - - /** - * ID of the response - * - * @return id The id of this {@link LLMModuleResultSynchronous} instance. - */ - @Nonnull - public String getId() { - return id; - } - - /** - * Set the id of this {@link LLMModuleResultSynchronous} instance. - * - * @param id ID of the response - */ - public void setId(@Nonnull final String id) { - this.id = id; - } - - /** - * Set the _object of this {@link LLMModuleResultSynchronous} instance and return the same - * instance. - * - * @param _object Object type - * @return The same instance of this {@link LLMModuleResultSynchronous} class - */ - @Nonnull - public LLMModuleResultSynchronous _object(@Nonnull final String _object) { - this._object = _object; - return this; - } - - /** - * Object type - * - * @return _object The _object of this {@link LLMModuleResultSynchronous} instance. - */ - @Nonnull - public String getObject() { - return _object; - } - - /** - * Set the _object of this {@link LLMModuleResultSynchronous} instance. - * - * @param _object Object type - */ - public void setObject(@Nonnull final String _object) { - this._object = _object; - } - - /** - * Set the created of this {@link LLMModuleResultSynchronous} instance and return the same - * instance. - * - * @param created Unix timestamp - * @return The same instance of this {@link LLMModuleResultSynchronous} class - */ - @Nonnull - public LLMModuleResultSynchronous created(@Nonnull final Integer created) { - this.created = created; - return this; - } - - /** - * Unix timestamp - * - * @return created The created of this {@link LLMModuleResultSynchronous} instance. - */ - @Nonnull - public Integer getCreated() { - return created; - } - - /** - * Set the created of this {@link LLMModuleResultSynchronous} instance. - * - * @param created Unix timestamp - */ - public void setCreated(@Nonnull final Integer created) { - this.created = created; - } - - /** - * Set the model of this {@link LLMModuleResultSynchronous} instance and return the same instance. - * - * @param model Model name - * @return The same instance of this {@link LLMModuleResultSynchronous} class - */ - @Nonnull - public LLMModuleResultSynchronous model(@Nonnull final String model) { - this.model = model; - return this; - } - - /** - * Model name - * - * @return model The model of this {@link LLMModuleResultSynchronous} instance. - */ - @Nonnull - public String getModel() { - return model; - } - - /** - * Set the model of this {@link LLMModuleResultSynchronous} instance. - * - * @param model Model name - */ - public void setModel(@Nonnull final String model) { - this.model = model; - } - - /** - * Set the systemFingerprint of this {@link LLMModuleResultSynchronous} instance and return the - * same instance. - * - * @param systemFingerprint System fingerprint - * @return The same instance of this {@link LLMModuleResultSynchronous} class - */ - @Nonnull - public LLMModuleResultSynchronous systemFingerprint(@Nullable final String systemFingerprint) { - this.systemFingerprint = systemFingerprint; - return this; - } - - /** - * System fingerprint - * - * @return systemFingerprint The systemFingerprint of this {@link LLMModuleResultSynchronous} - * instance. - */ - @Nonnull - public String getSystemFingerprint() { - return systemFingerprint; - } - - /** - * Set the systemFingerprint of this {@link LLMModuleResultSynchronous} instance. - * - * @param systemFingerprint System fingerprint - */ - public void setSystemFingerprint(@Nullable final String systemFingerprint) { - this.systemFingerprint = systemFingerprint; - } - - /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance and return the same - * instance. - * - * @param choices Choices - * @return The same instance of this {@link LLMModuleResultSynchronous} class - */ - @Nonnull - public LLMModuleResultSynchronous choices(@Nonnull final List choices) { - this.choices = choices; - return this; - } - - /** - * Add one choices instance to this {@link LLMModuleResultSynchronous}. - * - * @param choicesItem The choices that should be added - * @return The same instance of type {@link LLMModuleResultSynchronous} - */ - @Nonnull - public LLMModuleResultSynchronous addChoicesItem(@Nonnull final LLMChoice choicesItem) { - if (this.choices == null) { - this.choices = new ArrayList<>(); - } - this.choices.add(choicesItem); - return this; - } - - /** - * Choices - * - * @return choices The choices of this {@link LLMModuleResultSynchronous} instance. - */ - @Nonnull - public List getChoices() { - return choices; - } - - /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance. - * - * @param choices Choices - */ - public void setChoices(@Nonnull final List choices) { - this.choices = choices; - } - - /** - * Set the usage of this {@link LLMModuleResultSynchronous} instance and return the same instance. - * - * @param usage The usage of this {@link LLMModuleResultSynchronous} - * @return The same instance of this {@link LLMModuleResultSynchronous} class - */ - @Nonnull - public LLMModuleResultSynchronous usage(@Nonnull final TokenUsage usage) { - this.usage = usage; - return this; - } - - /** - * Get usage - * - * @return usage The usage of this {@link LLMModuleResultSynchronous} instance. - */ - @Nonnull - public TokenUsage getUsage() { - return usage; - } - - /** - * Set the usage of this {@link LLMModuleResultSynchronous} instance. - * - * @param usage The usage of this {@link LLMModuleResultSynchronous} - */ - public void setUsage(@Nonnull final TokenUsage usage) { - this.usage = usage; - } - - /** - * Get the names of the unrecognizable properties of the {@link LLMModuleResultSynchronous}. - * - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link LLMModuleResultSynchronous} - * instance. - * - * @deprecated Use {@link #toMap()} instead. - * @param name The name of the property - * @return The value of the property - * @throws NoSuchElementException If no property with the given name could be found. - */ - @Nullable - @Deprecated - public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { - if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException( - "LLMModuleResultSynchronous has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Get the value of all properties of this {@link LLMModuleResultSynchronous} instance including - * unrecognized properties. - * - * @return The map of all properties - */ - @JsonIgnore - @Nonnull - public Map toMap() { - final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); - if (id != null) declaredFields.put("id", id); - if (_object != null) declaredFields.put("_object", _object); - if (created != null) declaredFields.put("created", created); - if (model != null) declaredFields.put("model", model); - if (systemFingerprint != null) declaredFields.put("systemFingerprint", systemFingerprint); - if (choices != null) declaredFields.put("choices", choices); - if (usage != null) declaredFields.put("usage", usage); - return declaredFields; - } - - /** - * Set an unrecognizable property of this {@link LLMModuleResultSynchronous} instance. If the map - * previously contained a mapping for the key, the old value is replaced by the specified value. - * - * @param customFieldName The name of the property - * @param customFieldValue The value of the property - */ - @JsonIgnore - public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { - cloudSdkCustomFields.put(customFieldName, customFieldValue); - } - - @Override - public boolean equals(@Nullable final java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final LLMModuleResultSynchronous llMModuleResultSynchronous = (LLMModuleResultSynchronous) o; - return Objects.equals( - this.cloudSdkCustomFields, llMModuleResultSynchronous.cloudSdkCustomFields) - && Objects.equals(this.id, llMModuleResultSynchronous.id) - && Objects.equals(this._object, llMModuleResultSynchronous._object) - && Objects.equals(this.created, llMModuleResultSynchronous.created) - && Objects.equals(this.model, llMModuleResultSynchronous.model) - && Objects.equals(this.systemFingerprint, llMModuleResultSynchronous.systemFingerprint) - && Objects.equals(this.choices, llMModuleResultSynchronous.choices) - && Objects.equals(this.usage, llMModuleResultSynchronous.usage); - } - - @Override - public int hashCode() { - return Objects.hash( - id, _object, created, model, systemFingerprint, choices, usage, cloudSdkCustomFields); - } - - @Override - @Nonnull - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class LLMModuleResultSynchronous {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); - sb.append(" created: ").append(toIndentedString(created)).append("\n"); - sb.append(" model: ").append(toIndentedString(model)).append("\n"); - sb.append(" systemFingerprint: ").append(toIndentedString(systemFingerprint)).append("\n"); - sb.append(" choices: ").append(toIndentedString(choices)).append("\n"); - sb.append(" usage: ").append(toIndentedString(usage)).append("\n"); - cloudSdkCustomFields.forEach( - (k, v) -> - sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Create a type-safe, fluent-api builder object to construct a new {@link - * LLMModuleResultSynchronous} instance with all required arguments. - */ - public static Builder create() { - return (id) -> - (_object) -> - (created) -> - (model) -> - (choices) -> - (usage) -> - new LLMModuleResultSynchronous() - .id(id) - ._object(_object) - .created(created) - .model(model) - .choices(choices) - .usage(usage); - } - - /** Builder helper class. */ - public interface Builder { - /** - * Set the id of this {@link LLMModuleResultSynchronous} instance. - * - * @param id ID of the response - * @return The LLMModuleResultSynchronous builder. - */ - Builder1 id(@Nonnull final String id); - } - - /** Builder helper class. */ - public interface Builder1 { - /** - * Set the _object of this {@link LLMModuleResultSynchronous} instance. - * - * @param _object Object type - * @return The LLMModuleResultSynchronous builder. - */ - Builder2 _object(@Nonnull final String _object); - } - - /** Builder helper class. */ - public interface Builder2 { - /** - * Set the created of this {@link LLMModuleResultSynchronous} instance. - * - * @param created Unix timestamp - * @return The LLMModuleResultSynchronous builder. - */ - Builder3 created(@Nonnull final Integer created); - } - - /** Builder helper class. */ - public interface Builder3 { - /** - * Set the model of this {@link LLMModuleResultSynchronous} instance. - * - * @param model Model name - * @return The LLMModuleResultSynchronous builder. - */ - Builder4 model(@Nonnull final String model); - } - - /** Builder helper class. */ - public interface Builder4 { - /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance. - * - * @param choices Choices - * @return The LLMModuleResultSynchronous builder. - */ - Builder5 choices(@Nonnull final List choices); - - /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance. - * - * @param choices Choices - * @return The LLMModuleResultSynchronous builder. - */ - default Builder5 choices(@Nonnull final LLMChoice... choices) { - return choices(Arrays.asList(choices)); - } - } - - /** Builder helper class. */ - public interface Builder5 { - /** - * Set the usage of this {@link LLMModuleResultSynchronous} instance. - * - * @param usage The usage of this {@link LLMModuleResultSynchronous} - * @return The LLMModuleResultSynchronous instance. - */ - LLMModuleResultSynchronous usage(@Nonnull final TokenUsage usage); - } -} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LlamaGuard38bFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LlamaGuard38bFilterConfig.java index 4e848cfc2..686c1592e 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LlamaGuard38bFilterConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LlamaGuard38bFilterConfig.java @@ -27,7 +27,7 @@ /** LlamaGuard38bFilterConfig */ // CHECKSTYLE:OFF -public class LlamaGuard38bFilterConfig implements FilterConfig +public class LlamaGuard38bFilterConfig implements InputFilterConfig, OutputFilterConfig // CHECKSTYLE:ON { /** Name of the filter provider type */ diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java index 5db49a5cb..d5af953ad 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java @@ -25,7 +25,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** Results of each module. */ +/** Synchronous results of each module. */ // CHECKSTYLE:OFF public class ModuleResults // CHECKSTYLE:ON @@ -45,18 +45,18 @@ public class ModuleResults @JsonProperty("input_filtering") private GenericModuleResult inputFiltering; - @JsonProperty("llm") - private LLMModuleResult llm; - @JsonProperty("output_filtering") private GenericModuleResult outputFiltering; - @JsonProperty("output_unmasking") - private List outputUnmasking = new ArrayList<>(); - @JsonProperty("output_translation") private GenericModuleResult outputTranslation; + @JsonProperty("llm") + private LLMModuleResult llm; + + @JsonProperty("output_unmasking") + private List outputUnmasking = new ArrayList<>(); + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -234,145 +234,142 @@ public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering } /** - * Set the llm of this {@link ModuleResults} instance and return the same instance. + * Set the outputFiltering of this {@link ModuleResults} instance and return the same instance. * - * @param llm The llm of this {@link ModuleResults} + * @param outputFiltering The outputFiltering of this {@link ModuleResults} * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResults llm(@Nullable final LLMModuleResult llm) { - this.llm = llm; + public ModuleResults outputFiltering(@Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; return this; } /** - * Get llm + * Get outputFiltering * - * @return llm The llm of this {@link ModuleResults} instance. + * @return outputFiltering The outputFiltering of this {@link ModuleResults} instance. */ @Nonnull - public LLMModuleResult getLlm() { - return llm; + public GenericModuleResult getOutputFiltering() { + return outputFiltering; } /** - * Set the llm of this {@link ModuleResults} instance. + * Set the outputFiltering of this {@link ModuleResults} instance. * - * @param llm The llm of this {@link ModuleResults} + * @param outputFiltering The outputFiltering of this {@link ModuleResults} */ - public void setLlm(@Nullable final LLMModuleResult llm) { - this.llm = llm; + public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; } /** - * Set the outputFiltering of this {@link ModuleResults} instance and return the same instance. + * Set the outputTranslation of this {@link ModuleResults} instance and return the same instance. * - * @param outputFiltering The outputFiltering of this {@link ModuleResults} + * @param outputTranslation The outputTranslation of this {@link ModuleResults} * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResults outputFiltering(@Nullable final GenericModuleResult outputFiltering) { - this.outputFiltering = outputFiltering; + public ModuleResults outputTranslation(@Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; return this; } /** - * Get outputFiltering + * Get outputTranslation * - * @return outputFiltering The outputFiltering of this {@link ModuleResults} instance. + * @return outputTranslation The outputTranslation of this {@link ModuleResults} instance. */ @Nonnull - public GenericModuleResult getOutputFiltering() { - return outputFiltering; + public GenericModuleResult getOutputTranslation() { + return outputTranslation; } /** - * Set the outputFiltering of this {@link ModuleResults} instance. + * Set the outputTranslation of this {@link ModuleResults} instance. * - * @param outputFiltering The outputFiltering of this {@link ModuleResults} + * @param outputTranslation The outputTranslation of this {@link ModuleResults} */ - public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { - this.outputFiltering = outputFiltering; + public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; } /** - * Set the outputUnmasking of this {@link ModuleResults} instance and return the same instance. + * Set the llm of this {@link ModuleResults} instance and return the same instance. * - * @param outputUnmasking The outputUnmasking of this {@link ModuleResults} + * @param llm The llm of this {@link ModuleResults} * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResults outputUnmasking( - @Nullable final List outputUnmasking) { - this.outputUnmasking = outputUnmasking; + public ModuleResults llm(@Nullable final LLMModuleResult llm) { + this.llm = llm; return this; } /** - * Add one outputUnmasking instance to this {@link ModuleResults}. + * Get llm * - * @param outputUnmaskingItem The outputUnmasking that should be added - * @return The same instance of type {@link ModuleResults} + * @return llm The llm of this {@link ModuleResults} instance. */ @Nonnull - public ModuleResults addOutputUnmaskingItem( - @Nonnull final ModuleResultsOutputUnmaskingInner outputUnmaskingItem) { - if (this.outputUnmasking == null) { - this.outputUnmasking = new ArrayList<>(); - } - this.outputUnmasking.add(outputUnmaskingItem); - return this; + public LLMModuleResult getLlm() { + return llm; } /** - * Get outputUnmasking + * Set the llm of this {@link ModuleResults} instance. * - * @return outputUnmasking The outputUnmasking of this {@link ModuleResults} instance. + * @param llm The llm of this {@link ModuleResults} */ - @Nonnull - public List getOutputUnmasking() { - return outputUnmasking; + public void setLlm(@Nullable final LLMModuleResult llm) { + this.llm = llm; } /** - * Set the outputUnmasking of this {@link ModuleResults} instance. + * Set the outputUnmasking of this {@link ModuleResults} instance and return the same instance. * * @param outputUnmasking The outputUnmasking of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ - public void setOutputUnmasking( - @Nullable final List outputUnmasking) { + @Nonnull + public ModuleResults outputUnmasking(@Nullable final List outputUnmasking) { this.outputUnmasking = outputUnmasking; + return this; } /** - * Set the outputTranslation of this {@link ModuleResults} instance and return the same instance. + * Add one outputUnmasking instance to this {@link ModuleResults}. * - * @param outputTranslation The outputTranslation of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param outputUnmaskingItem The outputUnmasking that should be added + * @return The same instance of type {@link ModuleResults} */ @Nonnull - public ModuleResults outputTranslation(@Nullable final GenericModuleResult outputTranslation) { - this.outputTranslation = outputTranslation; + public ModuleResults addOutputUnmaskingItem(@Nonnull final LLMChoice outputUnmaskingItem) { + if (this.outputUnmasking == null) { + this.outputUnmasking = new ArrayList<>(); + } + this.outputUnmasking.add(outputUnmaskingItem); return this; } /** - * Get outputTranslation + * Get outputUnmasking * - * @return outputTranslation The outputTranslation of this {@link ModuleResults} instance. + * @return outputUnmasking The outputUnmasking of this {@link ModuleResults} instance. */ @Nonnull - public GenericModuleResult getOutputTranslation() { - return outputTranslation; + public List getOutputUnmasking() { + return outputUnmasking; } /** - * Set the outputTranslation of this {@link ModuleResults} instance. + * Set the outputUnmasking of this {@link ModuleResults} instance. * - * @param outputTranslation The outputTranslation of this {@link ModuleResults} + * @param outputUnmasking The outputUnmasking of this {@link ModuleResults} */ - public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { - this.outputTranslation = outputTranslation; + public void setOutputUnmasking(@Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; } /** @@ -418,10 +415,10 @@ public Map toMap() { if (inputTranslation != null) declaredFields.put("inputTranslation", inputTranslation); if (inputMasking != null) declaredFields.put("inputMasking", inputMasking); if (inputFiltering != null) declaredFields.put("inputFiltering", inputFiltering); - if (llm != null) declaredFields.put("llm", llm); if (outputFiltering != null) declaredFields.put("outputFiltering", outputFiltering); - if (outputUnmasking != null) declaredFields.put("outputUnmasking", outputUnmasking); if (outputTranslation != null) declaredFields.put("outputTranslation", outputTranslation); + if (llm != null) declaredFields.put("llm", llm); + if (outputUnmasking != null) declaredFields.put("outputUnmasking", outputUnmasking); return declaredFields; } @@ -452,10 +449,10 @@ public boolean equals(@Nullable final java.lang.Object o) { && Objects.equals(this.inputTranslation, moduleResults.inputTranslation) && Objects.equals(this.inputMasking, moduleResults.inputMasking) && Objects.equals(this.inputFiltering, moduleResults.inputFiltering) - && Objects.equals(this.llm, moduleResults.llm) && Objects.equals(this.outputFiltering, moduleResults.outputFiltering) - && Objects.equals(this.outputUnmasking, moduleResults.outputUnmasking) - && Objects.equals(this.outputTranslation, moduleResults.outputTranslation); + && Objects.equals(this.outputTranslation, moduleResults.outputTranslation) + && Objects.equals(this.llm, moduleResults.llm) + && Objects.equals(this.outputUnmasking, moduleResults.outputUnmasking); } @Override @@ -466,10 +463,10 @@ public int hashCode() { inputTranslation, inputMasking, inputFiltering, - llm, outputFiltering, - outputUnmasking, outputTranslation, + llm, + outputUnmasking, cloudSdkCustomFields); } @@ -483,10 +480,10 @@ public String toString() { sb.append(" inputTranslation: ").append(toIndentedString(inputTranslation)).append("\n"); sb.append(" inputMasking: ").append(toIndentedString(inputMasking)).append("\n"); sb.append(" inputFiltering: ").append(toIndentedString(inputFiltering)).append("\n"); - sb.append(" llm: ").append(toIndentedString(llm)).append("\n"); sb.append(" outputFiltering: ").append(toIndentedString(outputFiltering)).append("\n"); - sb.append(" outputUnmasking: ").append(toIndentedString(outputUnmasking)).append("\n"); sb.append(" outputTranslation: ").append(toIndentedString(outputTranslation)).append("\n"); + sb.append(" llm: ").append(toIndentedString(llm)).append("\n"); + sb.append(" outputUnmasking: ").append(toIndentedString(outputUnmasking)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsBase.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsBase.java new file mode 100644 index 000000000..5e8c22035 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsBase.java @@ -0,0 +1,421 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Results of each module of /embeddings endpoint(e.g. input masking). */ +// CHECKSTYLE:OFF +public class ModuleResultsBase +// CHECKSTYLE:ON +{ + @JsonProperty("grounding") + private GenericModuleResult grounding; + + @JsonProperty("templating") + private List templating = new ArrayList<>(); + + @JsonProperty("input_translation") + private GenericModuleResult inputTranslation; + + @JsonProperty("input_masking") + private GenericModuleResult inputMasking; + + @JsonProperty("input_filtering") + private GenericModuleResult inputFiltering; + + @JsonProperty("output_filtering") + private GenericModuleResult outputFiltering; + + @JsonProperty("output_translation") + private GenericModuleResult outputTranslation; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ModuleResultsBase. */ + protected ModuleResultsBase() {} + + /** + * Set the grounding of this {@link ModuleResultsBase} instance and return the same instance. + * + * @param grounding The grounding of this {@link ModuleResultsBase} + * @return The same instance of this {@link ModuleResultsBase} class + */ + @Nonnull + public ModuleResultsBase grounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + return this; + } + + /** + * Get grounding + * + * @return grounding The grounding of this {@link ModuleResultsBase} instance. + */ + @Nonnull + public GenericModuleResult getGrounding() { + return grounding; + } + + /** + * Set the grounding of this {@link ModuleResultsBase} instance. + * + * @param grounding The grounding of this {@link ModuleResultsBase} + */ + public void setGrounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + } + + /** + * Set the templating of this {@link ModuleResultsBase} instance and return the same instance. + * + * @param templating The templating of this {@link ModuleResultsBase} + * @return The same instance of this {@link ModuleResultsBase} class + */ + @Nonnull + public ModuleResultsBase templating(@Nullable final List templating) { + this.templating = templating; + return this; + } + + /** + * Add one templating instance to this {@link ModuleResultsBase}. + * + * @param templatingItem The templating that should be added + * @return The same instance of type {@link ModuleResultsBase} + */ + @Nonnull + public ModuleResultsBase addTemplatingItem(@Nonnull final ChatMessage templatingItem) { + if (this.templating == null) { + this.templating = new ArrayList<>(); + } + this.templating.add(templatingItem); + return this; + } + + /** + * Get templating + * + * @return templating The templating of this {@link ModuleResultsBase} instance. + */ + @Nonnull + public List getTemplating() { + return templating; + } + + /** + * Set the templating of this {@link ModuleResultsBase} instance. + * + * @param templating The templating of this {@link ModuleResultsBase} + */ + public void setTemplating(@Nullable final List templating) { + this.templating = templating; + } + + /** + * Set the inputTranslation of this {@link ModuleResultsBase} instance and return the same + * instance. + * + * @param inputTranslation The inputTranslation of this {@link ModuleResultsBase} + * @return The same instance of this {@link ModuleResultsBase} class + */ + @Nonnull + public ModuleResultsBase inputTranslation(@Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + return this; + } + + /** + * Get inputTranslation + * + * @return inputTranslation The inputTranslation of this {@link ModuleResultsBase} instance. + */ + @Nonnull + public GenericModuleResult getInputTranslation() { + return inputTranslation; + } + + /** + * Set the inputTranslation of this {@link ModuleResultsBase} instance. + * + * @param inputTranslation The inputTranslation of this {@link ModuleResultsBase} + */ + public void setInputTranslation(@Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + } + + /** + * Set the inputMasking of this {@link ModuleResultsBase} instance and return the same instance. + * + * @param inputMasking The inputMasking of this {@link ModuleResultsBase} + * @return The same instance of this {@link ModuleResultsBase} class + */ + @Nonnull + public ModuleResultsBase inputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + return this; + } + + /** + * Get inputMasking + * + * @return inputMasking The inputMasking of this {@link ModuleResultsBase} instance. + */ + @Nonnull + public GenericModuleResult getInputMasking() { + return inputMasking; + } + + /** + * Set the inputMasking of this {@link ModuleResultsBase} instance. + * + * @param inputMasking The inputMasking of this {@link ModuleResultsBase} + */ + public void setInputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + } + + /** + * Set the inputFiltering of this {@link ModuleResultsBase} instance and return the same instance. + * + * @param inputFiltering The inputFiltering of this {@link ModuleResultsBase} + * @return The same instance of this {@link ModuleResultsBase} class + */ + @Nonnull + public ModuleResultsBase inputFiltering(@Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + return this; + } + + /** + * Get inputFiltering + * + * @return inputFiltering The inputFiltering of this {@link ModuleResultsBase} instance. + */ + @Nonnull + public GenericModuleResult getInputFiltering() { + return inputFiltering; + } + + /** + * Set the inputFiltering of this {@link ModuleResultsBase} instance. + * + * @param inputFiltering The inputFiltering of this {@link ModuleResultsBase} + */ + public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + } + + /** + * Set the outputFiltering of this {@link ModuleResultsBase} instance and return the same + * instance. + * + * @param outputFiltering The outputFiltering of this {@link ModuleResultsBase} + * @return The same instance of this {@link ModuleResultsBase} class + */ + @Nonnull + public ModuleResultsBase outputFiltering(@Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + return this; + } + + /** + * Get outputFiltering + * + * @return outputFiltering The outputFiltering of this {@link ModuleResultsBase} instance. + */ + @Nonnull + public GenericModuleResult getOutputFiltering() { + return outputFiltering; + } + + /** + * Set the outputFiltering of this {@link ModuleResultsBase} instance. + * + * @param outputFiltering The outputFiltering of this {@link ModuleResultsBase} + */ + public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + } + + /** + * Set the outputTranslation of this {@link ModuleResultsBase} instance and return the same + * instance. + * + * @param outputTranslation The outputTranslation of this {@link ModuleResultsBase} + * @return The same instance of this {@link ModuleResultsBase} class + */ + @Nonnull + public ModuleResultsBase outputTranslation( + @Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + return this; + } + + /** + * Get outputTranslation + * + * @return outputTranslation The outputTranslation of this {@link ModuleResultsBase} instance. + */ + @Nonnull + public GenericModuleResult getOutputTranslation() { + return outputTranslation; + } + + /** + * Set the outputTranslation of this {@link ModuleResultsBase} instance. + * + * @param outputTranslation The outputTranslation of this {@link ModuleResultsBase} + */ + public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + } + + /** + * Get the names of the unrecognizable properties of the {@link ModuleResultsBase}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ModuleResultsBase} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("ModuleResultsBase has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ModuleResultsBase} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (grounding != null) declaredFields.put("grounding", grounding); + if (templating != null) declaredFields.put("templating", templating); + if (inputTranslation != null) declaredFields.put("inputTranslation", inputTranslation); + if (inputMasking != null) declaredFields.put("inputMasking", inputMasking); + if (inputFiltering != null) declaredFields.put("inputFiltering", inputFiltering); + if (outputFiltering != null) declaredFields.put("outputFiltering", outputFiltering); + if (outputTranslation != null) declaredFields.put("outputTranslation", outputTranslation); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link ModuleResultsBase} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ModuleResultsBase moduleResultsBase = (ModuleResultsBase) o; + return Objects.equals(this.cloudSdkCustomFields, moduleResultsBase.cloudSdkCustomFields) + && Objects.equals(this.grounding, moduleResultsBase.grounding) + && Objects.equals(this.templating, moduleResultsBase.templating) + && Objects.equals(this.inputTranslation, moduleResultsBase.inputTranslation) + && Objects.equals(this.inputMasking, moduleResultsBase.inputMasking) + && Objects.equals(this.inputFiltering, moduleResultsBase.inputFiltering) + && Objects.equals(this.outputFiltering, moduleResultsBase.outputFiltering) + && Objects.equals(this.outputTranslation, moduleResultsBase.outputTranslation); + } + + @Override + public int hashCode() { + return Objects.hash( + grounding, + templating, + inputTranslation, + inputMasking, + inputFiltering, + outputFiltering, + outputTranslation, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ModuleResultsBase {\n"); + sb.append(" grounding: ").append(toIndentedString(grounding)).append("\n"); + sb.append(" templating: ").append(toIndentedString(templating)).append("\n"); + sb.append(" inputTranslation: ").append(toIndentedString(inputTranslation)).append("\n"); + sb.append(" inputMasking: ").append(toIndentedString(inputMasking)).append("\n"); + sb.append(" inputFiltering: ").append(toIndentedString(inputFiltering)).append("\n"); + sb.append(" outputFiltering: ").append(toIndentedString(outputFiltering)).append("\n"); + sb.append(" outputTranslation: ").append(toIndentedString(outputTranslation)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link ModuleResultsBase} instance. No arguments are required. */ + public static ModuleResultsBase create() { + return new ModuleResultsBase(); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsStreaming.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsStreaming.java new file mode 100644 index 000000000..527b61a90 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsStreaming.java @@ -0,0 +1,522 @@ +/* + * Internal Orchestration Service API + * 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. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Streaming results of each module. */ +// CHECKSTYLE:OFF +public class ModuleResultsStreaming +// CHECKSTYLE:ON +{ + @JsonProperty("grounding") + private GenericModuleResult grounding; + + @JsonProperty("templating") + private List templating = new ArrayList<>(); + + @JsonProperty("input_translation") + private GenericModuleResult inputTranslation; + + @JsonProperty("input_masking") + private GenericModuleResult inputMasking; + + @JsonProperty("input_filtering") + private GenericModuleResult inputFiltering; + + @JsonProperty("output_filtering") + private GenericModuleResult outputFiltering; + + @JsonProperty("output_translation") + private GenericModuleResult outputTranslation; + + @JsonProperty("llm") + private LLMModuleResultStreaming llm; + + @JsonProperty("output_unmasking") + private List outputUnmasking = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ModuleResultsStreaming. */ + protected ModuleResultsStreaming() {} + + /** + * Set the grounding of this {@link ModuleResultsStreaming} instance and return the same instance. + * + * @param grounding The grounding of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming grounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + return this; + } + + /** + * Get grounding + * + * @return grounding The grounding of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public GenericModuleResult getGrounding() { + return grounding; + } + + /** + * Set the grounding of this {@link ModuleResultsStreaming} instance. + * + * @param grounding The grounding of this {@link ModuleResultsStreaming} + */ + public void setGrounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + } + + /** + * Set the templating of this {@link ModuleResultsStreaming} instance and return the same + * instance. + * + * @param templating The templating of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming templating(@Nullable final List templating) { + this.templating = templating; + return this; + } + + /** + * Add one templating instance to this {@link ModuleResultsStreaming}. + * + * @param templatingItem The templating that should be added + * @return The same instance of type {@link ModuleResultsStreaming} + */ + @Nonnull + public ModuleResultsStreaming addTemplatingItem(@Nonnull final ChatMessage templatingItem) { + if (this.templating == null) { + this.templating = new ArrayList<>(); + } + this.templating.add(templatingItem); + return this; + } + + /** + * Get templating + * + * @return templating The templating of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public List getTemplating() { + return templating; + } + + /** + * Set the templating of this {@link ModuleResultsStreaming} instance. + * + * @param templating The templating of this {@link ModuleResultsStreaming} + */ + public void setTemplating(@Nullable final List templating) { + this.templating = templating; + } + + /** + * Set the inputTranslation of this {@link ModuleResultsStreaming} instance and return the same + * instance. + * + * @param inputTranslation The inputTranslation of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming inputTranslation( + @Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + return this; + } + + /** + * Get inputTranslation + * + * @return inputTranslation The inputTranslation of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public GenericModuleResult getInputTranslation() { + return inputTranslation; + } + + /** + * Set the inputTranslation of this {@link ModuleResultsStreaming} instance. + * + * @param inputTranslation The inputTranslation of this {@link ModuleResultsStreaming} + */ + public void setInputTranslation(@Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + } + + /** + * Set the inputMasking of this {@link ModuleResultsStreaming} instance and return the same + * instance. + * + * @param inputMasking The inputMasking of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming inputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + return this; + } + + /** + * Get inputMasking + * + * @return inputMasking The inputMasking of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public GenericModuleResult getInputMasking() { + return inputMasking; + } + + /** + * Set the inputMasking of this {@link ModuleResultsStreaming} instance. + * + * @param inputMasking The inputMasking of this {@link ModuleResultsStreaming} + */ + public void setInputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + } + + /** + * Set the inputFiltering of this {@link ModuleResultsStreaming} instance and return the same + * instance. + * + * @param inputFiltering The inputFiltering of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming inputFiltering(@Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + return this; + } + + /** + * Get inputFiltering + * + * @return inputFiltering The inputFiltering of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public GenericModuleResult getInputFiltering() { + return inputFiltering; + } + + /** + * Set the inputFiltering of this {@link ModuleResultsStreaming} instance. + * + * @param inputFiltering The inputFiltering of this {@link ModuleResultsStreaming} + */ + public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + } + + /** + * Set the outputFiltering of this {@link ModuleResultsStreaming} instance and return the same + * instance. + * + * @param outputFiltering The outputFiltering of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming outputFiltering( + @Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + return this; + } + + /** + * Get outputFiltering + * + * @return outputFiltering The outputFiltering of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public GenericModuleResult getOutputFiltering() { + return outputFiltering; + } + + /** + * Set the outputFiltering of this {@link ModuleResultsStreaming} instance. + * + * @param outputFiltering The outputFiltering of this {@link ModuleResultsStreaming} + */ + public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + } + + /** + * Set the outputTranslation of this {@link ModuleResultsStreaming} instance and return the same + * instance. + * + * @param outputTranslation The outputTranslation of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming outputTranslation( + @Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + return this; + } + + /** + * Get outputTranslation + * + * @return outputTranslation The outputTranslation of this {@link ModuleResultsStreaming} + * instance. + */ + @Nonnull + public GenericModuleResult getOutputTranslation() { + return outputTranslation; + } + + /** + * Set the outputTranslation of this {@link ModuleResultsStreaming} instance. + * + * @param outputTranslation The outputTranslation of this {@link ModuleResultsStreaming} + */ + public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + } + + /** + * Set the llm of this {@link ModuleResultsStreaming} instance and return the same instance. + * + * @param llm The llm of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming llm(@Nullable final LLMModuleResultStreaming llm) { + this.llm = llm; + return this; + } + + /** + * Get llm + * + * @return llm The llm of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public LLMModuleResultStreaming getLlm() { + return llm; + } + + /** + * Set the llm of this {@link ModuleResultsStreaming} instance. + * + * @param llm The llm of this {@link ModuleResultsStreaming} + */ + public void setLlm(@Nullable final LLMModuleResultStreaming llm) { + this.llm = llm; + } + + /** + * Set the outputUnmasking of this {@link ModuleResultsStreaming} instance and return the same + * instance. + * + * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class + */ + @Nonnull + public ModuleResultsStreaming outputUnmasking( + @Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; + return this; + } + + /** + * Add one outputUnmasking instance to this {@link ModuleResultsStreaming}. + * + * @param outputUnmaskingItem The outputUnmasking that should be added + * @return The same instance of type {@link ModuleResultsStreaming} + */ + @Nonnull + public ModuleResultsStreaming addOutputUnmaskingItem( + @Nonnull final LLMChoiceStreaming outputUnmaskingItem) { + if (this.outputUnmasking == null) { + this.outputUnmasking = new ArrayList<>(); + } + this.outputUnmasking.add(outputUnmaskingItem); + return this; + } + + /** + * Get outputUnmasking + * + * @return outputUnmasking The outputUnmasking of this {@link ModuleResultsStreaming} instance. + */ + @Nonnull + public List getOutputUnmasking() { + return outputUnmasking; + } + + /** + * Set the outputUnmasking of this {@link ModuleResultsStreaming} instance. + * + * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsStreaming} + */ + public void setOutputUnmasking(@Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; + } + + /** + * Get the names of the unrecognizable properties of the {@link ModuleResultsStreaming}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ModuleResultsStreaming} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ModuleResultsStreaming has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ModuleResultsStreaming} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (grounding != null) declaredFields.put("grounding", grounding); + if (templating != null) declaredFields.put("templating", templating); + if (inputTranslation != null) declaredFields.put("inputTranslation", inputTranslation); + if (inputMasking != null) declaredFields.put("inputMasking", inputMasking); + if (inputFiltering != null) declaredFields.put("inputFiltering", inputFiltering); + if (outputFiltering != null) declaredFields.put("outputFiltering", outputFiltering); + if (outputTranslation != null) declaredFields.put("outputTranslation", outputTranslation); + if (llm != null) declaredFields.put("llm", llm); + if (outputUnmasking != null) declaredFields.put("outputUnmasking", outputUnmasking); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link ModuleResultsStreaming} instance. If the map + * previously contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ModuleResultsStreaming moduleResultsStreaming = (ModuleResultsStreaming) o; + return Objects.equals(this.cloudSdkCustomFields, moduleResultsStreaming.cloudSdkCustomFields) + && Objects.equals(this.grounding, moduleResultsStreaming.grounding) + && Objects.equals(this.templating, moduleResultsStreaming.templating) + && Objects.equals(this.inputTranslation, moduleResultsStreaming.inputTranslation) + && Objects.equals(this.inputMasking, moduleResultsStreaming.inputMasking) + && Objects.equals(this.inputFiltering, moduleResultsStreaming.inputFiltering) + && Objects.equals(this.outputFiltering, moduleResultsStreaming.outputFiltering) + && Objects.equals(this.outputTranslation, moduleResultsStreaming.outputTranslation) + && Objects.equals(this.llm, moduleResultsStreaming.llm) + && Objects.equals(this.outputUnmasking, moduleResultsStreaming.outputUnmasking); + } + + @Override + public int hashCode() { + return Objects.hash( + grounding, + templating, + inputTranslation, + inputMasking, + inputFiltering, + outputFiltering, + outputTranslation, + llm, + outputUnmasking, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ModuleResultsStreaming {\n"); + sb.append(" grounding: ").append(toIndentedString(grounding)).append("\n"); + sb.append(" templating: ").append(toIndentedString(templating)).append("\n"); + sb.append(" inputTranslation: ").append(toIndentedString(inputTranslation)).append("\n"); + sb.append(" inputMasking: ").append(toIndentedString(inputMasking)).append("\n"); + sb.append(" inputFiltering: ").append(toIndentedString(inputFiltering)).append("\n"); + sb.append(" outputFiltering: ").append(toIndentedString(outputFiltering)).append("\n"); + sb.append(" outputTranslation: ").append(toIndentedString(outputTranslation)).append("\n"); + sb.append(" llm: ").append(toIndentedString(llm)).append("\n"); + sb.append(" outputUnmasking: ").append(toIndentedString(outputUnmasking)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link ModuleResultsStreaming} instance. No arguments are required. */ + public static ModuleResultsStreaming create() { + return new ModuleResultsStreaming(); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsOutputUnmaskingInner.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java similarity index 82% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsOutputUnmaskingInner.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java index 7088e9392..a8565a3f5 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsOutputUnmaskingInner.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java @@ -14,10 +14,10 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -/** ModuleResultsOutputUnmaskingInner */ +/** OutputFilterConfig */ @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({ - @JsonSubTypes.Type(value = LLMChoice.class), - @JsonSubTypes.Type(value = LLMChoiceStreaming.class), + @JsonSubTypes.Type(value = AzureContentSafetyOutputFilterConfig.class), + @JsonSubTypes.Type(value = LlamaGuard38bFilterConfig.class), }) -public interface ModuleResultsOutputUnmaskingInner {} +public interface OutputFilterConfig {} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilteringConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilteringConfig.java index cdf477275..4e4d6a169 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilteringConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilteringConfig.java @@ -32,7 +32,7 @@ public class OutputFilteringConfig // CHECKSTYLE:ON { @JsonProperty("filters") - private List filters = new ArrayList<>(); + private List filters = new ArrayList<>(); @JsonProperty("stream_options") private FilteringStreamOptions streamOptions; @@ -47,11 +47,11 @@ protected OutputFilteringConfig() {} * Set the filters of this {@link OutputFilteringConfig} instance and return the same instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (output filtering). * @return The same instance of this {@link OutputFilteringConfig} class */ @Nonnull - public OutputFilteringConfig filters(@Nonnull final List filters) { + public OutputFilteringConfig filters(@Nonnull final List filters) { this.filters = filters; return this; } @@ -63,7 +63,7 @@ public OutputFilteringConfig filters(@Nonnull final List filters) * @return The same instance of type {@link OutputFilteringConfig} */ @Nonnull - public OutputFilteringConfig addFiltersItem(@Nonnull final FilterConfig filtersItem) { + public OutputFilteringConfig addFiltersItem(@Nonnull final OutputFilterConfig filtersItem) { if (this.filters == null) { this.filters = new ArrayList<>(); } @@ -73,12 +73,12 @@ public OutputFilteringConfig addFiltersItem(@Nonnull final FilterConfig filtersI /** * Configuration for content filtering services that should be used for the given filtering step - * (input filtering or output filtering). + * (output filtering). * * @return filters The filters of this {@link OutputFilteringConfig} instance. */ @Nonnull - public List getFilters() { + public List getFilters() { return filters; } @@ -86,9 +86,9 @@ public List getFilters() { * Set the filters of this {@link OutputFilteringConfig} instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (output filtering). */ - public void setFilters(@Nonnull final List filters) { + public void setFilters(@Nonnull final List filters) { this.filters = filters; } @@ -237,19 +237,19 @@ public interface Builder { * Set the filters of this {@link OutputFilteringConfig} instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (output filtering). * @return The OutputFilteringConfig instance. */ - OutputFilteringConfig filters(@Nonnull final List filters); + OutputFilteringConfig filters(@Nonnull final List filters); /** * Set the filters of this {@link OutputFilteringConfig} instance. * * @param filters Configuration for content filtering services that should be used for the given - * filtering step (input filtering or output filtering). + * filtering step (output filtering). * @return The OutputFilteringConfig instance. */ - default OutputFilteringConfig filters(@Nonnull final FilterConfig... filters) { + default OutputFilteringConfig filters(@Nonnull final OutputFilterConfig... filters) { return filters(Arrays.asList(filters)); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ResponseChatMessage.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ResponseChatMessage.java index 6cba8abdf..5957ef331 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ResponseChatMessage.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ResponseChatMessage.java @@ -111,7 +111,7 @@ protected ResponseChatMessage() {} * @return The same instance of this {@link ResponseChatMessage} class */ @Nonnull - public ResponseChatMessage role(@Nullable final RoleEnum role) { + public ResponseChatMessage role(@Nonnull final RoleEnum role) { this.role = role; return this; } @@ -131,7 +131,7 @@ public RoleEnum getRole() { * * @param role The role of this {@link ResponseChatMessage} */ - public void setRole(@Nullable final RoleEnum role) { + public void setRole(@Nonnull final RoleEnum role) { this.role = role; } @@ -348,8 +348,22 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - /** Create a new {@link ResponseChatMessage} instance. No arguments are required. */ - public static ResponseChatMessage create() { - return new ResponseChatMessage(); + /** + * Create a type-safe, fluent-api builder object to construct a new {@link ResponseChatMessage} + * instance with all required arguments. + */ + public static Builder create() { + return (role) -> new ResponseChatMessage().role(role); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the role of this {@link ResponseChatMessage} instance. + * + * @param role The role of this {@link ResponseChatMessage} + * @return The ResponseChatMessage instance. + */ + ResponseChatMessage role(@Nonnull final RoleEnum role); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TemplateResponseFormat.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TemplateResponseFormat.java index 98094ef78..e4951acb2 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TemplateResponseFormat.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TemplateResponseFormat.java @@ -16,8 +16,7 @@ /** * Response format that the model output should adhere to. This is the same as the OpenAI - * definition. Compatible with GPT-4o, GPT-4o mini, GPT-4 (Turbo) and all GPT-3.5 Turbo models newer - * than gpt-3.5-turbo-1106. + * definition. */ @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({ diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatDelta.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatDelta.java index 504e36aa9..807b5b399 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatDelta.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatDelta.java @@ -2,11 +2,10 @@ import com.google.common.annotations.Beta; import com.sap.ai.sdk.orchestration.OrchestrationChatCompletionDelta; -import com.sap.ai.sdk.orchestration.model.LLMChoice; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMChoiceStreaming; +import com.sap.ai.sdk.orchestration.model.LLMModuleResultStreaming; import com.sap.ai.sdk.orchestration.model.TokenUsage; import java.util.List; -import java.util.Map; import javax.annotation.Nonnull; import lombok.EqualsAndHashCode; import lombok.Value; @@ -30,36 +29,28 @@ public class OrchestrationSpringChatDelta extends ChatResponse { OrchestrationSpringChatDelta(@Nonnull final OrchestrationChatCompletionDelta delta) { super( - toGenerations((LLMModuleResultSynchronous) delta.getOrchestrationResult()), - toChatResponseMetadata((LLMModuleResultSynchronous) delta.getOrchestrationResult())); + toGenerations(delta.getOrchestrationResult()), + toChatResponseMetadata(delta.getOrchestrationResult())); } @Nonnull - static List toGenerations(@Nonnull final LLMModuleResultSynchronous result) { + static List toGenerations(@Nonnull final LLMModuleResultStreaming result) { return result.getChoices().stream().map(OrchestrationSpringChatDelta::toGeneration).toList(); } @Nonnull - static Generation toGeneration(@Nonnull final LLMChoice choice) { + static Generation toGeneration(@Nonnull final LLMChoiceStreaming choice) { val metadata = ChatGenerationMetadata.builder().finishReason(choice.getFinishReason()); metadata.metadata("index", choice.getIndex()); - if (!choice.getLogprobs().isEmpty()) { - metadata.metadata("logprobs", choice.getLogprobs()); + if (choice.getLogprobs() != null) { + metadata.metadata("logprobs", choice.getLogprobs().getContent()); } - return new Generation(new AssistantMessage(getContent(choice)), metadata.build()); - } - - @Nonnull - private static String getContent(@Nonnull final LLMChoice choice) { - return choice.toMap().get("delta") instanceof Map delta - && delta.get("content") instanceof String content - ? content - : ""; + return new Generation(new AssistantMessage(choice.getDelta().getContent()), metadata.build()); } @Nonnull static ChatResponseMetadata toChatResponseMetadata( - @Nonnull final LLMModuleResultSynchronous orchestrationResult) { + @Nonnull final LLMModuleResultStreaming orchestrationResult) { val metadataBuilder = ChatResponseMetadata.builder(); metadataBuilder diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatResponse.java index 66636c471..80c8035f2 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatResponse.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatResponse.java @@ -3,7 +3,7 @@ import com.google.common.annotations.Beta; import com.sap.ai.sdk.orchestration.OrchestrationChatResponse; import com.sap.ai.sdk.orchestration.model.LLMChoice; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMModuleResult; import com.sap.ai.sdk.orchestration.model.TokenUsage; import java.util.List; import java.util.Map; @@ -33,17 +33,14 @@ public class OrchestrationSpringChatResponse extends ChatResponse { OrchestrationSpringChatResponse(@Nonnull final OrchestrationChatResponse orchestrationResponse) { super( - toGenerations( - (LLMModuleResultSynchronous) - orchestrationResponse.getOriginalResponse().getOrchestrationResult()), + toGenerations(orchestrationResponse.getOriginalResponse().getOrchestrationResult()), toChatResponseMetadata( - (LLMModuleResultSynchronous) - orchestrationResponse.getOriginalResponse().getOrchestrationResult())); + orchestrationResponse.getOriginalResponse().getOrchestrationResult())); this.orchestrationResponse = orchestrationResponse; } @Nonnull - static List toGenerations(@Nonnull final LLMModuleResultSynchronous result) { + static List toGenerations(@Nonnull final LLMModuleResult result) { return result.getChoices().stream().map(OrchestrationSpringChatResponse::toGeneration).toList(); } @@ -51,8 +48,8 @@ static List toGenerations(@Nonnull final LLMModuleResultSynchronous static Generation toGeneration(@Nonnull final LLMChoice choice) { val metadata = ChatGenerationMetadata.builder().finishReason(choice.getFinishReason()); metadata.metadata("index", choice.getIndex()); - if (!choice.getLogprobs().isEmpty()) { - metadata.metadata("logprobs", choice.getLogprobs()); + if (choice.getLogprobs() != null) { + metadata.metadata("logprobs", choice.getLogprobs().getContent()); } val toolCalls = choice.getMessage().getToolCalls().stream() @@ -71,7 +68,7 @@ static Generation toGeneration(@Nonnull final LLMChoice choice) { @Nonnull static ChatResponseMetadata toChatResponseMetadata( - @Nonnull final LLMModuleResultSynchronous orchestrationResult) { + @Nonnull final LLMModuleResult orchestrationResult) { val metadataBuilder = ChatResponseMetadata.builder(); metadataBuilder diff --git a/orchestration/src/main/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index 893f7a40f..c4bcd5dcf 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -1,5 +1,9 @@ openapi: 3.0.0 +servers: + - url: "/" + description: Internal Orchestration Service API + x-sap-shortText: "Orchestration provides common capabilities for business AI scenarios, such as content filtering, data masking, and grounding" info: @@ -9,15 +13,12 @@ info: name: SAP AI Core version: 0.0.1 -servers: - - url: "/v1" - tags: - name: OrchestrationCompletion description: Run an orchestrated completion inference request paths: - /completion: + /v1/completion: post: tags: - OrchestrationCompletion @@ -37,11 +38,42 @@ paths: application/json: schema: $ref: "#/components/schemas/CompletionPostResponse" + text/event-stream: + schema: + $ref: "#/components/schemas/CompletionPostResponseStreaming" "400": $ref: "#/components/responses/BadRequest" default: $ref: "#/components/responses/CommonError" + /v2/embeddings: + post: + tags: + - OrchestrationEmbeddings + summary: orchestrated embeddings inference + description: > + Generate embeddings for input strings. + operationId: orchestration.v1.endpoints.create_embeddings + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/EmbeddingsPostRequest" + responses: + "200": + description: "Successful response" + content: + application/json: + schema: + $ref: "#/components/schemas/EmbeddingsPostResponse" + "400": + $ref: "#/components/responses/BadRequest" + default: + $ref: "#/components/responses/CommonError" + + + components: schemas: CompletionPostRequest: @@ -63,20 +95,191 @@ components: allOf: - $ref: "#/components/schemas/ChatMessages" description: History of chat messages. Can be used to provide system and assistant messages to set the context of the conversation. Will be merged with the template message - + + # Embedings Schemas + EmbeddingsPostRequest: + type: object + additionalProperties: false + required: + - input + - config + properties: + config: + $ref: "#/components/schemas/EmbeddingsOrchestrationConfig" + input: + $ref: "#/components/schemas/EmbeddingsInput" + EmbeddingsOrchestrationConfig: + type: object + required: + - modules + additionalProperties: false + properties: + modules: + $ref: "#/components/schemas/EmbeddingsModuleConfigs" + EmbeddingsInput: + type: object + required: + - text + additionalProperties: false + properties: + text: + $ref: "#/components/schemas/EmbeddingsInputText" + type: + type: string + enum: ["text", "document", "query"] + EmbeddingsInputText: + oneOf: + - type: string + description: The string that will be turned into an embedding. + example: Hello World! + - type: array + description: The array of strings that will be turned into an embedding. + minItems: 1 + items: + type: string + minLength: 1 + example: ['Hello', 'World', '!'] + description: Text input for which embeddings need to be generated + example: ["This is an input string.", "This is another input string."] + EmbeddingsModuleConfigs: + type: object + required: + - embeddings + additionalProperties: false + properties: + embeddings: + $ref: "#/components/schemas/EmbeddingsModelConfig" + masking: + $ref: "#/components/schemas/MaskingModuleConfig" + EmbeddingsModelConfig: + type: object + required: + - model + additionalProperties: false + properties: + model: + $ref: "#/components/schemas/EmbeddingsModelDetails" + EmbeddingsModelDetails: + type: object + required: + - name + additionalProperties: false + properties: + name: + type: string + version: + type: string + default: "latest" + params: + $ref: "#/components/schemas/EmbeddingsModelParams" + EmbeddingsModelParams: + type: object + description: Additional parameters for generating input's embeddings. Default values are used for mandatory parameters. + additionalProperties: true + properties: + dimensions: + type: integer + description: > + The number of dimensions the resulting output embeddings should have. + encoding_format: + type: string + enum: [float, base64, binary] + description: > + OpenAI's spec allows for 'float' and 'base64' encoding formats. + normalize: + type: boolean + + EmbeddingsPostResponse: + type: object + additionalProperties: false + required: + - request_id + properties: + request_id: + type: string + intermediate_results: + $ref: "#/components/schemas/ModuleResultsBase" + final_result: + $ref: "#/components/schemas/EmbeddingsResponse" + EmbeddingsResponse: + type: object + description: The response from request to embedding model following OpenAI specification. + additionalProperties: false + required: + - object + - data + - model + - usage + properties: + object: + type: string + description: The object type, which is always "list". + enum: + - list + data: + type: array + description: The list of embeddings generated by the model. + items: + $ref: "#/components/schemas/EmbeddingResult" + model: + type: string + description: The name of the model used to generate the embedding. + usage: + $ref: "#/components/schemas/EmbeddingsUsage" + EmbeddingsUsage: + type: object + description: The usage information for the request. + additionalProperties: false + required: + - prompt_tokens + - total_tokens + properties: + prompt_tokens: + type: integer + description: The number of tokens used by the prompt. + total_tokens: + type: integer + description: The total number of tokens used by the request. + EmbeddingResult: + type: object + description: | + Represents an embedding vector returned by embedding endpoint. + additionalProperties: false + required: + - object + - embedding + - index + properties: + object: + type: string + description: The object type, which is always "embedding". + enum: + - embedding + embedding: + $ref: "#/components/schemas/Embedding" + index: + type: integer + description: The index of the embedding in the list of embeddings. + Embedding: + oneOf: + - type: array + items: + type: number + description: "An array of numbers representing the embedding." + - type: string + description: "A single base64 string representing the embedding." + + # Chat Completion Schemas ChatMessages: type: array items: $ref: "#/components/schemas/ChatMessage" - TemplatingChatMessage: type: array minItems: 1 items: $ref: "#/components/schemas/ChatMessage" - ChatMessage: - type: object oneOf: - $ref: "#/components/schemas/SystemChatMessage" - $ref: "#/components/schemas/UserChatMessage" @@ -131,7 +334,7 @@ components: - user required: - content - - role + - role UserChatMessageContent: oneOf: - type: string @@ -195,13 +398,17 @@ components: required: - role - content + # Below, OpenAI's spec marks 'content' as required but nullable: https://github.com/Azure/azure-rest-api-specs/blob/8279d4aee23a3fef5aac9c76333b0895c83e44c3/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-10-21/inference.yaml#L2121 + # We've made it optional instead to maintain SDK compatibility and avoid breaking changes. + # Functionally achieves the same result as both patterns permit responses without textual content + # OpenAI via null values, ours via field omission. ResponseChatMessage: type: object additionalProperties: false properties: role: type: string - enum: + enum: - assistant content: type: string @@ -209,6 +416,8 @@ components: type: string tool_calls: $ref: "#/components/schemas/MessageToolCalls" + required: + - role # below tool message definitions are copied from openai spec: https://github.com/openai/openai-openapi/blob/e0cb2d721753e13e69e918465795d6e9f87ab15a/openapi.yaml#L11007 # only renaming them to differentiate them from the openai python classes MessageToolCalls: @@ -261,7 +470,6 @@ components: enum: ["text"] text: type: string - ChatDelta: type: object required: @@ -309,7 +517,6 @@ components: calling your function. required: - index - CompletionPostResponse: type: object required: @@ -327,7 +534,6 @@ components: $ref: "#/components/schemas/LLMModuleResult" CompletionPostResponseStreaming: - # TODO: This seems unused in the spec, but used in our endpoints.py, related to Github #778 type: object required: - request_id @@ -336,10 +542,9 @@ components: description: ID of the request type: string module_results: - $ref: "#/components/schemas/ModuleResults" + $ref: "#/components/schemas/ModuleResultsStreaming" orchestration_result: $ref: "#/components/schemas/LLMModuleResultStreaming" - OrchestrationConfig: type: object required: @@ -354,7 +559,6 @@ components: default: false stream_options: $ref: "#/components/schemas/GlobalStreamOptions" - ModuleConfigs: type: object required: @@ -376,9 +580,10 @@ components: $ref: "#/components/schemas/InputTranslationModuleConfig" output_translation_module_config: $ref: "#/components/schemas/OutputTranslationModuleConfig" - - ModuleResults: - description: Results of each module. + # Abstract base class encompassing fields for both `ModuleResults` and `ModuleResultsStreaming` + # Not to be instantiated by llm-orchestration code + ModuleResultsBase: + description: Results of each module of /embeddings endpoint(e.g. input masking). type: object additionalProperties: false properties: @@ -392,19 +597,38 @@ components: $ref: "#/components/schemas/GenericModuleResult" input_filtering: $ref: "#/components/schemas/GenericModuleResult" - llm: - $ref: "#/components/schemas/LLMModuleResult" output_filtering: $ref: "#/components/schemas/GenericModuleResult" - output_unmasking: - type: array - items: - oneOf: - - $ref: "#/components/schemas/LLMChoice" - - $ref: "#/components/schemas/LLMChoiceStreaming" output_translation: $ref: "#/components/schemas/GenericModuleResult" - + ModuleResults: + description: Synchronous results of each module. + type: object + additionalProperties: false + allOf: + - $ref: "#/components/schemas/ModuleResultsBase" + - type: object + properties: + llm: + $ref: "#/components/schemas/LLMModuleResult" + output_unmasking: + type: array + items: + $ref: "#/components/schemas/LLMChoice" + ModuleResultsStreaming: + description: Streaming results of each module. + type: object + additionalProperties: false + allOf: + - $ref: "#/components/schemas/ModuleResultsBase" + - type: object + properties: + llm: + $ref: "#/components/schemas/LLMModuleResultStreaming" + output_unmasking: + type: array + items: + $ref: "#/components/schemas/LLMChoiceStreaming" GlobalStreamOptions: description: Options for streaming. Will be ignored if stream is false. type: object @@ -433,7 +657,7 @@ components: properties: model_name: description: Model name as in LLM Access configuration - example: "gpt-4" + example: "gpt-4o-mini" type: string model_params: # optional, default values are used for mandatory model parameters description: Model parameters @@ -444,6 +668,7 @@ components: frequency_penalty: 0 presence_penalty: 0 n: 2 + logprobs: true stream_options: include_usage: true additionalProperties: true @@ -451,7 +676,6 @@ components: description: Version of the model to use type: string default: "latest" - GenericModuleResult: type: object description: Generic module result @@ -465,14 +689,7 @@ components: data: type: object description: Additional data object from the module - LLMModuleResult: - description: Output of LLM module. Follows the OpenAI spec. - oneOf: - - $ref: "#/components/schemas/LLMModuleResultSynchronous" - - $ref: "#/components/schemas/LLMModuleResultStreaming" - - LLMModuleResultSynchronous: type: object description: Output of LLM module. Follows the OpenAI spec. required: @@ -498,7 +715,7 @@ components: model: type: string description: Model name - example: "gpt-4" + example: "gpt-4o-mini" system_fingerprint: type: string description: System fingerprint @@ -510,7 +727,6 @@ components: $ref: "#/components/schemas/LLMChoice" usage: $ref: "#/components/schemas/TokenUsage" - LLMModuleResultStreaming: type: object description: Output of LLM module. Follows the OpenAI spec. @@ -543,7 +759,6 @@ components: $ref: "#/components/schemas/LLMChoiceStreaming" usage: $ref: "#/components/schemas/TokenUsage" - LLMChoice: type: object required: @@ -558,17 +773,11 @@ components: message: $ref: "#/components/schemas/ResponseChatMessage" logprobs: - type: object - description: Log probabilities - additionalProperties: - type: array - items: - type: number + $ref: '#/components/schemas/ChoiceLogprobs' finish_reason: type: string description: "Reason the model stopped generating tokens. 'stop' if the model hit a natural stop point or a provided stop sequence, 'length' if the maximum token number was reached, 'content_filter' if content was omitted due to a filter enforced by the LLM model provider or the content filtering module" example: stop - LLMChoiceStreaming: type: object required: @@ -581,16 +790,10 @@ components: delta: $ref: "#/components/schemas/ChatDelta" logprobs: - type: object - description: Log probabilities - additionalProperties: - type: array - items: - type: number + $ref: '#/components/schemas/ChoiceLogprobs' finish_reason: type: string description: Reason for stopping the model - TokenUsage: type: object description: Usage of tokens in the response @@ -641,8 +844,6 @@ components: description: > Response format that the model output should adhere to. This is the same as the OpenAI definition. - - Compatible with GPT-4o, GPT-4o mini, GPT-4 (Turbo) and all GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106. oneOf: - $ref: "#/components/schemas/ResponseFormatText" - $ref: "#/components/schemas/ResponseFormatJsonObject" @@ -855,11 +1056,11 @@ components: additionalProperties: false properties: filters: - description: Configuration for content filtering services that should be used for the given filtering step (input filtering or output filtering). + description: Configuration for content filtering services that should be used for the given filtering step (input filtering). type: array minItems: 1 items: - $ref: "#/components/schemas/FilterConfig" + $ref: "#/components/schemas/InputFilterConfig" OutputFilteringConfig: type: object @@ -868,11 +1069,11 @@ components: additionalProperties: false properties: filters: - description: Configuration for content filtering services that should be used for the given filtering step (input filtering or output filtering). + description: Configuration for content filtering services that should be used for the given filtering step (output filtering). type: array minItems: 1 items: - $ref: "#/components/schemas/FilterConfig" + $ref: "#/components/schemas/OutputFilterConfig" stream_options: $ref: "#/components/schemas/FilteringStreamOptions" @@ -888,12 +1089,17 @@ components: minimum: 0 maximum: 10000 - FilterConfig: + InputFilterConfig: oneOf: - - $ref: "#/components/schemas/AzureContentSafetyFilterConfig" + - $ref: "#/components/schemas/AzureContentSafetyInputFilterConfig" - $ref: "#/components/schemas/LlamaGuard38bFilterConfig" - AzureContentSafetyFilterConfig: + OutputFilterConfig: + oneOf: + - $ref: "#/components/schemas/AzureContentSafetyOutputFilterConfig" + - $ref: "#/components/schemas/LlamaGuard38bFilterConfig" + + AzureContentSafetyInputFilterConfig: type: object required: - type @@ -906,9 +1112,42 @@ components: - azure_content_safety example: azure_content_safety config: - $ref: "#/components/schemas/AzureContentSafety" + $ref: "#/components/schemas/AzureContentSafetyInput" + + AzureContentSafetyOutputFilterConfig: + type: object + required: + - type + additionalProperties: false + properties: + type: + description: Name of the filter provider type + type: string + enum: + - azure_content_safety + example: azure_content_safety + config: + $ref: "#/components/schemas/AzureContentSafetyOutput" + + AzureContentSafetyInput: + description: Filter configuration for Azure Content Safety + type: object + additionalProperties: false + properties: + Hate: + $ref: "#/components/schemas/AzureThreshold" + SelfHarm: + $ref: "#/components/schemas/AzureThreshold" + Sexual: + $ref: "#/components/schemas/AzureThreshold" + Violence: + $ref: "#/components/schemas/AzureThreshold" + PromptShield: + type: boolean + description: A flag to use prompt shield + default: false - AzureContentSafety: + AzureContentSafetyOutput: description: Filter configuration for Azure Content Safety type: object additionalProperties: false @@ -1042,15 +1281,67 @@ components: description: controls whether the input to the grounding module will be masked with the configuration supplied in the masking module DPIEntityConfig: + oneOf: + - $ref: "#/components/schemas/DPIStandardEntity" + - $ref: "#/components/schemas/DPICustomEntity" + + DPICustomEntity: + type: object + required: + - regex + - replacement_strategy + additionalProperties: false + properties: + regex: + description: Regular expression to match the entity + type: string + replacement_strategy: + description: Replacement strategy to be used for the entity + oneOf: + - $ref: "#/components/schemas/DPIMethodConstant" + + DPIStandardEntity: type: object required: - type additionalProperties: false properties: type: - description: Type of entity to be masked - allOf: - - $ref: "#/components/schemas/DPIEntities" + $ref: "#/components/schemas/DPIEntities" + replacement_strategy: + description: Replacement strategy to be used for the entity + oneOf: + - $ref: "#/components/schemas/DPIMethodConstant" + - $ref: "#/components/schemas/DPIMethodFabricatedData" + + DPIMethodConstant: + description: Replaces the entity with the specified value followed by an incrementing number + type: object + required: + - method + - value + additionalProperties: false + properties: + method: + type: string + enum: + - constant + value: + description: Value to be used for replacement + example: NAME_REDACTED + type: string + + DPIMethodFabricatedData: + description: Replaces the entity with a randomly generated value appropriate to its type. + type: object + required: + - method + additionalProperties: false + properties: + method: + type: string + enum: + - fabricated_data DPIEntities: description: Default entities supported by data privacy and integration service @@ -1077,6 +1368,7 @@ components: - profile-religious-group - profile-political-group - profile-pronouns-gender + - profile-ethnicity - profile-gender - profile-sexual-orientation - profile-trade-union @@ -1251,11 +1543,9 @@ components: InputTranslationModuleConfig: oneOf: - $ref: "#/components/schemas/SAPDocumentTranslation" - OutputTranslationModuleConfig: oneOf: - $ref: "#/components/schemas/SAPDocumentTranslation" - SAPDocumentTranslation: type: object required: @@ -1301,7 +1591,7 @@ components: example: 400 message: type: string - example: "Model name must be one of ['gpt-4', ...]" + example: "Model name must be one of ['gpt-4o-mini', ...]" location: type: string description: Where the error occurred @@ -1309,6 +1599,89 @@ components: module_results: $ref: "#/components/schemas/ModuleResults" + ErrorResponseStreaming: + type: object + required: + - request_id + - code + - message + - location + properties: + request_id: + type: string + example: "d4a67ea1-2bf9-4df7-8105-d48203ccff76" + code: + type: integer + example: 500 + message: + type: string + example: "Model name must be one of ['gpt-4o-mini', ...]" + location: + type: string + description: Where the error occurred + example: "LLM Module" + module_results: + $ref: "#/components/schemas/ModuleResultsStreaming" + + # ref : https://github.com/openai/openai-python/blob/main/src/openai/types/chat/chat_completion_token_logprob.py + ChatCompletionTokenLogprob: + type: object + required: + - token + - logprob + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token. + bytes: + type: array + items: + type: integer + format: int32 + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are multi-byte. + top_logprobs: + type: array + description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs`. + items: + # This is the schema for the inner object within top_logprobs + type: object + required: + - token + - logprob + properties: + token: + type: string + description: The token. + logprob: + type: number + format: float + description: The log probability of this token. + bytes: + type: array + items: + type: integer + format: int32 + description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are multi-byte. + # ref : https://github.com/openai/openai-python/blob/main/src/openai/types/chat/chat_completion.py + ChoiceLogprobs: + type: object + description: Log probabilities for the choice. + properties: + content: + type: array + items: + $ref: '#/components/schemas/ChatCompletionTokenLogprob' + description: A list of message content tokens with log probability information. + refusal: + type: array + items: + $ref: '#/components/schemas/ChatCompletionTokenLogprob' + description: A list of message refusal tokens with log probability information. + responses: BadRequest: description: Bad Request diff --git a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/LLMModuleResultDeserializerTest.java b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/LLMModuleResultDeserializerTest.java index b05afdedb..bbd9571d9 100644 --- a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/LLMModuleResultDeserializerTest.java +++ b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/LLMModuleResultDeserializerTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import com.sap.ai.sdk.orchestration.model.LLMModuleResult; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; @@ -43,6 +42,6 @@ void testSubtypeResolutionSynchronous() { var json = String.format(JSON, choices); var result = OrchestrationClient.JACKSON.readValue(json, LLMModuleResult.class); - assertThat(result).isExactlyInstanceOf(LLMModuleResultSynchronous.class); + assertThat(result).isExactlyInstanceOf(LLMModuleResult.class); } } diff --git a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfigTest.java b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfigTest.java index 642196dda..79255d199 100644 --- a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfigTest.java +++ b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfigTest.java @@ -11,6 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.sap.ai.sdk.orchestration.model.DPIConfig; import com.sap.ai.sdk.orchestration.model.DPIEntities; +import com.sap.ai.sdk.orchestration.model.DPIStandardEntity; import com.sap.ai.sdk.orchestration.model.DocumentGroundingFilter; import com.sap.ai.sdk.orchestration.model.GroundingModuleConfigConfig; import com.sap.ai.sdk.orchestration.model.GroundingModuleConfigConfigFiltersInner; @@ -87,10 +88,11 @@ void testDpiMaskingConfig() { assertThat(config.getMaskingConfig()).isNotNull(); assertThat(config.getMaskingConfig().getMaskingProviders()).hasSize(1); - DPIConfig dpiConfig = (DPIConfig) config.getMaskingConfig().getMaskingProviders().get(0); + DPIConfig dpiConfig = config.getMaskingConfig().getMaskingProviders().get(0); assertThat(dpiConfig.getMethod()).isEqualTo(DPIConfig.MethodEnum.ANONYMIZATION); assertThat(dpiConfig.getEntities()).hasSize(1); - assertThat(dpiConfig.getEntities().get(0).getType()).isEqualTo(DPIEntities.ADDRESS); + assertThat(((DPIStandardEntity) dpiConfig.getEntities().get(0)).getType()) + .isEqualTo(DPIEntities.ADDRESS); assertThat(dpiConfig.getMaskGroundingInput().isEnabled()).isEqualTo(true); assertThat(dpiConfig.getAllowlist()).containsExactly("Alice"); diff --git a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java index 6c8d86512..7603f6a69 100644 --- a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java +++ b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java @@ -12,6 +12,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.serverError; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.sap.ai.sdk.orchestration.AzureFilterThreshold.ALLOW_SAFE; @@ -37,16 +38,30 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; import com.github.tomakehurst.wiremock.junit5.WireMockTest; import com.github.tomakehurst.wiremock.stubbing.Scenario; +import com.sap.ai.sdk.orchestration.model.ChatDelta; +import com.sap.ai.sdk.orchestration.model.DPIConfig; import com.sap.ai.sdk.orchestration.model.DPIEntities; +import com.sap.ai.sdk.orchestration.model.DPIStandardEntity; import com.sap.ai.sdk.orchestration.model.DataRepositoryType; import com.sap.ai.sdk.orchestration.model.DocumentGroundingFilter; +import com.sap.ai.sdk.orchestration.model.Embedding; +import com.sap.ai.sdk.orchestration.model.EmbeddingsInput; +import com.sap.ai.sdk.orchestration.model.EmbeddingsInputText; +import com.sap.ai.sdk.orchestration.model.EmbeddingsModelConfig; +import com.sap.ai.sdk.orchestration.model.EmbeddingsModelDetails; +import com.sap.ai.sdk.orchestration.model.EmbeddingsModelParams; +import com.sap.ai.sdk.orchestration.model.EmbeddingsModuleConfigs; +import com.sap.ai.sdk.orchestration.model.EmbeddingsOrchestrationConfig; +import com.sap.ai.sdk.orchestration.model.EmbeddingsPostRequest; +import com.sap.ai.sdk.orchestration.model.EmbeddingsPostResponse; +import com.sap.ai.sdk.orchestration.model.EmbeddingsResponse; import com.sap.ai.sdk.orchestration.model.GenericModuleResult; import com.sap.ai.sdk.orchestration.model.GroundingFilterSearchConfiguration; import com.sap.ai.sdk.orchestration.model.GroundingModuleConfig; import com.sap.ai.sdk.orchestration.model.GroundingModuleConfigConfig; import com.sap.ai.sdk.orchestration.model.KeyValueListPair; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; import com.sap.ai.sdk.orchestration.model.LlamaGuard38b; +import com.sap.ai.sdk.orchestration.model.MaskingModuleConfig; import com.sap.ai.sdk.orchestration.model.ResponseFormatText; import com.sap.ai.sdk.orchestration.model.SearchDocumentKeyValueListPair; import com.sap.ai.sdk.orchestration.model.SearchSelectOptionEnum; @@ -58,6 +73,7 @@ import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination; import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; @@ -287,7 +303,7 @@ void testTemplating() throws IOException { .isEqualTo("Orchestration Service funktioniert!"); assertThat(messageList.get(2).role()).isEqualTo("assistant"); - var llm = (LLMModuleResultSynchronous) response.getModuleResults().getLlm(); + var llm = response.getModuleResults().getLlm(); assertThat(llm).isNotNull(); assertThat(llm.getId()).isEqualTo("chatcmpl-9lzPV4kLrXjFckOp2yY454wksWBoj"); assertThat(llm.getObject()).isEqualTo("chat.completion"); @@ -303,7 +319,7 @@ void testTemplating() throws IOException { assertThat(usage.getCompletionTokens()).isEqualTo(7); assertThat(usage.getPromptTokens()).isEqualTo(19); assertThat(usage.getTotalTokens()).isEqualTo(26); - var orchestrationResult = (LLMModuleResultSynchronous) response.getOrchestrationResult(); + var orchestrationResult = response.getOrchestrationResult(); assertThat(orchestrationResult.getId()).isEqualTo("chatcmpl-9lzPV4kLrXjFckOp2yY454wksWBoj"); assertThat(orchestrationResult.getObject()).isEqualTo("chat.completion"); assertThat(orchestrationResult.getCreated()).isEqualTo(1721224505); @@ -688,9 +704,9 @@ void streamChatCompletionDeltas() throws IOException { assertThat(deltaList.get(2).getFinishReason()).isEqualTo("stop"); // should be of type LLMModuleResultStreaming, will be fixed with a discriminator - var result0 = (LLMModuleResultSynchronous) deltaList.get(0).getOrchestrationResult(); - var result1 = (LLMModuleResultSynchronous) deltaList.get(1).getOrchestrationResult(); - var result2 = (LLMModuleResultSynchronous) deltaList.get(2).getOrchestrationResult(); + var result0 = deltaList.get(0).getOrchestrationResult(); + var result1 = deltaList.get(1).getOrchestrationResult(); + var result2 = deltaList.get(2).getOrchestrationResult(); assertThat(result0.getSystemFingerprint()).isEmpty(); assertThat(result0.getId()).isEmpty(); @@ -705,9 +721,9 @@ void streamChatCompletionDeltas() throws IOException { assertThat(choices0.getFinishReason()).isEmpty(); assertThat(choices0.toMap().get("delta")).isNotNull(); // this should be getDelta(), only when the result is of type LLMModuleResultStreaming - final var message0 = (Map) choices0.toMap().get("delta"); - assertThat(message0.get("role")).isEqualTo(""); - assertThat(message0.get("content")).isEqualTo(""); + final ChatDelta message0 = choices0.getDelta(); + assertThat(message0.getRole()).isEqualTo(""); + assertThat(message0.getContent()).isEqualTo(""); final var templating = deltaList.get(0).getModuleResults().getTemplating(); assertThat(templating).hasSize(1); @@ -727,9 +743,9 @@ void streamChatCompletionDeltas() throws IOException { assertThat(choices1.getIndex()).isEqualTo(0); assertThat(choices1.getFinishReason()).isEmpty(); assertThat(choices1.toMap().get("delta")).isNotNull(); - final var message1 = (Map) choices1.toMap().get("delta"); - assertThat(message1.get("role")).isEqualTo("assistant"); - assertThat(message1.get("content")).isEqualTo("Sure"); + final ChatDelta message1 = choices1.getDelta(); + assertThat(message1.getRole()).isEqualTo("assistant"); + assertThat(message1.getContent()).isEqualTo("Sure"); assertThat(result2.getSystemFingerprint()).isEqualTo("fp_808245b034"); assertThat(result2.getId()).isEqualTo("chatcmpl-AYZSQQwWv7ajJsyDBpMG4X01BBJxq"); @@ -743,9 +759,9 @@ void streamChatCompletionDeltas() throws IOException { assertThat(choices2.getFinishReason()).isEqualTo("stop"); // this should be getDelta(), only when the result is of type LLMModuleResultStreaming assertThat(choices2.toMap().get("delta")).isNotNull(); - final var message2 = (Map) choices2.toMap().get("delta"); - assertThat(message2.get("role")).isEqualTo("assistant"); - assertThat(message2.get("content")).isEqualTo("!"); + final ChatDelta message2 = choices2.getDelta(); + assertThat(message2.getRole()).isEqualTo("assistant"); + assertThat(message2.getContent()).isEqualTo("!"); } Mockito.verify(inputStream, times(1)).close(); } @@ -809,7 +825,7 @@ void testMultiMessage() throws IOException { "Well, this image features the logo of SAP, a software company, set against a gradient blue background transitioning from light to dark. The main color in the image is blue."); assertThat(response).isNotNull(); - var llmResults = (LLMModuleResultSynchronous) response.getModuleResults().getLlm(); + var llmResults = response.getModuleResults().getLlm(); assertThat(llmResults).isNotNull(); assertThat(llmResults.getChoices()).hasSize(1); assertThat(llmResults.getChoices().get(0).getMessage().getContent()) @@ -817,7 +833,7 @@ void testMultiMessage() throws IOException { "Well, this image features the logo of SAP, a software company, set against a gradient blue background transitioning from light to dark. The main color in the image is blue."); assertThat(llmResults.getChoices().get(0).getFinishReason()).isEqualTo("stop"); assertThat(llmResults.getChoices().get(0).getMessage().getRole()).isEqualTo(ASSISTANT); - var orchestrationResult = (LLMModuleResultSynchronous) response.getOrchestrationResult(); + var orchestrationResult = response.getOrchestrationResult(); assertThat(orchestrationResult.getChoices()).hasSize(1); assertThat(orchestrationResult.getChoices().get(0).getMessage().getContent()) .isEqualTo( @@ -1112,4 +1128,154 @@ void testGetAllMessages() { assertThat(messageListTools.get(1)).isInstanceOf(AssistantMessage.class); assertThat(messageListTools.get(2)).isInstanceOf(ToolMessage.class); } + + @Test + void testEmbeddingCallWithMasking() { + + stubFor( + post(urlEqualTo("/v2/embeddings")) + .willReturn( + aResponse() + .withStatus(200) + .withBody( + """ + { + "request_id": "2ee98443-e1ee-9503-b800-e38b5b80fe45", + "intermediate_results": { + "input_masking": { + "message": "Embedding input is masked successfully.", + "data": { + "masked_input": "['Hello', 'MASKED_PERSON', '!']" + } + } + }, + "final_result": { + "object": "list", + "data": [ + { + "object": "embedding", + "embedding": [ + 0.43988228, + -0.82985526, + -0.15936942, + 0.041005015, + 0.30127057 + ], + "index": 0 + } + ], + "model": "text-embedding-3-large", + "usage": { + "prompt_tokens": 10, + "total_tokens": 10 + } + } + } + """))); + + val dpiConfig = + DPIConfig.create() + .type(DPIConfig.TypeEnum.SAP_DATA_PRIVACY_INTEGRATION) + .method(DPIConfig.MethodEnum.ANONYMIZATION) + .entities(List.of(DPIStandardEntity.create().type(DPIEntities.PERSON))); + val maskingConfig = MaskingModuleConfig.create().maskingProviders(List.of(dpiConfig)); + + val modelParams = + EmbeddingsModelParams.create() + .encodingFormat(EmbeddingsModelParams.EncodingFormatEnum.FLOAT) + .dimensions(5) + .normalize(false); + val modelConfig = + EmbeddingsModelConfig.create() + .model( + EmbeddingsModelDetails.create().name("text-embedding-3-large").params(modelParams)); + + val orchestrationConfig = + EmbeddingsOrchestrationConfig.create() + .modules( + EmbeddingsModuleConfigs.create().embeddings(modelConfig).masking(maskingConfig)); + + val inputText = + EmbeddingsInput.create().text(EmbeddingsInputText.create("['Hello', 'Müller', '!']")); + + val request = EmbeddingsPostRequest.create().config(orchestrationConfig).input(inputText); + + EmbeddingsPostResponse response = client.embed(request); + + assertThat(response).isNotNull(); + assertThat(response.getRequestId()).isEqualTo("2ee98443-e1ee-9503-b800-e38b5b80fe45"); + + val orchestrationResult = response.getFinalResult(); + assertThat(orchestrationResult).isNotNull(); + assertThat(orchestrationResult.getObject()).isEqualTo(EmbeddingsResponse.ObjectEnum.LIST); + assertThat(orchestrationResult.getModel()).isEqualTo("text-embedding-3-large"); + + val data = orchestrationResult.getData(); + assertThat(data).isNotEmpty(); + assertThat(data.get(0).getEmbedding()) + .isEqualTo( + Embedding.create( + List.of( + BigDecimal.valueOf(0.43988228), + BigDecimal.valueOf(-0.82985526), + BigDecimal.valueOf(-0.15936942), + BigDecimal.valueOf(0.041005015), + BigDecimal.valueOf(0.30127057)))); + assertThat(data.get(0).getIndex()).isZero(); + + val usage = orchestrationResult.getUsage(); + assertThat(usage).isNotNull(); + assertThat(usage.getPromptTokens()).isEqualTo(10); + assertThat(usage.getTotalTokens()).isEqualTo(10); + + val moduleResults = response.getIntermediateResults(); + assertThat(moduleResults).isNotNull(); + assertThat(moduleResults.getInputMasking()).isNotNull(); + assertThat(moduleResults.getInputMasking().getMessage()) + .isEqualTo("Embedding input is masked successfully."); + assertThat(moduleResults.getInputMasking().getData()).isNotNull(); + assertThat(moduleResults.getInputMasking().getData()) + .isEqualTo(Map.of("masked_input", "['Hello', 'MASKED_PERSON', '!']")); + + verify( + postRequestedFor(urlEqualTo("/v2/embeddings")) + .withRequestBody( + equalToJson( + """ + { + "config": { + "modules": { + "embeddings": { + "model": { + "name": "text-embedding-3-large", + "version": "latest", + "params": { + "encoding_format": "float", + "dimensions": 5, + "normalize": false + } + } + }, + "masking": { + "masking_providers": [ + { + "type": "sap_data_privacy_integration", + "method": "anonymization", + "entities": [ + { + "type": "profile-person" + } + ], + "allowlist" : [ ] + } + ] + } + } + }, + "input": { + "text": "['Hello', 'Müller', '!']" + } + } + """))); + } } diff --git a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatDeltaTest.java b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatDeltaTest.java index 5c2e62968..ace029d88 100644 --- a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatDeltaTest.java +++ b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatDeltaTest.java @@ -2,12 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.sap.ai.sdk.orchestration.model.LLMChoice; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; -import com.sap.ai.sdk.orchestration.model.ResponseChatMessage; +import com.sap.ai.sdk.orchestration.model.ChatDelta; +import com.sap.ai.sdk.orchestration.model.LLMChoiceStreaming; +import com.sap.ai.sdk.orchestration.model.LLMModuleResultStreaming; import com.sap.ai.sdk.orchestration.model.TokenUsage; import java.util.List; -import java.util.Map; import org.junit.jupiter.api.Test; import org.springframework.ai.chat.metadata.EmptyUsage; import org.springframework.ai.chat.model.Generation; @@ -17,15 +16,10 @@ class OrchestrationChatDeltaTest { @Test void testToGeneration() { var choice = - LLMChoice.create() + LLMChoiceStreaming.create() .index(0) - .message( - ResponseChatMessage.create() - .role(ResponseChatMessage.RoleEnum.UNKNOWN_DEFAULT_OPEN_API) - .content("wrong")) + .delta(ChatDelta.create().content("Hello, world!").role("")) .finishReason("stop"); - // this will be fixed once the spec is fixed - choice.setCustomField("delta", Map.of("content", "Hello, world!")); Generation generation = OrchestrationSpringChatDelta.toGeneration(choice); @@ -37,7 +31,7 @@ void testToGeneration() { @Test void testToChatResponseMetadata() { var moduleResult = - LLMModuleResultSynchronous.create() + LLMModuleResultStreaming.create() .id("test-id") ._object("test-object") .created(123456789) diff --git a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatResponseTest.java b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatResponseTest.java index d47e40a8d..55d9e40a2 100644 --- a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatResponseTest.java +++ b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatResponseTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.sap.ai.sdk.orchestration.model.LLMChoice; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMModuleResult; import com.sap.ai.sdk.orchestration.model.ResponseChatMessage; import com.sap.ai.sdk.orchestration.model.TokenUsage; import java.util.List; @@ -33,7 +33,7 @@ void testToGeneration() { @Test void testToChatResponseMetadata() { var moduleResult = - LLMModuleResultSynchronous.create() + LLMModuleResult.create() .id("test-id") ._object("test-object") .created(123456789) diff --git a/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java index 7504b5b15..675cb2283 100644 --- a/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java +++ b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java @@ -166,7 +166,12 @@ public OrchestrationChatResponse inputFiltering(@Nonnull final AzureFilterThresh new OrchestrationPrompt( "Please rephrase the following sentence for me: 'We shall spill blood tonight', said the operator in-charge."); val filterConfig = - new AzureContentFilter().hate(policy).selfHarm(policy).sexual(policy).violence(policy); + new AzureContentFilter() + .hate(policy) + .selfHarm(policy) + .sexual(policy) + .violence(policy) + .promptShield(true); val configWithFilter = config.withInputFiltering(filterConfig); diff --git a/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OrchestrationTest.java b/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OrchestrationTest.java index 5d29f1cf8..e79da52ec 100644 --- a/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OrchestrationTest.java +++ b/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OrchestrationTest.java @@ -18,11 +18,8 @@ import com.sap.ai.sdk.orchestration.OrchestrationPrompt; import com.sap.ai.sdk.orchestration.TemplateConfig; import com.sap.ai.sdk.orchestration.TextItem; -import com.sap.ai.sdk.orchestration.model.CompletionPostResponse; import com.sap.ai.sdk.orchestration.model.DPIEntities; import com.sap.ai.sdk.orchestration.model.GenericModuleResult; -import com.sap.ai.sdk.orchestration.model.LLMChoice; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -92,7 +89,7 @@ void testTemplate() { assertThat(((TextItem) result.getAllMessages().get(0).content().items().get(0)).text()) .isEqualTo("Reply with 'Orchestration Service is working!' in German"); assertThat(result.getAllMessages().get(0).role()).isEqualTo("user"); - var llm = (LLMModuleResultSynchronous) response.getModuleResults().getLlm(); + var llm = response.getModuleResults().getLlm(); assertThat(llm.getId()).isEmpty(); assertThat(llm.getObject()).isEqualTo("chat.completion"); assertThat(llm.getCreated()).isGreaterThan(1); @@ -107,7 +104,7 @@ void testTemplate() { assertThat(usage.getPromptTokens()).isGreaterThan(1); assertThat(usage.getTotalTokens()).isGreaterThan(1); - var orchestrationResult = ((LLMModuleResultSynchronous) response.getOrchestrationResult()); + var orchestrationResult = (response.getOrchestrationResult()); assertThat(orchestrationResult.getObject()).isEqualTo("chat.completion"); assertThat(orchestrationResult.getCreated()).isGreaterThan(1); assertThat(orchestrationResult.getModel()).isEqualTo(modelName); @@ -125,10 +122,7 @@ void testTemplate() { @Test void testMessagesHistory() { - CompletionPostResponse result = - service.messagesHistory("What is the capital of France?").getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); - assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); + assertThat(service.messagesHistory("What is the capital of France?").getContent()).isNotEmpty(); } @SuppressWarnings("unchecked") @@ -136,8 +130,7 @@ void testMessagesHistory() { void testMaskingAnonymization() { var response = service.maskingAnonymization(DPIEntities.PERSON); var result = response.getOriginalResponse(); - var llmChoice = - ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices().get(0); + var llmChoice = (result.getOrchestrationResult()).getChoices().get(0); assertThat(llmChoice.getFinishReason()).isEqualTo("stop"); var maskingResult = result.getModuleResults().getInputMasking(); @@ -156,8 +149,7 @@ void testMaskingAnonymization() { void testMaskingPseudonymization() { var response = service.maskingPseudonymization(DPIEntities.PERSON); var result = response.getOriginalResponse(); - var llmChoice = - ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices().get(0); + var llmChoice = (result.getOrchestrationResult()).getChoices().get(0); assertThat(llmChoice.getFinishReason()).isEqualTo("stop"); assertThat(llmChoice.getMessage().getContent()) .describedAs("The final response should contain the original user name") @@ -174,7 +166,7 @@ void testMaskingPseudonymization() { var unmaskingResult = result.getModuleResults().getOutputUnmasking(); assertThat(unmaskingResult).isNotEmpty(); - assertThat(((LLMChoice) unmaskingResult.get(0)).getMessage().getContent()) + assertThat(unmaskingResult.get(0).getMessage().getContent()) .describedAs("The unmasking step should replace the pseudonyms used by the LLM") .doesNotContain("MASKED_PERSON") .contains("Mallory"); @@ -186,8 +178,7 @@ void testGrounding() { assertThat(System.getProperty("aicore.landscape")).isNotEqualTo("production"); var response = service.grounding("What does Joule do?", true); var result = response.getOriginalResponse(); - var llmChoice = - ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices().get(0); + var llmChoice = (result.getOrchestrationResult()).getChoices().get(0); assertThat(response).isNotNull(); assertThat(llmChoice.getFinishReason()).isEqualTo("stop"); assertThat(result.getModuleResults().getGrounding()).isNotNull(); @@ -205,8 +196,7 @@ void testGroundingSharepoint() { var response = service.groundingSharepoint("What is the secret for the AI SDK e2e test?"); assertThat(response).isNotNull(); var result = response.getOriginalResponse(); - var llmChoice = - ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices().get(0); + var llmChoice = result.getOrchestrationResult().getChoices().get(0); assertThat(llmChoice.getMessage().getContent()).contains("&)UPnkL_izT)&1u%?2Kg*Y.@qFqR@/"); } @@ -214,8 +204,7 @@ void testGroundingSharepoint() { void testCompletionWithResourceGroup() { var response = service.completionWithResourceGroup("ai-sdk-java-e2e", "Hello world!"); var result = response.getOriginalResponse(); - var llmChoice = - ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices().get(0); + var llmChoice = (result.getOrchestrationResult()).getChoices().get(0); assertThat(llmChoice.getFinishReason()).isEqualTo("stop"); assertThat(llmChoice.getMessage().getContent()).isNotEmpty(); } @@ -294,7 +283,7 @@ void testImageInput() { .imageInput( "https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/SAP_2011_logo.svg/440px-SAP_2011_logo.svg.png") .getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); } @@ -313,7 +302,7 @@ void testImageInputBase64() { System.out.println("Error fetching or reading the image from URL: " + e.getMessage()); } val result = service.imageInput(dataUrl).getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); } @@ -324,7 +313,7 @@ void testMultiStringInput() { .multiStringInput( List.of("What is the capital of France?", "What is Chess about?", "What is 2+2?")) .getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); } @@ -339,7 +328,7 @@ void testResponseFormatJsonSchema() { @Test void testResponseFormatJsonObject() { val result = service.responseFormatJsonObject("apple").getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); assertThat(choices.get(0).getMessage().getContent()).contains("\"language\":"); assertThat(choices.get(0).getMessage().getContent()).contains("\"translation\":"); @@ -348,14 +337,14 @@ void testResponseFormatJsonObject() { @Test void testResponseFormatText() { val result = service.responseFormatText("apple").getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); } @Test void testTemplateFromPromptRegistryById() { val result = service.templateFromPromptRegistryById("Cloud ERP systems").getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); } @@ -363,7 +352,7 @@ void testTemplateFromPromptRegistryById() { void testTemplateFromPromptRegistryByScenario() { val result = service.templateFromPromptRegistryByScenario("Cloud ERP systems").getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); } @@ -374,7 +363,7 @@ void testLocalPromptTemplate() throws IOException { .localPromptTemplate( Files.readString(Path.of("src/main/resources/promptTemplateExample.yaml"))) .getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); }