From b36c9d4ee451fec62f7a63f954b926e1d6da175e Mon Sep 17 00:00:00 2001 From: SAP Cloud SDK Bot Date: Mon, 26 May 2025 11:10:57 +0000 Subject: [PATCH 01/12] Update orchestration based on fix/streaming-response-type --- .../CompletionPostResponseStreaming.java | 8 +- ...=> CompletionPostResponseSynchronous.java} | 132 +++-- .../sdk/orchestration/model/DPIEntities.java | 2 + .../orchestration/model/DPIEntityConfig.java | 176 +----- .../model/DPIMethodConstant.java | 288 ++++++++++ .../model/DPIMethodFabricatedData.java | 241 ++++++++ .../model/DPIStandardEntity.java | 226 ++++++++ .../DPIStandardEntityReplacementStrategy.java | 23 + .../orchestration/model/ErrorResponse.java | 8 +- .../model/ErrorResponseModuleResults.java | 531 ++++++++++++++++++ ...> ErrorResponseModuleResultsAllOfLlm.java} | 4 +- ...duleResultsAllOfOutputUnmaskingInner.java} | 6 +- .../model/LLMChoiceStreaming.java | 2 +- ...MChoice.java => LLMChoiceSynchronous.java} | 110 ++-- .../model/LLMModuleResultStreaming.java | 2 +- .../model/LLMModuleResultSynchronous.java | 17 +- .../model/ModuleResultsBase.java | 421 ++++++++++++++ ...sults.java => ModuleResultsStreaming.java} | 291 +++++----- .../model/ModuleResultsSynchronous.java | 525 +++++++++++++++++ .../model/ResponseChatMessage.java | 24 +- .../main/resources/spec/orchestration.yaml | 150 +++-- 21 files changed, 2690 insertions(+), 497 deletions(-) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{CompletionPostResponse.java => CompletionPostResponseSynchronous.java} (68%) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodConstant.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIMethodFabricatedData.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntity.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntityReplacementStrategy.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{LLMModuleResult.java => ErrorResponseModuleResultsAllOfLlm.java} (91%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{ModuleResultsOutputUnmaskingInner.java => ErrorResponseModuleResultsAllOfOutputUnmaskingInner.java} (84%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{LLMChoice.java => LLMChoiceSynchronous.java} (69%) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsBase.java rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{ModuleResults.java => ModuleResultsStreaming.java} (63%) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsSynchronous.java 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/CompletionPostResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseSynchronous.java similarity index 68% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponse.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseSynchronous.java index 245223966..ef3fd2789 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponse.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseSynchronous.java @@ -23,34 +23,35 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** CompletionPostResponse */ +/** CompletionPostResponseSynchronous */ // CHECKSTYLE:OFF -public class CompletionPostResponse +public class CompletionPostResponseSynchronous // CHECKSTYLE:ON { @JsonProperty("request_id") private String requestId; @JsonProperty("module_results") - private ModuleResults moduleResults; + private ModuleResultsSynchronous moduleResults; @JsonProperty("orchestration_result") - private LLMModuleResult orchestrationResult; + private LLMModuleResultSynchronous orchestrationResult; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for CompletionPostResponse. */ - protected CompletionPostResponse() {} + /** Default constructor for CompletionPostResponseSynchronous. */ + protected CompletionPostResponseSynchronous() {} /** - * Set the requestId of this {@link CompletionPostResponse} instance and return the same instance. + * Set the requestId of this {@link CompletionPostResponseSynchronous} instance and return the + * same instance. * * @param requestId ID of the request - * @return The same instance of this {@link CompletionPostResponse} class + * @return The same instance of this {@link CompletionPostResponseSynchronous} class */ @Nonnull - public CompletionPostResponse requestId(@Nonnull final String requestId) { + public CompletionPostResponseSynchronous requestId(@Nonnull final String requestId) { this.requestId = requestId; return this; } @@ -58,7 +59,7 @@ public CompletionPostResponse requestId(@Nonnull final String requestId) { /** * ID of the request * - * @return requestId The requestId of this {@link CompletionPostResponse} instance. + * @return requestId The requestId of this {@link CompletionPostResponseSynchronous} instance. */ @Nonnull public String getRequestId() { @@ -66,7 +67,7 @@ public String getRequestId() { } /** - * Set the requestId of this {@link CompletionPostResponse} instance. + * Set the requestId of this {@link CompletionPostResponseSynchronous} instance. * * @param requestId ID of the request */ @@ -75,14 +76,15 @@ public void setRequestId(@Nonnull final String requestId) { } /** - * Set the moduleResults of this {@link CompletionPostResponse} instance and return the same - * instance. + * Set the moduleResults of this {@link CompletionPostResponseSynchronous} instance and return the + * same instance. * - * @param moduleResults The moduleResults of this {@link CompletionPostResponse} - * @return The same instance of this {@link CompletionPostResponse} class + * @param moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} + * @return The same instance of this {@link CompletionPostResponseSynchronous} class */ @Nonnull - public CompletionPostResponse moduleResults(@Nonnull final ModuleResults moduleResults) { + public CompletionPostResponseSynchronous moduleResults( + @Nonnull final ModuleResultsSynchronous moduleResults) { this.moduleResults = moduleResults; return this; } @@ -90,32 +92,34 @@ public CompletionPostResponse moduleResults(@Nonnull final ModuleResults moduleR /** * Get moduleResults * - * @return moduleResults The moduleResults of this {@link CompletionPostResponse} instance. + * @return moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} + * instance. */ @Nonnull - public ModuleResults getModuleResults() { + public ModuleResultsSynchronous getModuleResults() { return moduleResults; } /** - * Set the moduleResults of this {@link CompletionPostResponse} instance. + * Set the moduleResults of this {@link CompletionPostResponseSynchronous} instance. * - * @param moduleResults The moduleResults of this {@link CompletionPostResponse} + * @param moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} */ - public void setModuleResults(@Nonnull final ModuleResults moduleResults) { + public void setModuleResults(@Nonnull final ModuleResultsSynchronous moduleResults) { this.moduleResults = moduleResults; } /** - * Set the orchestrationResult of this {@link CompletionPostResponse} instance and return the same - * instance. + * Set the orchestrationResult of this {@link CompletionPostResponseSynchronous} instance and + * return the same instance. * - * @param orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} - * @return The same instance of this {@link CompletionPostResponse} class + * @param orchestrationResult The orchestrationResult of this {@link + * CompletionPostResponseSynchronous} + * @return The same instance of this {@link CompletionPostResponseSynchronous} class */ @Nonnull - public CompletionPostResponse orchestrationResult( - @Nonnull final LLMModuleResult orchestrationResult) { + public CompletionPostResponseSynchronous orchestrationResult( + @Nonnull final LLMModuleResultSynchronous orchestrationResult) { this.orchestrationResult = orchestrationResult; return this; } @@ -123,25 +127,28 @@ public CompletionPostResponse orchestrationResult( /** * Get orchestrationResult * - * @return orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} - * instance. + * @return orchestrationResult The orchestrationResult of this {@link + * CompletionPostResponseSynchronous} instance. */ @Nonnull - public LLMModuleResult getOrchestrationResult() { + public LLMModuleResultSynchronous getOrchestrationResult() { return orchestrationResult; } /** - * Set the orchestrationResult of this {@link CompletionPostResponse} instance. + * Set the orchestrationResult of this {@link CompletionPostResponseSynchronous} instance. * - * @param orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} + * @param orchestrationResult The orchestrationResult of this {@link + * CompletionPostResponseSynchronous} */ - public void setOrchestrationResult(@Nonnull final LLMModuleResult orchestrationResult) { + public void setOrchestrationResult( + @Nonnull final LLMModuleResultSynchronous orchestrationResult) { this.orchestrationResult = orchestrationResult; } /** - * Get the names of the unrecognizable properties of the {@link CompletionPostResponse}. + * Get the names of the unrecognizable properties of the {@link + * CompletionPostResponseSynchronous}. * * @return The set of properties names */ @@ -152,7 +159,8 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link CompletionPostResponse} instance. + * Get the value of an unrecognizable property of this {@link CompletionPostResponseSynchronous} + * instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -164,14 +172,14 @@ public Set getCustomFieldNames() { public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { throw new NoSuchElementException( - "CompletionPostResponse has no field with name '" + name + "'."); + "CompletionPostResponseSynchronous has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link CompletionPostResponse} instance including - * unrecognized properties. + * Get the value of all properties of this {@link CompletionPostResponseSynchronous} instance + * including unrecognized properties. * * @return The map of all properties */ @@ -186,8 +194,9 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link CompletionPostResponse} instance. If the map - * previously contained a mapping for the key, the old value is replaced by the specified value. + * Set an unrecognizable property of this {@link CompletionPostResponseSynchronous} 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 @@ -205,11 +214,14 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final CompletionPostResponse completionPostResponse = (CompletionPostResponse) o; - return Objects.equals(this.cloudSdkCustomFields, completionPostResponse.cloudSdkCustomFields) - && Objects.equals(this.requestId, completionPostResponse.requestId) - && Objects.equals(this.moduleResults, completionPostResponse.moduleResults) - && Objects.equals(this.orchestrationResult, completionPostResponse.orchestrationResult); + final CompletionPostResponseSynchronous completionPostResponseSynchronous = + (CompletionPostResponseSynchronous) o; + return Objects.equals( + this.cloudSdkCustomFields, completionPostResponseSynchronous.cloudSdkCustomFields) + && Objects.equals(this.requestId, completionPostResponseSynchronous.requestId) + && Objects.equals(this.moduleResults, completionPostResponseSynchronous.moduleResults) + && Objects.equals( + this.orchestrationResult, completionPostResponseSynchronous.orchestrationResult); } @Override @@ -221,7 +233,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class CompletionPostResponse {\n"); + sb.append("class CompletionPostResponseSynchronous {\n"); sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); sb.append(" moduleResults: ").append(toIndentedString(moduleResults)).append("\n"); sb.append(" orchestrationResult: ") @@ -245,14 +257,14 @@ private String toIndentedString(final java.lang.Object o) { } /** - * Create a type-safe, fluent-api builder object to construct a new {@link CompletionPostResponse} - * instance with all required arguments. + * Create a type-safe, fluent-api builder object to construct a new {@link + * CompletionPostResponseSynchronous} instance with all required arguments. */ public static Builder create() { return (requestId) -> (moduleResults) -> (orchestrationResult) -> - new CompletionPostResponse() + new CompletionPostResponseSynchronous() .requestId(requestId) .moduleResults(moduleResults) .orchestrationResult(orchestrationResult); @@ -261,10 +273,10 @@ public static Builder create() { /** Builder helper class. */ public interface Builder { /** - * Set the requestId of this {@link CompletionPostResponse} instance. + * Set the requestId of this {@link CompletionPostResponseSynchronous} instance. * * @param requestId ID of the request - * @return The CompletionPostResponse builder. + * @return The CompletionPostResponseSynchronous builder. */ Builder1 requestId(@Nonnull final String requestId); } @@ -272,22 +284,24 @@ public interface Builder { /** Builder helper class. */ public interface Builder1 { /** - * Set the moduleResults of this {@link CompletionPostResponse} instance. + * Set the moduleResults of this {@link CompletionPostResponseSynchronous} instance. * - * @param moduleResults The moduleResults of this {@link CompletionPostResponse} - * @return The CompletionPostResponse builder. + * @param moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} + * @return The CompletionPostResponseSynchronous builder. */ - Builder2 moduleResults(@Nonnull final ModuleResults moduleResults); + Builder2 moduleResults(@Nonnull final ModuleResultsSynchronous moduleResults); } /** Builder helper class. */ public interface Builder2 { /** - * Set the orchestrationResult of this {@link CompletionPostResponse} instance. + * Set the orchestrationResult of this {@link CompletionPostResponseSynchronous} instance. * - * @param orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} - * @return The CompletionPostResponse instance. + * @param orchestrationResult The orchestrationResult of this {@link + * CompletionPostResponseSynchronous} + * @return The CompletionPostResponseSynchronous instance. */ - CompletionPostResponse orchestrationResult(@Nonnull final LLMModuleResult orchestrationResult); + CompletionPostResponseSynchronous orchestrationResult( + @Nonnull final LLMModuleResultSynchronous orchestrationResult); } } 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..bfceb38eb 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,12 @@ 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 = 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/ErrorResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java index 76fc798e1..9fd360023 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java @@ -41,7 +41,7 @@ public class ErrorResponse private String location; @JsonProperty("module_results") - private ModuleResults moduleResults; + private ErrorResponseModuleResults moduleResults; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -180,7 +180,7 @@ public void setLocation(@Nonnull final String location) { * @return The same instance of this {@link ErrorResponse} class */ @Nonnull - public ErrorResponse moduleResults(@Nullable final ModuleResults moduleResults) { + public ErrorResponse moduleResults(@Nullable final ErrorResponseModuleResults moduleResults) { this.moduleResults = moduleResults; return this; } @@ -191,7 +191,7 @@ public ErrorResponse moduleResults(@Nullable final ModuleResults moduleResults) * @return moduleResults The moduleResults of this {@link ErrorResponse} instance. */ @Nonnull - public ModuleResults getModuleResults() { + public ErrorResponseModuleResults getModuleResults() { return moduleResults; } @@ -200,7 +200,7 @@ public ModuleResults getModuleResults() { * * @param moduleResults The moduleResults of this {@link ErrorResponse} */ - public void setModuleResults(@Nullable final ModuleResults moduleResults) { + public void setModuleResults(@Nullable final ErrorResponseModuleResults moduleResults) { this.moduleResults = moduleResults; } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java new file mode 100644 index 000000000..3a9a55770 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java @@ -0,0 +1,531 @@ +/* + * 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; + +/** ErrorResponseModuleResults */ +// CHECKSTYLE:OFF +public class ErrorResponseModuleResults +// 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 ErrorResponseModuleResultsAllOfLlm llm; + + @JsonProperty("output_unmasking") + private List outputUnmasking = + new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ErrorResponseModuleResults. */ + protected ErrorResponseModuleResults() {} + + /** + * Set the grounding of this {@link ErrorResponseModuleResults} instance and return the same + * instance. + * + * @param grounding The grounding of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults grounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + return this; + } + + /** + * Get grounding + * + * @return grounding The grounding of this {@link ErrorResponseModuleResults} instance. + */ + @Nonnull + public GenericModuleResult getGrounding() { + return grounding; + } + + /** + * Set the grounding of this {@link ErrorResponseModuleResults} instance. + * + * @param grounding The grounding of this {@link ErrorResponseModuleResults} + */ + public void setGrounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + } + + /** + * Set the templating of this {@link ErrorResponseModuleResults} instance and return the same + * instance. + * + * @param templating The templating of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults templating(@Nullable final List templating) { + this.templating = templating; + return this; + } + + /** + * Add one templating instance to this {@link ErrorResponseModuleResults}. + * + * @param templatingItem The templating that should be added + * @return The same instance of type {@link ErrorResponseModuleResults} + */ + @Nonnull + public ErrorResponseModuleResults 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 ErrorResponseModuleResults} instance. + */ + @Nonnull + public List getTemplating() { + return templating; + } + + /** + * Set the templating of this {@link ErrorResponseModuleResults} instance. + * + * @param templating The templating of this {@link ErrorResponseModuleResults} + */ + public void setTemplating(@Nullable final List templating) { + this.templating = templating; + } + + /** + * Set the inputTranslation of this {@link ErrorResponseModuleResults} instance and return the + * same instance. + * + * @param inputTranslation The inputTranslation of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults inputTranslation( + @Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + return this; + } + + /** + * Get inputTranslation + * + * @return inputTranslation The inputTranslation of this {@link ErrorResponseModuleResults} + * instance. + */ + @Nonnull + public GenericModuleResult getInputTranslation() { + return inputTranslation; + } + + /** + * Set the inputTranslation of this {@link ErrorResponseModuleResults} instance. + * + * @param inputTranslation The inputTranslation of this {@link ErrorResponseModuleResults} + */ + public void setInputTranslation(@Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + } + + /** + * Set the inputMasking of this {@link ErrorResponseModuleResults} instance and return the same + * instance. + * + * @param inputMasking The inputMasking of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults inputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + return this; + } + + /** + * Get inputMasking + * + * @return inputMasking The inputMasking of this {@link ErrorResponseModuleResults} instance. + */ + @Nonnull + public GenericModuleResult getInputMasking() { + return inputMasking; + } + + /** + * Set the inputMasking of this {@link ErrorResponseModuleResults} instance. + * + * @param inputMasking The inputMasking of this {@link ErrorResponseModuleResults} + */ + public void setInputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + } + + /** + * Set the inputFiltering of this {@link ErrorResponseModuleResults} instance and return the same + * instance. + * + * @param inputFiltering The inputFiltering of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults inputFiltering( + @Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + return this; + } + + /** + * Get inputFiltering + * + * @return inputFiltering The inputFiltering of this {@link ErrorResponseModuleResults} instance. + */ + @Nonnull + public GenericModuleResult getInputFiltering() { + return inputFiltering; + } + + /** + * Set the inputFiltering of this {@link ErrorResponseModuleResults} instance. + * + * @param inputFiltering The inputFiltering of this {@link ErrorResponseModuleResults} + */ + public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + } + + /** + * Set the outputFiltering of this {@link ErrorResponseModuleResults} instance and return the same + * instance. + * + * @param outputFiltering The outputFiltering of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults outputFiltering( + @Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + return this; + } + + /** + * Get outputFiltering + * + * @return outputFiltering The outputFiltering of this {@link ErrorResponseModuleResults} + * instance. + */ + @Nonnull + public GenericModuleResult getOutputFiltering() { + return outputFiltering; + } + + /** + * Set the outputFiltering of this {@link ErrorResponseModuleResults} instance. + * + * @param outputFiltering The outputFiltering of this {@link ErrorResponseModuleResults} + */ + public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + } + + /** + * Set the outputTranslation of this {@link ErrorResponseModuleResults} instance and return the + * same instance. + * + * @param outputTranslation The outputTranslation of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults outputTranslation( + @Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + return this; + } + + /** + * Get outputTranslation + * + * @return outputTranslation The outputTranslation of this {@link ErrorResponseModuleResults} + * instance. + */ + @Nonnull + public GenericModuleResult getOutputTranslation() { + return outputTranslation; + } + + /** + * Set the outputTranslation of this {@link ErrorResponseModuleResults} instance. + * + * @param outputTranslation The outputTranslation of this {@link ErrorResponseModuleResults} + */ + public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + } + + /** + * Set the llm of this {@link ErrorResponseModuleResults} instance and return the same instance. + * + * @param llm The llm of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults llm(@Nullable final ErrorResponseModuleResultsAllOfLlm llm) { + this.llm = llm; + return this; + } + + /** + * Get llm + * + * @return llm The llm of this {@link ErrorResponseModuleResults} instance. + */ + @Nonnull + public ErrorResponseModuleResultsAllOfLlm getLlm() { + return llm; + } + + /** + * Set the llm of this {@link ErrorResponseModuleResults} instance. + * + * @param llm The llm of this {@link ErrorResponseModuleResults} + */ + public void setLlm(@Nullable final ErrorResponseModuleResultsAllOfLlm llm) { + this.llm = llm; + } + + /** + * Set the outputUnmasking of this {@link ErrorResponseModuleResults} instance and return the same + * instance. + * + * @param outputUnmasking The outputUnmasking of this {@link ErrorResponseModuleResults} + * @return The same instance of this {@link ErrorResponseModuleResults} class + */ + @Nonnull + public ErrorResponseModuleResults outputUnmasking( + @Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; + return this; + } + + /** + * Add one outputUnmasking instance to this {@link ErrorResponseModuleResults}. + * + * @param outputUnmaskingItem The outputUnmasking that should be added + * @return The same instance of type {@link ErrorResponseModuleResults} + */ + @Nonnull + public ErrorResponseModuleResults addOutputUnmaskingItem( + @Nonnull final ErrorResponseModuleResultsAllOfOutputUnmaskingInner outputUnmaskingItem) { + if (this.outputUnmasking == null) { + this.outputUnmasking = new ArrayList<>(); + } + this.outputUnmasking.add(outputUnmaskingItem); + return this; + } + + /** + * Get outputUnmasking + * + * @return outputUnmasking The outputUnmasking of this {@link ErrorResponseModuleResults} + * instance. + */ + @Nonnull + public List getOutputUnmasking() { + return outputUnmasking; + } + + /** + * Set the outputUnmasking of this {@link ErrorResponseModuleResults} instance. + * + * @param outputUnmasking The outputUnmasking of this {@link ErrorResponseModuleResults} + */ + public void setOutputUnmasking( + @Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; + } + + /** + * Get the names of the unrecognizable properties of the {@link ErrorResponseModuleResults}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ErrorResponseModuleResults} + * 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( + "ErrorResponseModuleResults has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ErrorResponseModuleResults} 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 ErrorResponseModuleResults} 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 ErrorResponseModuleResults errorResponseModuleResults = (ErrorResponseModuleResults) o; + return Objects.equals( + this.cloudSdkCustomFields, errorResponseModuleResults.cloudSdkCustomFields) + && Objects.equals(this.grounding, errorResponseModuleResults.grounding) + && Objects.equals(this.templating, errorResponseModuleResults.templating) + && Objects.equals(this.inputTranslation, errorResponseModuleResults.inputTranslation) + && Objects.equals(this.inputMasking, errorResponseModuleResults.inputMasking) + && Objects.equals(this.inputFiltering, errorResponseModuleResults.inputFiltering) + && Objects.equals(this.outputFiltering, errorResponseModuleResults.outputFiltering) + && Objects.equals(this.outputTranslation, errorResponseModuleResults.outputTranslation) + && Objects.equals(this.llm, errorResponseModuleResults.llm) + && Objects.equals(this.outputUnmasking, errorResponseModuleResults.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 ErrorResponseModuleResults {\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 ErrorResponseModuleResults} instance. No arguments are required. */ + public static ErrorResponseModuleResults create() { + return new ErrorResponseModuleResults(); + } +} 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/ErrorResponseModuleResultsAllOfLlm.java similarity index 91% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResultsAllOfLlm.java index a07479937..d37d91cb6 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/ErrorResponseModuleResultsAllOfLlm.java @@ -14,10 +14,10 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -/** Output of LLM module. Follows the OpenAI spec. */ +/** ErrorResponseModuleResultsAllOfLlm */ @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({ @JsonSubTypes.Type(value = LLMModuleResultStreaming.class), @JsonSubTypes.Type(value = LLMModuleResultSynchronous.class), }) -public interface LLMModuleResult {} +public interface ErrorResponseModuleResultsAllOfLlm {} 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/ErrorResponseModuleResultsAllOfOutputUnmaskingInner.java similarity index 84% 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/ErrorResponseModuleResultsAllOfOutputUnmaskingInner.java index 7088e9392..fa92db908 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/ErrorResponseModuleResultsAllOfOutputUnmaskingInner.java @@ -14,10 +14,10 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -/** ModuleResultsOutputUnmaskingInner */ +/** ErrorResponseModuleResultsAllOfOutputUnmaskingInner */ @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({ - @JsonSubTypes.Type(value = LLMChoice.class), @JsonSubTypes.Type(value = LLMChoiceStreaming.class), + @JsonSubTypes.Type(value = LLMChoiceSynchronous.class), }) -public interface ModuleResultsOutputUnmaskingInner {} +public interface ErrorResponseModuleResultsAllOfOutputUnmaskingInner {} 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..6d0a1da0e 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 @@ -28,7 +28,7 @@ /** LLMChoiceStreaming */ // CHECKSTYLE:OFF -public class LLMChoiceStreaming implements ModuleResultsOutputUnmaskingInner +public class LLMChoiceStreaming implements ErrorResponseModuleResultsAllOfOutputUnmaskingInner // CHECKSTYLE:ON { @JsonProperty("index") 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/LLMChoiceSynchronous.java similarity index 69% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceSynchronous.java index 482d0b217..ce6222a65 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/LLMChoiceSynchronous.java @@ -26,9 +26,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** LLMChoice */ +/** LLMChoiceSynchronous */ // CHECKSTYLE:OFF -public class LLMChoice implements ModuleResultsOutputUnmaskingInner +public class LLMChoiceSynchronous implements ErrorResponseModuleResultsAllOfOutputUnmaskingInner // CHECKSTYLE:ON { @JsonProperty("index") @@ -46,17 +46,17 @@ public class LLMChoice implements ModuleResultsOutputUnmaskingInner @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for LLMChoice. */ - protected LLMChoice() {} + /** Default constructor for LLMChoiceSynchronous. */ + protected LLMChoiceSynchronous() {} /** - * Set the index of this {@link LLMChoice} instance and return the same instance. + * Set the index of this {@link LLMChoiceSynchronous} instance and return the same instance. * * @param index Index of the choice - * @return The same instance of this {@link LLMChoice} class + * @return The same instance of this {@link LLMChoiceSynchronous} class */ @Nonnull - public LLMChoice index(@Nonnull final Integer index) { + public LLMChoiceSynchronous index(@Nonnull final Integer index) { this.index = index; return this; } @@ -64,7 +64,7 @@ public LLMChoice index(@Nonnull final Integer index) { /** * Index of the choice * - * @return index The index of this {@link LLMChoice} instance. + * @return index The index of this {@link LLMChoiceSynchronous} instance. */ @Nonnull public Integer getIndex() { @@ -72,7 +72,7 @@ public Integer getIndex() { } /** - * Set the index of this {@link LLMChoice} instance. + * Set the index of this {@link LLMChoiceSynchronous} instance. * * @param index Index of the choice */ @@ -81,13 +81,13 @@ public void setIndex(@Nonnull final Integer index) { } /** - * Set the message of this {@link LLMChoice} instance and return the same instance. + * Set the message of this {@link LLMChoiceSynchronous} instance and return the same instance. * - * @param message The message of this {@link LLMChoice} - * @return The same instance of this {@link LLMChoice} class + * @param message The message of this {@link LLMChoiceSynchronous} + * @return The same instance of this {@link LLMChoiceSynchronous} class */ @Nonnull - public LLMChoice message(@Nonnull final ResponseChatMessage message) { + public LLMChoiceSynchronous message(@Nonnull final ResponseChatMessage message) { this.message = message; return this; } @@ -95,7 +95,7 @@ public LLMChoice message(@Nonnull final ResponseChatMessage message) { /** * Get message * - * @return message The message of this {@link LLMChoice} instance. + * @return message The message of this {@link LLMChoiceSynchronous} instance. */ @Nonnull public ResponseChatMessage getMessage() { @@ -103,35 +103,35 @@ public ResponseChatMessage getMessage() { } /** - * Set the message of this {@link LLMChoice} instance. + * Set the message of this {@link LLMChoiceSynchronous} instance. * - * @param message The message of this {@link LLMChoice} + * @param message The message of this {@link LLMChoiceSynchronous} */ public void setMessage(@Nonnull final ResponseChatMessage message) { this.message = message; } /** - * Set the logprobs of this {@link LLMChoice} instance and return the same instance. + * Set the logprobs of this {@link LLMChoiceSynchronous} instance and return the same instance. * * @param logprobs Log probabilities - * @return The same instance of this {@link LLMChoice} class + * @return The same instance of this {@link LLMChoiceSynchronous} class */ @Nonnull - public LLMChoice logprobs(@Nullable final Map> logprobs) { + public LLMChoiceSynchronous logprobs(@Nullable final Map> logprobs) { this.logprobs = logprobs; return this; } /** - * Put one logprobs instance to this {@link LLMChoice} instance. + * Put one logprobs instance to this {@link LLMChoiceSynchronous} 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} + * @return The same instance of type {@link LLMChoiceSynchronous} */ @Nonnull - public LLMChoice putlogprobsItem( + public LLMChoiceSynchronous putlogprobsItem( @Nonnull final String key, @Nonnull final List logprobsItem) { if (this.logprobs == null) { this.logprobs = new HashMap<>(); @@ -143,7 +143,7 @@ public LLMChoice putlogprobsItem( /** * Log probabilities * - * @return logprobs The logprobs of this {@link LLMChoice} instance. + * @return logprobs The logprobs of this {@link LLMChoiceSynchronous} instance. */ @Nonnull public Map> getLogprobs() { @@ -151,7 +151,7 @@ public Map> getLogprobs() { } /** - * Set the logprobs of this {@link LLMChoice} instance. + * Set the logprobs of this {@link LLMChoiceSynchronous} instance. * * @param logprobs Log probabilities */ @@ -160,16 +160,17 @@ public void setLogprobs(@Nullable final Map> logprobs) } /** - * Set the finishReason of this {@link LLMChoice} instance and return the same instance. + * Set the finishReason of this {@link LLMChoiceSynchronous} instance and return the same + * instance. * * @param finishReason 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 - * @return The same instance of this {@link LLMChoice} class + * @return The same instance of this {@link LLMChoiceSynchronous} class */ @Nonnull - public LLMChoice finishReason(@Nonnull final String finishReason) { + public LLMChoiceSynchronous finishReason(@Nonnull final String finishReason) { this.finishReason = finishReason; return this; } @@ -180,7 +181,7 @@ public LLMChoice finishReason(@Nonnull final String finishReason) { * 'content_filter' if content was omitted due to a filter enforced by the LLM model * provider or the content filtering module * - * @return finishReason The finishReason of this {@link LLMChoice} instance. + * @return finishReason The finishReason of this {@link LLMChoiceSynchronous} instance. */ @Nonnull public String getFinishReason() { @@ -188,7 +189,7 @@ public String getFinishReason() { } /** - * Set the finishReason of this {@link LLMChoice} instance. + * Set the finishReason of this {@link LLMChoiceSynchronous} instance. * * @param finishReason 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 @@ -200,7 +201,7 @@ public void setFinishReason(@Nonnull final String finishReason) { } /** - * Get the names of the unrecognizable properties of the {@link LLMChoice}. + * Get the names of the unrecognizable properties of the {@link LLMChoiceSynchronous}. * * @return The set of properties names */ @@ -211,7 +212,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link LLMChoice} instance. + * Get the value of an unrecognizable property of this {@link LLMChoiceSynchronous} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -222,14 +223,15 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException("LLMChoice has no field with name '" + name + "'."); + throw new NoSuchElementException( + "LLMChoiceSynchronous has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link LLMChoice} instance including unrecognized - * properties. + * Get the value of all properties of this {@link LLMChoiceSynchronous} instance including + * unrecognized properties. * * @return The map of all properties */ @@ -245,8 +247,8 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link LLMChoice} instance. If the map previously - * contained a mapping for the key, the old value is replaced by the specified value. + * Set an unrecognizable property of this {@link LLMChoiceSynchronous} 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 @@ -264,12 +266,12 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final LLMChoice llMChoice = (LLMChoice) o; - return Objects.equals(this.cloudSdkCustomFields, llMChoice.cloudSdkCustomFields) - && Objects.equals(this.index, llMChoice.index) - && Objects.equals(this.message, llMChoice.message) - && Objects.equals(this.logprobs, llMChoice.logprobs) - && Objects.equals(this.finishReason, llMChoice.finishReason); + final LLMChoiceSynchronous llMChoiceSynchronous = (LLMChoiceSynchronous) o; + return Objects.equals(this.cloudSdkCustomFields, llMChoiceSynchronous.cloudSdkCustomFields) + && Objects.equals(this.index, llMChoiceSynchronous.index) + && Objects.equals(this.message, llMChoiceSynchronous.message) + && Objects.equals(this.logprobs, llMChoiceSynchronous.logprobs) + && Objects.equals(this.finishReason, llMChoiceSynchronous.finishReason); } @Override @@ -281,7 +283,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class LLMChoice {\n"); + sb.append("class LLMChoiceSynchronous {\n"); sb.append(" index: ").append(toIndentedString(index)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" logprobs: ").append(toIndentedString(logprobs)).append("\n"); @@ -304,23 +306,23 @@ private String toIndentedString(final java.lang.Object o) { } /** - * Create a type-safe, fluent-api builder object to construct a new {@link LLMChoice} instance - * with all required arguments. + * Create a type-safe, fluent-api builder object to construct a new {@link LLMChoiceSynchronous} + * instance with all required arguments. */ public static Builder create() { return (index) -> (message) -> (finishReason) -> - new LLMChoice().index(index).message(message).finishReason(finishReason); + new LLMChoiceSynchronous().index(index).message(message).finishReason(finishReason); } /** Builder helper class. */ public interface Builder { /** - * Set the index of this {@link LLMChoice} instance. + * Set the index of this {@link LLMChoiceSynchronous} instance. * * @param index Index of the choice - * @return The LLMChoice builder. + * @return The LLMChoiceSynchronous builder. */ Builder1 index(@Nonnull final Integer index); } @@ -328,10 +330,10 @@ public interface Builder { /** Builder helper class. */ public interface Builder1 { /** - * Set the message of this {@link LLMChoice} instance. + * Set the message of this {@link LLMChoiceSynchronous} instance. * - * @param message The message of this {@link LLMChoice} - * @return The LLMChoice builder. + * @param message The message of this {@link LLMChoiceSynchronous} + * @return The LLMChoiceSynchronous builder. */ Builder2 message(@Nonnull final ResponseChatMessage message); } @@ -339,14 +341,14 @@ public interface Builder1 { /** Builder helper class. */ public interface Builder2 { /** - * Set the finishReason of this {@link LLMChoice} instance. + * Set the finishReason of this {@link LLMChoiceSynchronous} instance. * * @param finishReason 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 - * @return The LLMChoice instance. + * @return The LLMChoiceSynchronous instance. */ - LLMChoice finishReason(@Nonnull final String finishReason); + LLMChoiceSynchronous finishReason(@Nonnull final String finishReason); } } 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..bc4985f26 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 implements ErrorResponseModuleResultsAllOfLlm // 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 index 5db99a16c..bede28885 100644 --- 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 @@ -28,7 +28,7 @@ /** Output of LLM module. Follows the OpenAI spec. */ // CHECKSTYLE:OFF -public class LLMModuleResultSynchronous implements LLMModuleResult +public class LLMModuleResultSynchronous implements ErrorResponseModuleResultsAllOfLlm // CHECKSTYLE:ON { @JsonProperty("id") @@ -47,7 +47,7 @@ public class LLMModuleResultSynchronous implements LLMModuleResult private String systemFingerprint; @JsonProperty("choices") - private List choices = new ArrayList<>(); + private List choices = new ArrayList<>(); @JsonProperty("usage") private TokenUsage usage; @@ -225,7 +225,7 @@ public void setSystemFingerprint(@Nullable final String systemFingerprint) { * @return The same instance of this {@link LLMModuleResultSynchronous} class */ @Nonnull - public LLMModuleResultSynchronous choices(@Nonnull final List choices) { + public LLMModuleResultSynchronous choices(@Nonnull final List choices) { this.choices = choices; return this; } @@ -237,7 +237,8 @@ public LLMModuleResultSynchronous choices(@Nonnull final List choices * @return The same instance of type {@link LLMModuleResultSynchronous} */ @Nonnull - public LLMModuleResultSynchronous addChoicesItem(@Nonnull final LLMChoice choicesItem) { + public LLMModuleResultSynchronous addChoicesItem( + @Nonnull final LLMChoiceSynchronous choicesItem) { if (this.choices == null) { this.choices = new ArrayList<>(); } @@ -251,7 +252,7 @@ public LLMModuleResultSynchronous addChoicesItem(@Nonnull final LLMChoice choice * @return choices The choices of this {@link LLMModuleResultSynchronous} instance. */ @Nonnull - public List getChoices() { + public List getChoices() { return choices; } @@ -260,7 +261,7 @@ public List getChoices() { * * @param choices Choices */ - public void setChoices(@Nonnull final List choices) { + public void setChoices(@Nonnull final List choices) { this.choices = choices; } @@ -484,7 +485,7 @@ public interface Builder4 { * @param choices Choices * @return The LLMModuleResultSynchronous builder. */ - Builder5 choices(@Nonnull final List choices); + Builder5 choices(@Nonnull final List choices); /** * Set the choices of this {@link LLMModuleResultSynchronous} instance. @@ -492,7 +493,7 @@ public interface Builder4 { * @param choices Choices * @return The LLMModuleResultSynchronous builder. */ - default Builder5 choices(@Nonnull final LLMChoice... choices) { + default Builder5 choices(@Nonnull final LLMChoiceSynchronous... choices) { return choices(Arrays.asList(choices)); } } 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..e3a415e74 --- /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. */ +// 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/ModuleResults.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsStreaming.java similarity index 63% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsStreaming.java index 5db49a5cb..527b61a90 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/ModuleResultsStreaming.java @@ -25,9 +25,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** Results of each module. */ +/** Streaming results of each module. */ // CHECKSTYLE:OFF -public class ModuleResults +public class ModuleResultsStreaming // CHECKSTYLE:ON { @JsonProperty("grounding") @@ -45,32 +45,32 @@ 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 LLMModuleResultStreaming llm; + + @JsonProperty("output_unmasking") + private List outputUnmasking = new ArrayList<>(); + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for ModuleResults. */ - protected ModuleResults() {} + /** Default constructor for ModuleResultsStreaming. */ + protected ModuleResultsStreaming() {} /** - * Set the grounding of this {@link ModuleResults} instance and return the same instance. + * Set the grounding of this {@link ModuleResultsStreaming} instance and return the same instance. * - * @param grounding The grounding of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param grounding The grounding of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults grounding(@Nullable final GenericModuleResult grounding) { + public ModuleResultsStreaming grounding(@Nullable final GenericModuleResult grounding) { this.grounding = grounding; return this; } @@ -78,7 +78,7 @@ public ModuleResults grounding(@Nullable final GenericModuleResult grounding) { /** * Get grounding * - * @return grounding The grounding of this {@link ModuleResults} instance. + * @return grounding The grounding of this {@link ModuleResultsStreaming} instance. */ @Nonnull public GenericModuleResult getGrounding() { @@ -86,34 +86,35 @@ public GenericModuleResult getGrounding() { } /** - * Set the grounding of this {@link ModuleResults} instance. + * Set the grounding of this {@link ModuleResultsStreaming} instance. * - * @param grounding The grounding of this {@link ModuleResults} + * @param grounding The grounding of this {@link ModuleResultsStreaming} */ public void setGrounding(@Nullable final GenericModuleResult grounding) { this.grounding = grounding; } /** - * Set the templating of this {@link ModuleResults} instance and return the same instance. + * Set the templating of this {@link ModuleResultsStreaming} instance and return the same + * instance. * - * @param templating The templating of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param templating The templating of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults templating(@Nullable final List templating) { + public ModuleResultsStreaming templating(@Nullable final List templating) { this.templating = templating; return this; } /** - * Add one templating instance to this {@link ModuleResults}. + * Add one templating instance to this {@link ModuleResultsStreaming}. * * @param templatingItem The templating that should be added - * @return The same instance of type {@link ModuleResults} + * @return The same instance of type {@link ModuleResultsStreaming} */ @Nonnull - public ModuleResults addTemplatingItem(@Nonnull final ChatMessage templatingItem) { + public ModuleResultsStreaming addTemplatingItem(@Nonnull final ChatMessage templatingItem) { if (this.templating == null) { this.templating = new ArrayList<>(); } @@ -124,7 +125,7 @@ public ModuleResults addTemplatingItem(@Nonnull final ChatMessage templatingItem /** * Get templating * - * @return templating The templating of this {@link ModuleResults} instance. + * @return templating The templating of this {@link ModuleResultsStreaming} instance. */ @Nonnull public List getTemplating() { @@ -132,22 +133,24 @@ public List getTemplating() { } /** - * Set the templating of this {@link ModuleResults} instance. + * Set the templating of this {@link ModuleResultsStreaming} instance. * - * @param templating The templating of this {@link ModuleResults} + * @param templating The templating of this {@link ModuleResultsStreaming} */ public void setTemplating(@Nullable final List templating) { this.templating = templating; } /** - * Set the inputTranslation of this {@link ModuleResults} instance and return the same instance. + * Set the inputTranslation of this {@link ModuleResultsStreaming} instance and return the same + * instance. * - * @param inputTranslation The inputTranslation of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param inputTranslation The inputTranslation of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults inputTranslation(@Nullable final GenericModuleResult inputTranslation) { + public ModuleResultsStreaming inputTranslation( + @Nullable final GenericModuleResult inputTranslation) { this.inputTranslation = inputTranslation; return this; } @@ -155,7 +158,7 @@ public ModuleResults inputTranslation(@Nullable final GenericModuleResult inputT /** * Get inputTranslation * - * @return inputTranslation The inputTranslation of this {@link ModuleResults} instance. + * @return inputTranslation The inputTranslation of this {@link ModuleResultsStreaming} instance. */ @Nonnull public GenericModuleResult getInputTranslation() { @@ -163,22 +166,23 @@ public GenericModuleResult getInputTranslation() { } /** - * Set the inputTranslation of this {@link ModuleResults} instance. + * Set the inputTranslation of this {@link ModuleResultsStreaming} instance. * - * @param inputTranslation The inputTranslation of this {@link ModuleResults} + * @param inputTranslation The inputTranslation of this {@link ModuleResultsStreaming} */ public void setInputTranslation(@Nullable final GenericModuleResult inputTranslation) { this.inputTranslation = inputTranslation; } /** - * Set the inputMasking of this {@link ModuleResults} instance and return the same instance. + * Set the inputMasking of this {@link ModuleResultsStreaming} instance and return the same + * instance. * - * @param inputMasking The inputMasking of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param inputMasking The inputMasking of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults inputMasking(@Nullable final GenericModuleResult inputMasking) { + public ModuleResultsStreaming inputMasking(@Nullable final GenericModuleResult inputMasking) { this.inputMasking = inputMasking; return this; } @@ -186,7 +190,7 @@ public ModuleResults inputMasking(@Nullable final GenericModuleResult inputMaski /** * Get inputMasking * - * @return inputMasking The inputMasking of this {@link ModuleResults} instance. + * @return inputMasking The inputMasking of this {@link ModuleResultsStreaming} instance. */ @Nonnull public GenericModuleResult getInputMasking() { @@ -194,22 +198,23 @@ public GenericModuleResult getInputMasking() { } /** - * Set the inputMasking of this {@link ModuleResults} instance. + * Set the inputMasking of this {@link ModuleResultsStreaming} instance. * - * @param inputMasking The inputMasking of this {@link ModuleResults} + * @param inputMasking The inputMasking of this {@link ModuleResultsStreaming} */ public void setInputMasking(@Nullable final GenericModuleResult inputMasking) { this.inputMasking = inputMasking; } /** - * Set the inputFiltering of this {@link ModuleResults} instance and return the same instance. + * Set the inputFiltering of this {@link ModuleResultsStreaming} instance and return the same + * instance. * - * @param inputFiltering The inputFiltering of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param inputFiltering The inputFiltering of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults inputFiltering(@Nullable final GenericModuleResult inputFiltering) { + public ModuleResultsStreaming inputFiltering(@Nullable final GenericModuleResult inputFiltering) { this.inputFiltering = inputFiltering; return this; } @@ -217,7 +222,7 @@ public ModuleResults inputFiltering(@Nullable final GenericModuleResult inputFil /** * Get inputFiltering * - * @return inputFiltering The inputFiltering of this {@link ModuleResults} instance. + * @return inputFiltering The inputFiltering of this {@link ModuleResultsStreaming} instance. */ @Nonnull public GenericModuleResult getInputFiltering() { @@ -225,158 +230,163 @@ public GenericModuleResult getInputFiltering() { } /** - * Set the inputFiltering of this {@link ModuleResults} instance. + * Set the inputFiltering of this {@link ModuleResultsStreaming} instance. * - * @param inputFiltering The inputFiltering of this {@link ModuleResults} + * @param inputFiltering The inputFiltering of this {@link ModuleResultsStreaming} */ public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering) { this.inputFiltering = inputFiltering; } /** - * Set the llm of this {@link ModuleResults} instance and return the same instance. + * Set the outputFiltering of this {@link ModuleResultsStreaming} instance and return the same + * instance. * - * @param llm The llm of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param outputFiltering The outputFiltering of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults llm(@Nullable final LLMModuleResult llm) { - this.llm = llm; + public ModuleResultsStreaming 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 ModuleResultsStreaming} 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 ModuleResultsStreaming} instance. * - * @param llm The llm of this {@link ModuleResults} + * @param outputFiltering The outputFiltering of this {@link ModuleResultsStreaming} */ - 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 ModuleResultsStreaming} instance and return the same + * instance. * - * @param outputFiltering The outputFiltering of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param outputTranslation The outputTranslation of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults outputFiltering(@Nullable final GenericModuleResult outputFiltering) { - this.outputFiltering = outputFiltering; + public ModuleResultsStreaming 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 ModuleResultsStreaming} + * 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 ModuleResultsStreaming} instance. * - * @param outputFiltering The outputFiltering of this {@link ModuleResults} + * @param outputTranslation The outputTranslation of this {@link ModuleResultsStreaming} */ - 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 ModuleResultsStreaming} instance and return the same instance. * - * @param outputUnmasking The outputUnmasking of this {@link ModuleResults} - * @return The same instance of this {@link ModuleResults} class + * @param llm The llm of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ @Nonnull - public ModuleResults outputUnmasking( - @Nullable final List outputUnmasking) { - this.outputUnmasking = outputUnmasking; + public ModuleResultsStreaming llm(@Nullable final LLMModuleResultStreaming 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 ModuleResultsStreaming} instance. */ @Nonnull - public ModuleResults addOutputUnmaskingItem( - @Nonnull final ModuleResultsOutputUnmaskingInner outputUnmaskingItem) { - if (this.outputUnmasking == null) { - this.outputUnmasking = new ArrayList<>(); - } - this.outputUnmasking.add(outputUnmaskingItem); - return this; + public LLMModuleResultStreaming getLlm() { + return llm; } /** - * Get outputUnmasking + * Set the llm of this {@link ModuleResultsStreaming} instance. * - * @return outputUnmasking The outputUnmasking of this {@link ModuleResults} instance. + * @param llm The llm of this {@link ModuleResultsStreaming} */ - @Nonnull - public List getOutputUnmasking() { - return outputUnmasking; + public void setLlm(@Nullable final LLMModuleResultStreaming llm) { + this.llm = llm; } /** - * Set the outputUnmasking of this {@link ModuleResults} instance. + * Set the outputUnmasking of this {@link ModuleResultsStreaming} instance and return the same + * instance. * - * @param outputUnmasking The outputUnmasking of this {@link ModuleResults} + * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsStreaming} + * @return The same instance of this {@link ModuleResultsStreaming} class */ - public void setOutputUnmasking( - @Nullable final List outputUnmasking) { + @Nonnull + public ModuleResultsStreaming 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 ModuleResultsStreaming}. * - * @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 ModuleResultsStreaming} */ @Nonnull - public ModuleResults outputTranslation(@Nullable final GenericModuleResult outputTranslation) { - this.outputTranslation = outputTranslation; + public ModuleResultsStreaming addOutputUnmaskingItem( + @Nonnull final LLMChoiceStreaming 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 ModuleResultsStreaming} 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 ModuleResultsStreaming} instance. * - * @param outputTranslation The outputTranslation of this {@link ModuleResults} + * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsStreaming} */ - public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { - this.outputTranslation = outputTranslation; + public void setOutputUnmasking(@Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; } /** - * Get the names of the unrecognizable properties of the {@link ModuleResults}. + * Get the names of the unrecognizable properties of the {@link ModuleResultsStreaming}. * * @return The set of properties names */ @@ -387,7 +397,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link ModuleResults} instance. + * Get the value of an unrecognizable property of this {@link ModuleResultsStreaming} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -398,14 +408,15 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException("ModuleResults has no field with name '" + name + "'."); + throw new NoSuchElementException( + "ModuleResultsStreaming has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link ModuleResults} instance including unrecognized - * properties. + * Get the value of all properties of this {@link ModuleResultsStreaming} instance including + * unrecognized properties. * * @return The map of all properties */ @@ -418,16 +429,16 @@ 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; } /** - * Set an unrecognizable property of this {@link ModuleResults} instance. If the map previously - * contained a mapping for the key, the old value is replaced by the specified value. + * 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 @@ -445,17 +456,17 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final ModuleResults moduleResults = (ModuleResults) o; - return Objects.equals(this.cloudSdkCustomFields, moduleResults.cloudSdkCustomFields) - && Objects.equals(this.grounding, moduleResults.grounding) - && Objects.equals(this.templating, moduleResults.templating) - && 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); + 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 @@ -466,10 +477,10 @@ public int hashCode() { inputTranslation, inputMasking, inputFiltering, - llm, outputFiltering, - outputUnmasking, outputTranslation, + llm, + outputUnmasking, cloudSdkCustomFields); } @@ -477,16 +488,16 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class ModuleResults {\n"); + 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(" 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")); @@ -504,8 +515,8 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - /** Create a new {@link ModuleResults} instance. No arguments are required. */ - public static ModuleResults create() { - return new ModuleResults(); + /** 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/ModuleResultsSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsSynchronous.java new file mode 100644 index 000000000..7db2e0be2 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsSynchronous.java @@ -0,0 +1,525 @@ +/* + * 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; + +/** Synchronous results of each module. */ +// CHECKSTYLE:OFF +public class ModuleResultsSynchronous +// 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 LLMModuleResultSynchronous llm; + + @JsonProperty("output_unmasking") + private List outputUnmasking = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ModuleResultsSynchronous. */ + protected ModuleResultsSynchronous() {} + + /** + * Set the grounding of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param grounding The grounding of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous grounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + return this; + } + + /** + * Get grounding + * + * @return grounding The grounding of this {@link ModuleResultsSynchronous} instance. + */ + @Nonnull + public GenericModuleResult getGrounding() { + return grounding; + } + + /** + * Set the grounding of this {@link ModuleResultsSynchronous} instance. + * + * @param grounding The grounding of this {@link ModuleResultsSynchronous} + */ + public void setGrounding(@Nullable final GenericModuleResult grounding) { + this.grounding = grounding; + } + + /** + * Set the templating of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param templating The templating of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous templating(@Nullable final List templating) { + this.templating = templating; + return this; + } + + /** + * Add one templating instance to this {@link ModuleResultsSynchronous}. + * + * @param templatingItem The templating that should be added + * @return The same instance of type {@link ModuleResultsSynchronous} + */ + @Nonnull + public ModuleResultsSynchronous 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 ModuleResultsSynchronous} instance. + */ + @Nonnull + public List getTemplating() { + return templating; + } + + /** + * Set the templating of this {@link ModuleResultsSynchronous} instance. + * + * @param templating The templating of this {@link ModuleResultsSynchronous} + */ + public void setTemplating(@Nullable final List templating) { + this.templating = templating; + } + + /** + * Set the inputTranslation of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param inputTranslation The inputTranslation of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous inputTranslation( + @Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + return this; + } + + /** + * Get inputTranslation + * + * @return inputTranslation The inputTranslation of this {@link ModuleResultsSynchronous} + * instance. + */ + @Nonnull + public GenericModuleResult getInputTranslation() { + return inputTranslation; + } + + /** + * Set the inputTranslation of this {@link ModuleResultsSynchronous} instance. + * + * @param inputTranslation The inputTranslation of this {@link ModuleResultsSynchronous} + */ + public void setInputTranslation(@Nullable final GenericModuleResult inputTranslation) { + this.inputTranslation = inputTranslation; + } + + /** + * Set the inputMasking of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param inputMasking The inputMasking of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous inputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + return this; + } + + /** + * Get inputMasking + * + * @return inputMasking The inputMasking of this {@link ModuleResultsSynchronous} instance. + */ + @Nonnull + public GenericModuleResult getInputMasking() { + return inputMasking; + } + + /** + * Set the inputMasking of this {@link ModuleResultsSynchronous} instance. + * + * @param inputMasking The inputMasking of this {@link ModuleResultsSynchronous} + */ + public void setInputMasking(@Nullable final GenericModuleResult inputMasking) { + this.inputMasking = inputMasking; + } + + /** + * Set the inputFiltering of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param inputFiltering The inputFiltering of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous inputFiltering( + @Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + return this; + } + + /** + * Get inputFiltering + * + * @return inputFiltering The inputFiltering of this {@link ModuleResultsSynchronous} instance. + */ + @Nonnull + public GenericModuleResult getInputFiltering() { + return inputFiltering; + } + + /** + * Set the inputFiltering of this {@link ModuleResultsSynchronous} instance. + * + * @param inputFiltering The inputFiltering of this {@link ModuleResultsSynchronous} + */ + public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering) { + this.inputFiltering = inputFiltering; + } + + /** + * Set the outputFiltering of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param outputFiltering The outputFiltering of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous outputFiltering( + @Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + return this; + } + + /** + * Get outputFiltering + * + * @return outputFiltering The outputFiltering of this {@link ModuleResultsSynchronous} instance. + */ + @Nonnull + public GenericModuleResult getOutputFiltering() { + return outputFiltering; + } + + /** + * Set the outputFiltering of this {@link ModuleResultsSynchronous} instance. + * + * @param outputFiltering The outputFiltering of this {@link ModuleResultsSynchronous} + */ + public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { + this.outputFiltering = outputFiltering; + } + + /** + * Set the outputTranslation of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param outputTranslation The outputTranslation of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous outputTranslation( + @Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + return this; + } + + /** + * Get outputTranslation + * + * @return outputTranslation The outputTranslation of this {@link ModuleResultsSynchronous} + * instance. + */ + @Nonnull + public GenericModuleResult getOutputTranslation() { + return outputTranslation; + } + + /** + * Set the outputTranslation of this {@link ModuleResultsSynchronous} instance. + * + * @param outputTranslation The outputTranslation of this {@link ModuleResultsSynchronous} + */ + public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { + this.outputTranslation = outputTranslation; + } + + /** + * Set the llm of this {@link ModuleResultsSynchronous} instance and return the same instance. + * + * @param llm The llm of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous llm(@Nullable final LLMModuleResultSynchronous llm) { + this.llm = llm; + return this; + } + + /** + * Get llm + * + * @return llm The llm of this {@link ModuleResultsSynchronous} instance. + */ + @Nonnull + public LLMModuleResultSynchronous getLlm() { + return llm; + } + + /** + * Set the llm of this {@link ModuleResultsSynchronous} instance. + * + * @param llm The llm of this {@link ModuleResultsSynchronous} + */ + public void setLlm(@Nullable final LLMModuleResultSynchronous llm) { + this.llm = llm; + } + + /** + * Set the outputUnmasking of this {@link ModuleResultsSynchronous} instance and return the same + * instance. + * + * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsSynchronous} + * @return The same instance of this {@link ModuleResultsSynchronous} class + */ + @Nonnull + public ModuleResultsSynchronous outputUnmasking( + @Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; + return this; + } + + /** + * Add one outputUnmasking instance to this {@link ModuleResultsSynchronous}. + * + * @param outputUnmaskingItem The outputUnmasking that should be added + * @return The same instance of type {@link ModuleResultsSynchronous} + */ + @Nonnull + public ModuleResultsSynchronous addOutputUnmaskingItem( + @Nonnull final LLMChoiceSynchronous outputUnmaskingItem) { + if (this.outputUnmasking == null) { + this.outputUnmasking = new ArrayList<>(); + } + this.outputUnmasking.add(outputUnmaskingItem); + return this; + } + + /** + * Get outputUnmasking + * + * @return outputUnmasking The outputUnmasking of this {@link ModuleResultsSynchronous} instance. + */ + @Nonnull + public List getOutputUnmasking() { + return outputUnmasking; + } + + /** + * Set the outputUnmasking of this {@link ModuleResultsSynchronous} instance. + * + * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsSynchronous} + */ + public void setOutputUnmasking(@Nullable final List outputUnmasking) { + this.outputUnmasking = outputUnmasking; + } + + /** + * Get the names of the unrecognizable properties of the {@link ModuleResultsSynchronous}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ModuleResultsSynchronous} 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( + "ModuleResultsSynchronous has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ModuleResultsSynchronous} 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 ModuleResultsSynchronous} 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 ModuleResultsSynchronous moduleResultsSynchronous = (ModuleResultsSynchronous) o; + return Objects.equals(this.cloudSdkCustomFields, moduleResultsSynchronous.cloudSdkCustomFields) + && Objects.equals(this.grounding, moduleResultsSynchronous.grounding) + && Objects.equals(this.templating, moduleResultsSynchronous.templating) + && Objects.equals(this.inputTranslation, moduleResultsSynchronous.inputTranslation) + && Objects.equals(this.inputMasking, moduleResultsSynchronous.inputMasking) + && Objects.equals(this.inputFiltering, moduleResultsSynchronous.inputFiltering) + && Objects.equals(this.outputFiltering, moduleResultsSynchronous.outputFiltering) + && Objects.equals(this.outputTranslation, moduleResultsSynchronous.outputTranslation) + && Objects.equals(this.llm, moduleResultsSynchronous.llm) + && Objects.equals(this.outputUnmasking, moduleResultsSynchronous.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 ModuleResultsSynchronous {\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 ModuleResultsSynchronous} instance. No arguments are required. */ + public static ModuleResultsSynchronous create() { + return new ModuleResultsSynchronous(); + } +} 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/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index 893f7a40f..899a56bb4 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -36,7 +36,10 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/CompletionPostResponse" + $ref: "#/components/schemas/CompletionPostResponseSynchronous" + text/event-stream: + schema: + $ref: "#/components/schemas/CompletionPostResponseStreaming" "400": $ref: "#/components/responses/BadRequest" default: @@ -63,20 +66,16 @@ 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 - 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 +130,7 @@ components: - user required: - content - - role + - role UserChatMessageContent: oneOf: - type: string @@ -195,13 +194,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 +212,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 +266,6 @@ components: enum: ["text"] text: type: string - ChatDelta: type: object required: @@ -309,8 +313,7 @@ components: calling your function. required: - index - - CompletionPostResponse: + CompletionPostResponseSynchronous: type: object required: - request_id @@ -322,12 +325,11 @@ components: type: string example: "d4a67ea1-2bf9-4df7-8105-d48203ccff76" module_results: - $ref: "#/components/schemas/ModuleResults" + $ref: "#/components/schemas/ModuleResultsSynchronous" orchestration_result: - $ref: "#/components/schemas/LLMModuleResult" + $ref: "#/components/schemas/LLMModuleResultSynchronous" 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 +338,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 +355,6 @@ components: default: false stream_options: $ref: "#/components/schemas/GlobalStreamOptions" - ModuleConfigs: type: object required: @@ -376,8 +376,9 @@ components: $ref: "#/components/schemas/InputTranslationModuleConfig" output_translation_module_config: $ref: "#/components/schemas/OutputTranslationModuleConfig" - - ModuleResults: + # Abstract base class encompassing fields for both `ModuleResultsSynchronous` and `ModuleResultsStreaming` + # Not to be instantiated by llm-orchestration code + ModuleResultsBase: description: Results of each module. type: object additionalProperties: false @@ -392,19 +393,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" - + ModuleResultsSynchronous: + description: Synchronous results of each module. + type: object + additionalProperties: false + allOf: + - $ref: "#/components/schemas/ModuleResultsBase" + - type: object + properties: + llm: + $ref: "#/components/schemas/LLMModuleResultSynchronous" + output_unmasking: + type: array + items: + $ref: "#/components/schemas/LLMChoiceSynchronous" + 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 @@ -451,7 +471,6 @@ components: description: Version of the model to use type: string default: "latest" - GenericModuleResult: type: object description: Generic module result @@ -465,13 +484,6 @@ 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. @@ -507,10 +519,9 @@ components: type: array description: Choices items: - $ref: "#/components/schemas/LLMChoice" + $ref: "#/components/schemas/LLMChoiceSynchronous" usage: $ref: "#/components/schemas/TokenUsage" - LLMModuleResultStreaming: type: object description: Output of LLM module. Follows the OpenAI spec. @@ -543,8 +554,7 @@ components: $ref: "#/components/schemas/LLMChoiceStreaming" usage: $ref: "#/components/schemas/TokenUsage" - - LLMChoice: + LLMChoiceSynchronous: type: object required: - index @@ -568,7 +578,6 @@ components: 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: @@ -590,7 +599,6 @@ components: finish_reason: type: string description: Reason for stopping the model - TokenUsage: type: object description: Usage of tokens in the response @@ -1042,15 +1050,51 @@ 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" + + 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 +1121,7 @@ components: - profile-religious-group - profile-political-group - profile-pronouns-gender + - profile-ethnicity - profile-gender - profile-sexual-orientation - profile-trade-union @@ -1251,11 +1296,9 @@ components: InputTranslationModuleConfig: oneOf: - $ref: "#/components/schemas/SAPDocumentTranslation" - OutputTranslationModuleConfig: oneOf: - $ref: "#/components/schemas/SAPDocumentTranslation" - SAPDocumentTranslation: type: object required: @@ -1307,7 +1350,20 @@ components: description: Where the error occurred example: "LLM Module" module_results: - $ref: "#/components/schemas/ModuleResults" + allOf: + - $ref: "#/components/schemas/ModuleResultsBase" + - type: object + properties: + llm: + oneOf: + - $ref: "#/components/schemas/LLMModuleResultSynchronous" + - $ref: "#/components/schemas/LLMModuleResultStreaming" + output_unmasking: + type: array + items: + oneOf: + - $ref: "#/components/schemas/LLMChoiceSynchronous" + - $ref: "#/components/schemas/LLMChoiceStreaming" responses: BadRequest: From bd1ddb724b31a311da4bda459c99ebcfe338729f Mon Sep 17 00:00:00 2001 From: I538344 Date: Tue, 27 May 2025 10:09:39 +0200 Subject: [PATCH 02/12] WiP --- .../sap/ai/sdk/orchestration/DpiMasking.java | 4 ++- .../ai/sdk/orchestration/JacksonMixins.java | 6 ---- .../OrchestrationChatCompletionDelta.java | 20 ++++------- .../OrchestrationChatResponse.java | 17 ++++------ .../orchestration/OrchestrationClient.java | 10 +++--- .../OrchestrationJacksonConfiguration.java | 8 ++--- .../spring/OrchestrationSpringChatDelta.java | 25 +++++--------- .../OrchestrationSpringChatResponse.java | 11 +++--- .../LLMModuleResultDeserializerTest.java | 3 +- .../OrchestrationModuleConfigTest.java | 4 ++- .../orchestration/OrchestrationUnitTest.java | 34 +++++++++---------- .../spring/OrchestrationChatDeltaTest.java | 21 +++++------- .../spring/OrchestrationChatResponseTest.java | 4 +-- 13 files changed, 67 insertions(+), 100 deletions(-) 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 aa4aaaffa..e3484e726 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 com.sap.ai.sdk.orchestration.model.MaskingProviderConfig; import java.util.ArrayList; import java.util.Arrays; @@ -96,7 +97,8 @@ public DpiMasking withAllowList(@Nonnull final List allowList) { @Nonnull @Override public MaskingProviderConfig 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 66441072c..73ec77f36 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 @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.sap.ai.sdk.orchestration.model.LLMChoice; import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -15,11 +14,6 @@ final class JacksonMixins { @JsonDeserialize(as = LLMModuleResultSynchronous.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.NONE) interface NoneTypeInfoMixin {} 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..d3dd6371c 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,7 +29,7 @@ public String getDeltaContent() { @Nullable @Override public String getFinishReason() { - return ((LLMModuleResultSynchronous) getOrchestrationResult()) + 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 9a734b032..1ea0d40b4 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 @@ -5,9 +5,8 @@ import com.sap.ai.sdk.orchestration.model.AssistantChatMessage; import com.sap.ai.sdk.orchestration.model.ChatMessage; 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.CompletionPostResponseSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMChoiceSynchronous; import com.sap.ai.sdk.orchestration.model.SystemChatMessage; import com.sap.ai.sdk.orchestration.model.TokenUsage; import com.sap.ai.sdk.orchestration.model.ToolChatMessage; @@ -23,7 +22,7 @@ @Value @RequiredArgsConstructor(access = PACKAGE) public class OrchestrationChatResponse { - CompletionPostResponse originalResponse; + CompletionPostResponseSynchronous originalResponse; /** * Get the message content from the output. @@ -50,7 +49,7 @@ public String getContent() throws OrchestrationClientException { */ @Nonnull public TokenUsage getTokenUsage() { - return ((LLMModuleResultSynchronous) originalResponse.getOrchestrationResult()).getUsage(); + return originalResponse.getOrchestrationResult().getUsage(); } /** @@ -98,13 +97,11 @@ public List getAllMessages() throws IllegalArgumentException { /** * Get the LLM response. Useful for accessing the finish reason or further data like logprobs. * - * @return The (first, in case of multiple) {@link LLMChoice}. + * @return The (first, in case of multiple) {@link LLMChoiceSynchronous}. */ @Nonnull - public LLMChoice getChoice() { + public LLMChoiceSynchronous getChoice() { // We expect choices to be defined and never empty. - return ((LLMModuleResultSynchronous) originalResponse.getOrchestrationResult()) - .getChoices() - .get(0); + return originalResponse.getOrchestrationResult().getChoices().get(0); } } 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..999d3161c 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 @@ -13,7 +13,7 @@ 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.CompletionPostResponseSynchronous; import com.sap.ai.sdk.orchestration.model.ModuleConfigs; import com.sap.ai.sdk.orchestration.model.OrchestrationConfig; import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Accessor; @@ -148,8 +148,8 @@ private static void throwOnContentFilter(@Nonnull final OrchestrationChatComplet * @throws OrchestrationClientException If the request fails. */ @Nonnull - public CompletionPostResponse executeRequest(@Nonnull final CompletionPostRequest request) - throws OrchestrationClientException { + public CompletionPostResponseSynchronous executeRequest( + @Nonnull final CompletionPostRequest request) throws OrchestrationClientException { final String jsonRequest; try { jsonRequest = JACKSON.writeValueAsString(request); @@ -209,7 +209,7 @@ public OrchestrationChatResponse executeRequestFromJsonModuleConfig( } @Nonnull - CompletionPostResponse executeRequest(@Nonnull final String request) { + CompletionPostResponseSynchronous executeRequest(@Nonnull final String request) { val postRequest = new HttpPost("/completion"); postRequest.setEntity(new StringEntity(request, ContentType.APPLICATION_JSON)); @@ -219,7 +219,7 @@ CompletionPostResponse executeRequest(@Nonnull final String request) { val client = ApacheHttpClient5Accessor.getHttpClient(destination); val handler = new ClientResponseHandler<>( - CompletionPostResponse.class, + CompletionPostResponseSynchronous.class, OrchestrationError.class, OrchestrationClientException::new) .objectMapper(JACKSON); 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..24f0e9201 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,7 @@ 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.ErrorResponseModuleResultsAllOfLlm; import com.sap.ai.sdk.orchestration.model.TemplateResponseFormat; import javax.annotation.Nonnull; import lombok.AccessLevel; @@ -37,11 +36,8 @@ public static ObjectMapper getOrchestrationObjectMapper() { val jackson = getDefaultObjectMapper(); - // Add mix-ins - jackson.addMixIn(LLMModuleResult.class, JacksonMixins.LLMModuleResultMixIn.class); jackson.addMixIn( - ModuleResultsOutputUnmaskingInner.class, - JacksonMixins.ModuleResultsOutputUnmaskingInnerMixIn.class); + ErrorResponseModuleResultsAllOfLlm.class, JacksonMixins.LLMModuleResultMixIn.class); jackson.addMixIn(ChatMessage.class, JacksonMixins.ChatMessageMixin.class); final var module = 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..256bcc2b0 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()); } - 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..fde3e39a1 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 @@ -2,7 +2,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.LLMChoiceSynchronous; import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; import com.sap.ai.sdk.orchestration.model.TokenUsage; import java.util.List; @@ -33,12 +33,9 @@ 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; } @@ -48,7 +45,7 @@ static List toGenerations(@Nonnull final LLMModuleResultSynchronous } @Nonnull - static Generation toGeneration(@Nonnull final LLMChoice choice) { + static Generation toGeneration(@Nonnull final LLMChoiceSynchronous choice) { val metadata = ChatGenerationMetadata.builder().finishReason(choice.getFinishReason()); metadata.metadata("index", choice.getIndex()); if (!choice.getLogprobs().isEmpty()) { 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..1b75c75fb 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 @@ -2,7 +2,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; @@ -42,7 +41,7 @@ void testSubtypeResolutionSynchronous() { """; var json = String.format(JSON, choices); - var result = OrchestrationClient.JACKSON.readValue(json, LLMModuleResult.class); + var result = OrchestrationClient.JACKSON.readValue(json, LLMModuleResultSynchronous.class); assertThat(result).isExactlyInstanceOf(LLMModuleResultSynchronous.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..0bca15acd 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; @@ -90,7 +91,8 @@ void testDpiMaskingConfig() { DPIConfig 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 540c37db0..d6d41a3e1 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 @@ -37,6 +37,7 @@ 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.DPIEntities; import com.sap.ai.sdk.orchestration.model.DataRepositoryType; import com.sap.ai.sdk.orchestration.model.DocumentGroundingFilter; @@ -45,7 +46,6 @@ 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.ResponseFormatText; import com.sap.ai.sdk.orchestration.model.SearchDocumentKeyValueListPair; @@ -287,7 +287,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 +303,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); @@ -687,9 +687,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(); @@ -704,9 +704,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); @@ -726,9 +726,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"); @@ -742,9 +742,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(); } @@ -808,7 +808,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()) @@ -816,7 +816,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( 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..0cd2e6137 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,13 @@ 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 +34,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..6b047ecac 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 @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.sap.ai.sdk.orchestration.model.LLMChoice; +import com.sap.ai.sdk.orchestration.model.LLMChoiceSynchronous; import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; import com.sap.ai.sdk.orchestration.model.ResponseChatMessage; import com.sap.ai.sdk.orchestration.model.TokenUsage; @@ -15,7 +15,7 @@ class OrchestrationChatResponseTest { @Test void testToGeneration() { var choice = - LLMChoice.create() + LLMChoiceSynchronous.create() .index(0) .message( ResponseChatMessage.create() From 50add6cc40aed5ca0578a94801258a63ff69919c Mon Sep 17 00:00:00 2001 From: I538344 Date: Wed, 4 Jun 2025 09:25:20 +0200 Subject: [PATCH 03/12] Latest spec with error classes --- orchestration/pom.xml | 2 +- .../OrchestrationChatCompletionDelta.java | 5 +- .../sdk/orchestration/OrchestrationError.java | 4 +- .../OrchestrationJacksonConfiguration.java | 3 - .../model/AzureContentSafetyInput.java | 320 +++++++++++ .../AzureContentSafetyInputFilterConfig.java | 286 ++++++++++ .../model/AzureContentSafetyOutput.java | 284 ++++++++++ .../AzureContentSafetyOutputFilterConfig.java | 286 ++++++++++ .../orchestration/model/DPICustomEntity.java | 240 ++++++++ ...> DPICustomEntityReplacementStrategy.java} | 7 +- .../model/ErrorResponseModuleResults.java | 531 ------------------ ...ponse.java => ErrorResponseStreaming.java} | 143 ++--- .../model/ErrorResponseSynchronous.java | 378 +++++++++++++ ...skingInner.java => InputFilterConfig.java} | 8 +- .../model/LLMChoiceStreaming.java | 2 +- .../model/LLMChoiceSynchronous.java | 2 +- .../model/LLMModuleResultStreaming.java | 2 +- .../model/LLMModuleResultSynchronous.java | 2 +- .../model/OutputFilterConfig.java | 23 + .../main/resources/spec/orchestration.yaml | 47 +- .../spring/OrchestrationChatDeltaTest.java | 5 +- .../app/controllers/OrchestrationTest.java | 44 +- 22 files changed, 1952 insertions(+), 672 deletions(-) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInput.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutputFilterConfig.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{ErrorResponseModuleResultsAllOfLlm.java => DPICustomEntityReplacementStrategy.java} (81%) delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{ErrorResponse.java => ErrorResponseStreaming.java} (64%) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseSynchronous.java rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{ErrorResponseModuleResultsAllOfOutputUnmaskingInner.java => InputFilterConfig.java} (79%) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java diff --git a/orchestration/pom.xml b/orchestration/pom.xml index f5157eac7..5424fb30d 100644 --- a/orchestration/pom.xml +++ b/orchestration/pom.xml @@ -35,7 +35,7 @@ 94% 95% 79% - 94% + 93% 100% 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 d3dd6371c..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 @@ -29,9 +29,6 @@ public String getDeltaContent() { @Nullable @Override public String getFinishReason() { - return getOrchestrationResult() - .getChoices() - .get(0) - .getFinishReason(); + return getOrchestrationResult().getChoices().get(0).getFinishReason(); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java index 4d5956edd..d8d68ce43 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.google.common.annotations.Beta; import com.sap.ai.sdk.core.common.ClientError; -import com.sap.ai.sdk.orchestration.model.ErrorResponse; +import com.sap.ai.sdk.orchestration.model.ErrorResponseSynchronous; import javax.annotation.Nonnull; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -18,7 +18,7 @@ @Value @Beta public class OrchestrationError implements ClientError { - ErrorResponse originalResponse; + ErrorResponseSynchronous originalResponse; /** * Gets the error message from the contained original response. 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 24f0e9201..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,7 +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.ErrorResponseModuleResultsAllOfLlm; import com.sap.ai.sdk.orchestration.model.TemplateResponseFormat; import javax.annotation.Nonnull; import lombok.AccessLevel; @@ -36,8 +35,6 @@ public static ObjectMapper getOrchestrationObjectMapper() { val jackson = getDefaultObjectMapper(); - jackson.addMixIn( - ErrorResponseModuleResultsAllOfLlm.class, JacksonMixins.LLMModuleResultMixIn.class); jackson.addMixIn(ChatMessage.class, JacksonMixins.ChatMessageMixin.class); final var module = 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/AzureContentSafetyInputFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java new file mode 100644 index 000000000..3de44c4d5 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.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; + +/** AzureContentSafetyInputFilterConfig */ +// CHECKSTYLE:OFF +public class AzureContentSafetyInputFilterConfig implements InputFilterConfig +// CHECKSTYLE:ON +{ + /** Name of the filter provider type */ + public enum TypeEnum { + /** The AZURE_CONTENT_SAFETY option of this AzureContentSafetyInputFilterConfig */ + AZURE_CONTENT_SAFETY("azure_content_safety"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this AzureContentSafetyInputFilterConfig */ + 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 AzureContentSafetyInputFilterConfig + */ + @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 AzureContentSafetyInput config; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for AzureContentSafetyInputFilterConfig. */ + protected AzureContentSafetyInputFilterConfig() {} + + /** + * 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 AzureContentSafetyInputFilterConfig} class + */ + @Nonnull + public AzureContentSafetyInputFilterConfig type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * Name of the filter provider type + * + * @return type The type of this {@link AzureContentSafetyInputFilterConfig} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link AzureContentSafetyInputFilterConfig} 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 AzureContentSafetyInputFilterConfig} instance and return the same + * instance. + * + * @param config The config of this {@link AzureContentSafetyInputFilterConfig} + * @return The same instance of this {@link AzureContentSafetyInputFilterConfig} class + */ + @Nonnull + public AzureContentSafetyInputFilterConfig config( + @Nullable final AzureContentSafetyInput config) { + this.config = config; + return this; + } + + /** + * Get config + * + * @return config The config of this {@link AzureContentSafetyInputFilterConfig} instance. + */ + @Nonnull + public AzureContentSafetyInput getConfig() { + return config; + } + + /** + * Set the config of this {@link AzureContentSafetyInputFilterConfig} instance. + * + * @param config The config of this {@link AzureContentSafetyInputFilterConfig} + */ + public void setConfig(@Nullable final AzureContentSafetyInput config) { + this.config = config; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * AzureContentSafetyInputFilterConfig}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AzureContentSafetyInputFilterConfig} + * 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( + "AzureContentSafetyInputFilterConfig has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link AzureContentSafetyInputFilterConfig} 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 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 + * @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 AzureContentSafetyInputFilterConfig azureContentSafetyInputFilterConfig = + (AzureContentSafetyInputFilterConfig) o; + return Objects.equals( + this.cloudSdkCustomFields, azureContentSafetyInputFilterConfig.cloudSdkCustomFields) + && Objects.equals(this.type, azureContentSafetyInputFilterConfig.type) + && Objects.equals(this.config, azureContentSafetyInputFilterConfig.config); + } + + @Override + public int hashCode() { + return Objects.hash(type, config, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AzureContentSafetyInputFilterConfig {\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 + * AzureContentSafetyInputFilterConfig} instance with all required arguments. + */ + public static Builder create() { + return (type) -> new AzureContentSafetyInputFilterConfig().type(type); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the type of this {@link AzureContentSafetyInputFilterConfig} instance. + * + * @param type Name of the filter provider type + * @return The AzureContentSafetyInputFilterConfig instance. + */ + AzureContentSafetyInputFilterConfig type(@Nonnull final TypeEnum type); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java new file mode 100644 index 000000000..f428f183a --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java @@ -0,0 +1,284 @@ +/* + * 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 AzureContentSafetyOutput +// CHECKSTYLE:ON +{ + @JsonProperty("Hate") + private AzureThreshold hate; + + @JsonProperty("SelfHarm") + private AzureThreshold selfHarm; + + @JsonProperty("Sexual") + private AzureThreshold sexual; + + @JsonProperty("Violence") + private AzureThreshold violence; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for AzureContentSafetyOutput. */ + protected AzureContentSafetyOutput() {} + + /** + * Set the hate of this {@link AzureContentSafetyOutput} instance and return the same instance. + * + * @param hate The hate of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class + */ + @Nonnull + public AzureContentSafetyOutput hate(@Nullable final AzureThreshold hate) { + this.hate = hate; + return this; + } + + /** + * Get hate + * + * @return hate The hate of this {@link AzureContentSafetyOutput} instance. + */ + @Nonnull + public AzureThreshold getHate() { + return hate; + } + + /** + * Set the hate of this {@link AzureContentSafetyOutput} instance. + * + * @param hate The hate of this {@link AzureContentSafetyOutput} + */ + public void setHate(@Nullable final AzureThreshold hate) { + this.hate = hate; + } + + /** + * Set the selfHarm of this {@link AzureContentSafetyOutput} instance and return the same + * instance. + * + * @param selfHarm The selfHarm of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class + */ + @Nonnull + public AzureContentSafetyOutput selfHarm(@Nullable final AzureThreshold selfHarm) { + this.selfHarm = selfHarm; + return this; + } + + /** + * Get selfHarm + * + * @return selfHarm The selfHarm of this {@link AzureContentSafetyOutput} instance. + */ + @Nonnull + public AzureThreshold getSelfHarm() { + return selfHarm; + } + + /** + * Set the selfHarm of this {@link AzureContentSafetyOutput} instance. + * + * @param selfHarm The selfHarm of this {@link AzureContentSafetyOutput} + */ + public void setSelfHarm(@Nullable final AzureThreshold selfHarm) { + this.selfHarm = selfHarm; + } + + /** + * Set the sexual of this {@link AzureContentSafetyOutput} instance and return the same instance. + * + * @param sexual The sexual of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class + */ + @Nonnull + public AzureContentSafetyOutput sexual(@Nullable final AzureThreshold sexual) { + this.sexual = sexual; + return this; + } + + /** + * Get sexual + * + * @return sexual The sexual of this {@link AzureContentSafetyOutput} instance. + */ + @Nonnull + public AzureThreshold getSexual() { + return sexual; + } + + /** + * Set the sexual of this {@link AzureContentSafetyOutput} instance. + * + * @param sexual The sexual of this {@link AzureContentSafetyOutput} + */ + public void setSexual(@Nullable final AzureThreshold sexual) { + this.sexual = sexual; + } + + /** + * Set the violence of this {@link AzureContentSafetyOutput} instance and return the same + * instance. + * + * @param violence The violence of this {@link AzureContentSafetyOutput} + * @return The same instance of this {@link AzureContentSafetyOutput} class + */ + @Nonnull + public AzureContentSafetyOutput violence(@Nullable final AzureThreshold violence) { + this.violence = violence; + return this; + } + + /** + * Get violence + * + * @return violence The violence of this {@link AzureContentSafetyOutput} instance. + */ + @Nonnull + public AzureThreshold getViolence() { + return violence; + } + + /** + * Set the violence of this {@link AzureContentSafetyOutput} instance. + * + * @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 AzureContentSafetyOutput}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AzureContentSafetyOutput} 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( + "AzureContentSafetyOutput has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link AzureContentSafetyOutput} 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); + return declaredFields; + } + + /** + * 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 + * @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 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 + public int hashCode() { + return Objects.hash(hate, selfHarm, sexual, violence, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + 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"); + sb.append(" violence: ").append(toIndentedString(violence)).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 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/DPICustomEntity.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java new file mode 100644 index 000000000..25ed33a75 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java @@ -0,0 +1,240 @@ +/* + * 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 DPICustomEntityReplacementStrategy 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 DPICustomEntityReplacementStrategy replacementStrategy) { + this.replacementStrategy = replacementStrategy; + return this; + } + + /** + * Get replacementStrategy + * + * @return replacementStrategy The replacementStrategy of this {@link DPICustomEntity} instance. + */ + @Nonnull + public DPICustomEntityReplacementStrategy getReplacementStrategy() { + return replacementStrategy; + } + + /** + * Set the replacementStrategy of this {@link DPICustomEntity} instance. + * + * @param replacementStrategy The replacementStrategy of this {@link DPICustomEntity} + */ + public void setReplacementStrategy( + @Nonnull final DPICustomEntityReplacementStrategy 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 DPICustomEntityReplacementStrategy replacementStrategy); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResultsAllOfLlm.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntityReplacementStrategy.java similarity index 81% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResultsAllOfLlm.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntityReplacementStrategy.java index d37d91cb6..42ede0a51 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResultsAllOfLlm.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntityReplacementStrategy.java @@ -14,10 +14,9 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -/** ErrorResponseModuleResultsAllOfLlm */ +/** Replacement strategy to be used for the entity */ @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({ - @JsonSubTypes.Type(value = LLMModuleResultStreaming.class), - @JsonSubTypes.Type(value = LLMModuleResultSynchronous.class), + @JsonSubTypes.Type(value = DPIMethodConstant.class), }) -public interface ErrorResponseModuleResultsAllOfLlm {} +public interface DPICustomEntityReplacementStrategy {} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java deleted file mode 100644 index 3a9a55770..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResults.java +++ /dev/null @@ -1,531 +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.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; - -/** ErrorResponseModuleResults */ -// CHECKSTYLE:OFF -public class ErrorResponseModuleResults -// 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 ErrorResponseModuleResultsAllOfLlm llm; - - @JsonProperty("output_unmasking") - private List outputUnmasking = - new ArrayList<>(); - - @JsonAnySetter @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** Default constructor for ErrorResponseModuleResults. */ - protected ErrorResponseModuleResults() {} - - /** - * Set the grounding of this {@link ErrorResponseModuleResults} instance and return the same - * instance. - * - * @param grounding The grounding of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults grounding(@Nullable final GenericModuleResult grounding) { - this.grounding = grounding; - return this; - } - - /** - * Get grounding - * - * @return grounding The grounding of this {@link ErrorResponseModuleResults} instance. - */ - @Nonnull - public GenericModuleResult getGrounding() { - return grounding; - } - - /** - * Set the grounding of this {@link ErrorResponseModuleResults} instance. - * - * @param grounding The grounding of this {@link ErrorResponseModuleResults} - */ - public void setGrounding(@Nullable final GenericModuleResult grounding) { - this.grounding = grounding; - } - - /** - * Set the templating of this {@link ErrorResponseModuleResults} instance and return the same - * instance. - * - * @param templating The templating of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults templating(@Nullable final List templating) { - this.templating = templating; - return this; - } - - /** - * Add one templating instance to this {@link ErrorResponseModuleResults}. - * - * @param templatingItem The templating that should be added - * @return The same instance of type {@link ErrorResponseModuleResults} - */ - @Nonnull - public ErrorResponseModuleResults 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 ErrorResponseModuleResults} instance. - */ - @Nonnull - public List getTemplating() { - return templating; - } - - /** - * Set the templating of this {@link ErrorResponseModuleResults} instance. - * - * @param templating The templating of this {@link ErrorResponseModuleResults} - */ - public void setTemplating(@Nullable final List templating) { - this.templating = templating; - } - - /** - * Set the inputTranslation of this {@link ErrorResponseModuleResults} instance and return the - * same instance. - * - * @param inputTranslation The inputTranslation of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults inputTranslation( - @Nullable final GenericModuleResult inputTranslation) { - this.inputTranslation = inputTranslation; - return this; - } - - /** - * Get inputTranslation - * - * @return inputTranslation The inputTranslation of this {@link ErrorResponseModuleResults} - * instance. - */ - @Nonnull - public GenericModuleResult getInputTranslation() { - return inputTranslation; - } - - /** - * Set the inputTranslation of this {@link ErrorResponseModuleResults} instance. - * - * @param inputTranslation The inputTranslation of this {@link ErrorResponseModuleResults} - */ - public void setInputTranslation(@Nullable final GenericModuleResult inputTranslation) { - this.inputTranslation = inputTranslation; - } - - /** - * Set the inputMasking of this {@link ErrorResponseModuleResults} instance and return the same - * instance. - * - * @param inputMasking The inputMasking of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults inputMasking(@Nullable final GenericModuleResult inputMasking) { - this.inputMasking = inputMasking; - return this; - } - - /** - * Get inputMasking - * - * @return inputMasking The inputMasking of this {@link ErrorResponseModuleResults} instance. - */ - @Nonnull - public GenericModuleResult getInputMasking() { - return inputMasking; - } - - /** - * Set the inputMasking of this {@link ErrorResponseModuleResults} instance. - * - * @param inputMasking The inputMasking of this {@link ErrorResponseModuleResults} - */ - public void setInputMasking(@Nullable final GenericModuleResult inputMasking) { - this.inputMasking = inputMasking; - } - - /** - * Set the inputFiltering of this {@link ErrorResponseModuleResults} instance and return the same - * instance. - * - * @param inputFiltering The inputFiltering of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults inputFiltering( - @Nullable final GenericModuleResult inputFiltering) { - this.inputFiltering = inputFiltering; - return this; - } - - /** - * Get inputFiltering - * - * @return inputFiltering The inputFiltering of this {@link ErrorResponseModuleResults} instance. - */ - @Nonnull - public GenericModuleResult getInputFiltering() { - return inputFiltering; - } - - /** - * Set the inputFiltering of this {@link ErrorResponseModuleResults} instance. - * - * @param inputFiltering The inputFiltering of this {@link ErrorResponseModuleResults} - */ - public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering) { - this.inputFiltering = inputFiltering; - } - - /** - * Set the outputFiltering of this {@link ErrorResponseModuleResults} instance and return the same - * instance. - * - * @param outputFiltering The outputFiltering of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults outputFiltering( - @Nullable final GenericModuleResult outputFiltering) { - this.outputFiltering = outputFiltering; - return this; - } - - /** - * Get outputFiltering - * - * @return outputFiltering The outputFiltering of this {@link ErrorResponseModuleResults} - * instance. - */ - @Nonnull - public GenericModuleResult getOutputFiltering() { - return outputFiltering; - } - - /** - * Set the outputFiltering of this {@link ErrorResponseModuleResults} instance. - * - * @param outputFiltering The outputFiltering of this {@link ErrorResponseModuleResults} - */ - public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { - this.outputFiltering = outputFiltering; - } - - /** - * Set the outputTranslation of this {@link ErrorResponseModuleResults} instance and return the - * same instance. - * - * @param outputTranslation The outputTranslation of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults outputTranslation( - @Nullable final GenericModuleResult outputTranslation) { - this.outputTranslation = outputTranslation; - return this; - } - - /** - * Get outputTranslation - * - * @return outputTranslation The outputTranslation of this {@link ErrorResponseModuleResults} - * instance. - */ - @Nonnull - public GenericModuleResult getOutputTranslation() { - return outputTranslation; - } - - /** - * Set the outputTranslation of this {@link ErrorResponseModuleResults} instance. - * - * @param outputTranslation The outputTranslation of this {@link ErrorResponseModuleResults} - */ - public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { - this.outputTranslation = outputTranslation; - } - - /** - * Set the llm of this {@link ErrorResponseModuleResults} instance and return the same instance. - * - * @param llm The llm of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults llm(@Nullable final ErrorResponseModuleResultsAllOfLlm llm) { - this.llm = llm; - return this; - } - - /** - * Get llm - * - * @return llm The llm of this {@link ErrorResponseModuleResults} instance. - */ - @Nonnull - public ErrorResponseModuleResultsAllOfLlm getLlm() { - return llm; - } - - /** - * Set the llm of this {@link ErrorResponseModuleResults} instance. - * - * @param llm The llm of this {@link ErrorResponseModuleResults} - */ - public void setLlm(@Nullable final ErrorResponseModuleResultsAllOfLlm llm) { - this.llm = llm; - } - - /** - * Set the outputUnmasking of this {@link ErrorResponseModuleResults} instance and return the same - * instance. - * - * @param outputUnmasking The outputUnmasking of this {@link ErrorResponseModuleResults} - * @return The same instance of this {@link ErrorResponseModuleResults} class - */ - @Nonnull - public ErrorResponseModuleResults outputUnmasking( - @Nullable final List outputUnmasking) { - this.outputUnmasking = outputUnmasking; - return this; - } - - /** - * Add one outputUnmasking instance to this {@link ErrorResponseModuleResults}. - * - * @param outputUnmaskingItem The outputUnmasking that should be added - * @return The same instance of type {@link ErrorResponseModuleResults} - */ - @Nonnull - public ErrorResponseModuleResults addOutputUnmaskingItem( - @Nonnull final ErrorResponseModuleResultsAllOfOutputUnmaskingInner outputUnmaskingItem) { - if (this.outputUnmasking == null) { - this.outputUnmasking = new ArrayList<>(); - } - this.outputUnmasking.add(outputUnmaskingItem); - return this; - } - - /** - * Get outputUnmasking - * - * @return outputUnmasking The outputUnmasking of this {@link ErrorResponseModuleResults} - * instance. - */ - @Nonnull - public List getOutputUnmasking() { - return outputUnmasking; - } - - /** - * Set the outputUnmasking of this {@link ErrorResponseModuleResults} instance. - * - * @param outputUnmasking The outputUnmasking of this {@link ErrorResponseModuleResults} - */ - public void setOutputUnmasking( - @Nullable final List outputUnmasking) { - this.outputUnmasking = outputUnmasking; - } - - /** - * Get the names of the unrecognizable properties of the {@link ErrorResponseModuleResults}. - * - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link ErrorResponseModuleResults} - * 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( - "ErrorResponseModuleResults has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Get the value of all properties of this {@link ErrorResponseModuleResults} 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 ErrorResponseModuleResults} 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 ErrorResponseModuleResults errorResponseModuleResults = (ErrorResponseModuleResults) o; - return Objects.equals( - this.cloudSdkCustomFields, errorResponseModuleResults.cloudSdkCustomFields) - && Objects.equals(this.grounding, errorResponseModuleResults.grounding) - && Objects.equals(this.templating, errorResponseModuleResults.templating) - && Objects.equals(this.inputTranslation, errorResponseModuleResults.inputTranslation) - && Objects.equals(this.inputMasking, errorResponseModuleResults.inputMasking) - && Objects.equals(this.inputFiltering, errorResponseModuleResults.inputFiltering) - && Objects.equals(this.outputFiltering, errorResponseModuleResults.outputFiltering) - && Objects.equals(this.outputTranslation, errorResponseModuleResults.outputTranslation) - && Objects.equals(this.llm, errorResponseModuleResults.llm) - && Objects.equals(this.outputUnmasking, errorResponseModuleResults.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 ErrorResponseModuleResults {\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 ErrorResponseModuleResults} instance. No arguments are required. */ - public static ErrorResponseModuleResults create() { - return new ErrorResponseModuleResults(); - } -} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseStreaming.java similarity index 64% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseStreaming.java index 9fd360023..496390e32 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseStreaming.java @@ -23,9 +23,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** ErrorResponse */ +/** ErrorResponseStreaming */ // CHECKSTYLE:OFF -public class ErrorResponse +public class ErrorResponseStreaming // CHECKSTYLE:ON { @JsonProperty("request_id") @@ -41,22 +41,22 @@ public class ErrorResponse private String location; @JsonProperty("module_results") - private ErrorResponseModuleResults moduleResults; + private ModuleResultsStreaming moduleResults; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for ErrorResponse. */ - protected ErrorResponse() {} + /** Default constructor for ErrorResponseStreaming. */ + protected ErrorResponseStreaming() {} /** - * Set the requestId of this {@link ErrorResponse} instance and return the same instance. + * Set the requestId of this {@link ErrorResponseStreaming} instance and return the same instance. * - * @param requestId The requestId of this {@link ErrorResponse} - * @return The same instance of this {@link ErrorResponse} class + * @param requestId The requestId of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class */ @Nonnull - public ErrorResponse requestId(@Nonnull final String requestId) { + public ErrorResponseStreaming requestId(@Nonnull final String requestId) { this.requestId = requestId; return this; } @@ -64,7 +64,7 @@ public ErrorResponse requestId(@Nonnull final String requestId) { /** * Get requestId * - * @return requestId The requestId of this {@link ErrorResponse} instance. + * @return requestId The requestId of this {@link ErrorResponseStreaming} instance. */ @Nonnull public String getRequestId() { @@ -72,22 +72,22 @@ public String getRequestId() { } /** - * Set the requestId of this {@link ErrorResponse} instance. + * Set the requestId of this {@link ErrorResponseStreaming} instance. * - * @param requestId The requestId of this {@link ErrorResponse} + * @param requestId The requestId of this {@link ErrorResponseStreaming} */ public void setRequestId(@Nonnull final String requestId) { this.requestId = requestId; } /** - * Set the code of this {@link ErrorResponse} instance and return the same instance. + * Set the code of this {@link ErrorResponseStreaming} instance and return the same instance. * - * @param code The code of this {@link ErrorResponse} - * @return The same instance of this {@link ErrorResponse} class + * @param code The code of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class */ @Nonnull - public ErrorResponse code(@Nonnull final Integer code) { + public ErrorResponseStreaming code(@Nonnull final Integer code) { this.code = code; return this; } @@ -95,7 +95,7 @@ public ErrorResponse code(@Nonnull final Integer code) { /** * Get code * - * @return code The code of this {@link ErrorResponse} instance. + * @return code The code of this {@link ErrorResponseStreaming} instance. */ @Nonnull public Integer getCode() { @@ -103,22 +103,22 @@ public Integer getCode() { } /** - * Set the code of this {@link ErrorResponse} instance. + * Set the code of this {@link ErrorResponseStreaming} instance. * - * @param code The code of this {@link ErrorResponse} + * @param code The code of this {@link ErrorResponseStreaming} */ public void setCode(@Nonnull final Integer code) { this.code = code; } /** - * Set the message of this {@link ErrorResponse} instance and return the same instance. + * Set the message of this {@link ErrorResponseStreaming} instance and return the same instance. * - * @param message The message of this {@link ErrorResponse} - * @return The same instance of this {@link ErrorResponse} class + * @param message The message of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class */ @Nonnull - public ErrorResponse message(@Nonnull final String message) { + public ErrorResponseStreaming message(@Nonnull final String message) { this.message = message; return this; } @@ -126,7 +126,7 @@ public ErrorResponse message(@Nonnull final String message) { /** * Get message * - * @return message The message of this {@link ErrorResponse} instance. + * @return message The message of this {@link ErrorResponseStreaming} instance. */ @Nonnull public String getMessage() { @@ -134,22 +134,22 @@ public String getMessage() { } /** - * Set the message of this {@link ErrorResponse} instance. + * Set the message of this {@link ErrorResponseStreaming} instance. * - * @param message The message of this {@link ErrorResponse} + * @param message The message of this {@link ErrorResponseStreaming} */ public void setMessage(@Nonnull final String message) { this.message = message; } /** - * Set the location of this {@link ErrorResponse} instance and return the same instance. + * 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 ErrorResponse} class + * @return The same instance of this {@link ErrorResponseStreaming} class */ @Nonnull - public ErrorResponse location(@Nonnull final String location) { + public ErrorResponseStreaming location(@Nonnull final String location) { this.location = location; return this; } @@ -157,7 +157,7 @@ public ErrorResponse location(@Nonnull final String location) { /** * Where the error occurred * - * @return location The location of this {@link ErrorResponse} instance. + * @return location The location of this {@link ErrorResponseStreaming} instance. */ @Nonnull public String getLocation() { @@ -165,7 +165,7 @@ public String getLocation() { } /** - * Set the location of this {@link ErrorResponse} instance. + * Set the location of this {@link ErrorResponseStreaming} instance. * * @param location Where the error occurred */ @@ -174,13 +174,15 @@ public void setLocation(@Nonnull final String location) { } /** - * Set the moduleResults of this {@link ErrorResponse} instance and return the same instance. + * Set the moduleResults of this {@link ErrorResponseStreaming} instance and return the same + * instance. * - * @param moduleResults The moduleResults of this {@link ErrorResponse} - * @return The same instance of this {@link ErrorResponse} class + * @param moduleResults The moduleResults of this {@link ErrorResponseStreaming} + * @return The same instance of this {@link ErrorResponseStreaming} class */ @Nonnull - public ErrorResponse moduleResults(@Nullable final ErrorResponseModuleResults moduleResults) { + public ErrorResponseStreaming moduleResults( + @Nullable final ModuleResultsStreaming moduleResults) { this.moduleResults = moduleResults; return this; } @@ -188,24 +190,24 @@ public ErrorResponse moduleResults(@Nullable final ErrorResponseModuleResults mo /** * Get moduleResults * - * @return moduleResults The moduleResults of this {@link ErrorResponse} instance. + * @return moduleResults The moduleResults of this {@link ErrorResponseStreaming} instance. */ @Nonnull - public ErrorResponseModuleResults getModuleResults() { + public ModuleResultsStreaming getModuleResults() { return moduleResults; } /** - * Set the moduleResults of this {@link ErrorResponse} instance. + * Set the moduleResults of this {@link ErrorResponseStreaming} instance. * - * @param moduleResults The moduleResults of this {@link ErrorResponse} + * @param moduleResults The moduleResults of this {@link ErrorResponseStreaming} */ - public void setModuleResults(@Nullable final ErrorResponseModuleResults moduleResults) { + public void setModuleResults(@Nullable final ModuleResultsStreaming moduleResults) { this.moduleResults = moduleResults; } /** - * Get the names of the unrecognizable properties of the {@link ErrorResponse}. + * Get the names of the unrecognizable properties of the {@link ErrorResponseStreaming}. * * @return The set of properties names */ @@ -216,7 +218,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link ErrorResponse} instance. + * Get the value of an unrecognizable property of this {@link ErrorResponseStreaming} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -227,14 +229,15 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException("ErrorResponse has no field with name '" + name + "'."); + throw new NoSuchElementException( + "ErrorResponseStreaming has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link ErrorResponse} instance including unrecognized - * properties. + * Get the value of all properties of this {@link ErrorResponseStreaming} instance including + * unrecognized properties. * * @return The map of all properties */ @@ -251,8 +254,8 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link ErrorResponse} instance. If the map previously - * contained a mapping for the key, the old value is replaced by the specified value. + * 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 @@ -270,13 +273,13 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final ErrorResponse errorResponse = (ErrorResponse) o; - return Objects.equals(this.cloudSdkCustomFields, errorResponse.cloudSdkCustomFields) - && Objects.equals(this.requestId, errorResponse.requestId) - && Objects.equals(this.code, errorResponse.code) - && Objects.equals(this.message, errorResponse.message) - && Objects.equals(this.location, errorResponse.location) - && Objects.equals(this.moduleResults, errorResponse.moduleResults); + 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 @@ -288,7 +291,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class ErrorResponse {\n"); + 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"); @@ -312,15 +315,15 @@ private String toIndentedString(final java.lang.Object o) { } /** - * Create a type-safe, fluent-api builder object to construct a new {@link ErrorResponse} instance - * with all required arguments. + * 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 ErrorResponse() + new ErrorResponseStreaming() .requestId(requestId) .code(code) .message(message) @@ -330,10 +333,10 @@ public static Builder create() { /** Builder helper class. */ public interface Builder { /** - * Set the requestId of this {@link ErrorResponse} instance. + * Set the requestId of this {@link ErrorResponseStreaming} instance. * - * @param requestId The requestId of this {@link ErrorResponse} - * @return The ErrorResponse builder. + * @param requestId The requestId of this {@link ErrorResponseStreaming} + * @return The ErrorResponseStreaming builder. */ Builder1 requestId(@Nonnull final String requestId); } @@ -341,10 +344,10 @@ public interface Builder { /** Builder helper class. */ public interface Builder1 { /** - * Set the code of this {@link ErrorResponse} instance. + * Set the code of this {@link ErrorResponseStreaming} instance. * - * @param code The code of this {@link ErrorResponse} - * @return The ErrorResponse builder. + * @param code The code of this {@link ErrorResponseStreaming} + * @return The ErrorResponseStreaming builder. */ Builder2 code(@Nonnull final Integer code); } @@ -352,10 +355,10 @@ public interface Builder1 { /** Builder helper class. */ public interface Builder2 { /** - * Set the message of this {@link ErrorResponse} instance. + * Set the message of this {@link ErrorResponseStreaming} instance. * - * @param message The message of this {@link ErrorResponse} - * @return The ErrorResponse builder. + * @param message The message of this {@link ErrorResponseStreaming} + * @return The ErrorResponseStreaming builder. */ Builder3 message(@Nonnull final String message); } @@ -363,11 +366,11 @@ public interface Builder2 { /** Builder helper class. */ public interface Builder3 { /** - * Set the location of this {@link ErrorResponse} instance. + * Set the location of this {@link ErrorResponseStreaming} instance. * * @param location Where the error occurred - * @return The ErrorResponse instance. + * @return The ErrorResponseStreaming instance. */ - ErrorResponse location(@Nonnull final String location); + ErrorResponseStreaming location(@Nonnull final String location); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseSynchronous.java new file mode 100644 index 000000000..a39ee432a --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseSynchronous.java @@ -0,0 +1,378 @@ +/* + * 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; + +/** ErrorResponseSynchronous */ +// CHECKSTYLE:OFF +public class ErrorResponseSynchronous +// 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 ModuleResultsSynchronous moduleResults; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for ErrorResponseSynchronous. */ + protected ErrorResponseSynchronous() {} + + /** + * Set the requestId of this {@link ErrorResponseSynchronous} instance and return the same + * instance. + * + * @param requestId The requestId of this {@link ErrorResponseSynchronous} + * @return The same instance of this {@link ErrorResponseSynchronous} class + */ + @Nonnull + public ErrorResponseSynchronous requestId(@Nonnull final String requestId) { + this.requestId = requestId; + return this; + } + + /** + * Get requestId + * + * @return requestId The requestId of this {@link ErrorResponseSynchronous} instance. + */ + @Nonnull + public String getRequestId() { + return requestId; + } + + /** + * Set the requestId of this {@link ErrorResponseSynchronous} instance. + * + * @param requestId The requestId of this {@link ErrorResponseSynchronous} + */ + public void setRequestId(@Nonnull final String requestId) { + this.requestId = requestId; + } + + /** + * Set the code of this {@link ErrorResponseSynchronous} instance and return the same instance. + * + * @param code The code of this {@link ErrorResponseSynchronous} + * @return The same instance of this {@link ErrorResponseSynchronous} class + */ + @Nonnull + public ErrorResponseSynchronous code(@Nonnull final Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code The code of this {@link ErrorResponseSynchronous} instance. + */ + @Nonnull + public Integer getCode() { + return code; + } + + /** + * Set the code of this {@link ErrorResponseSynchronous} instance. + * + * @param code The code of this {@link ErrorResponseSynchronous} + */ + public void setCode(@Nonnull final Integer code) { + this.code = code; + } + + /** + * Set the message of this {@link ErrorResponseSynchronous} instance and return the same instance. + * + * @param message The message of this {@link ErrorResponseSynchronous} + * @return The same instance of this {@link ErrorResponseSynchronous} class + */ + @Nonnull + public ErrorResponseSynchronous message(@Nonnull final String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message The message of this {@link ErrorResponseSynchronous} instance. + */ + @Nonnull + public String getMessage() { + return message; + } + + /** + * Set the message of this {@link ErrorResponseSynchronous} instance. + * + * @param message The message of this {@link ErrorResponseSynchronous} + */ + public void setMessage(@Nonnull final String message) { + this.message = message; + } + + /** + * Set the location of this {@link ErrorResponseSynchronous} instance and return the same + * instance. + * + * @param location Where the error occurred + * @return The same instance of this {@link ErrorResponseSynchronous} class + */ + @Nonnull + public ErrorResponseSynchronous location(@Nonnull final String location) { + this.location = location; + return this; + } + + /** + * Where the error occurred + * + * @return location The location of this {@link ErrorResponseSynchronous} instance. + */ + @Nonnull + public String getLocation() { + return location; + } + + /** + * Set the location of this {@link ErrorResponseSynchronous} instance. + * + * @param location Where the error occurred + */ + public void setLocation(@Nonnull final String location) { + this.location = location; + } + + /** + * Set the moduleResults of this {@link ErrorResponseSynchronous} instance and return the same + * instance. + * + * @param moduleResults The moduleResults of this {@link ErrorResponseSynchronous} + * @return The same instance of this {@link ErrorResponseSynchronous} class + */ + @Nonnull + public ErrorResponseSynchronous moduleResults( + @Nullable final ModuleResultsSynchronous moduleResults) { + this.moduleResults = moduleResults; + return this; + } + + /** + * Get moduleResults + * + * @return moduleResults The moduleResults of this {@link ErrorResponseSynchronous} instance. + */ + @Nonnull + public ModuleResultsSynchronous getModuleResults() { + return moduleResults; + } + + /** + * Set the moduleResults of this {@link ErrorResponseSynchronous} instance. + * + * @param moduleResults The moduleResults of this {@link ErrorResponseSynchronous} + */ + public void setModuleResults(@Nullable final ModuleResultsSynchronous moduleResults) { + this.moduleResults = moduleResults; + } + + /** + * Get the names of the unrecognizable properties of the {@link ErrorResponseSynchronous}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ErrorResponseSynchronous} 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( + "ErrorResponseSynchronous has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link ErrorResponseSynchronous} 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 ErrorResponseSynchronous} 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 ErrorResponseSynchronous errorResponseSynchronous = (ErrorResponseSynchronous) o; + return Objects.equals(this.cloudSdkCustomFields, errorResponseSynchronous.cloudSdkCustomFields) + && Objects.equals(this.requestId, errorResponseSynchronous.requestId) + && Objects.equals(this.code, errorResponseSynchronous.code) + && Objects.equals(this.message, errorResponseSynchronous.message) + && Objects.equals(this.location, errorResponseSynchronous.location) + && Objects.equals(this.moduleResults, errorResponseSynchronous.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 ErrorResponseSynchronous {\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 + * ErrorResponseSynchronous} instance with all required arguments. + */ + public static Builder create() { + return (requestId) -> + (code) -> + (message) -> + (location) -> + new ErrorResponseSynchronous() + .requestId(requestId) + .code(code) + .message(message) + .location(location); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the requestId of this {@link ErrorResponseSynchronous} instance. + * + * @param requestId The requestId of this {@link ErrorResponseSynchronous} + * @return The ErrorResponseSynchronous builder. + */ + Builder1 requestId(@Nonnull final String requestId); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the code of this {@link ErrorResponseSynchronous} instance. + * + * @param code The code of this {@link ErrorResponseSynchronous} + * @return The ErrorResponseSynchronous builder. + */ + Builder2 code(@Nonnull final Integer code); + } + + /** Builder helper class. */ + public interface Builder2 { + /** + * Set the message of this {@link ErrorResponseSynchronous} instance. + * + * @param message The message of this {@link ErrorResponseSynchronous} + * @return The ErrorResponseSynchronous builder. + */ + Builder3 message(@Nonnull final String message); + } + + /** Builder helper class. */ + public interface Builder3 { + /** + * Set the location of this {@link ErrorResponseSynchronous} instance. + * + * @param location Where the error occurred + * @return The ErrorResponseSynchronous instance. + */ + ErrorResponseSynchronous location(@Nonnull final String location); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResultsAllOfOutputUnmaskingInner.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java similarity index 79% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResultsAllOfOutputUnmaskingInner.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java index fa92db908..2f2daf275 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseModuleResultsAllOfOutputUnmaskingInner.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; -/** ErrorResponseModuleResultsAllOfOutputUnmaskingInner */ +/** InputFilterConfig */ @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) @JsonSubTypes({ - @JsonSubTypes.Type(value = LLMChoiceStreaming.class), - @JsonSubTypes.Type(value = LLMChoiceSynchronous.class), + @JsonSubTypes.Type(value = AzureContentSafetyInputFilterConfig.class), + @JsonSubTypes.Type(value = LlamaGuard38bFilterConfig.class), }) -public interface ErrorResponseModuleResultsAllOfOutputUnmaskingInner {} +public interface InputFilterConfig {} 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 6d0a1da0e..0ccfaa149 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 @@ -28,7 +28,7 @@ /** LLMChoiceStreaming */ // CHECKSTYLE:OFF -public class LLMChoiceStreaming implements ErrorResponseModuleResultsAllOfOutputUnmaskingInner +public class LLMChoiceStreaming // CHECKSTYLE:ON { @JsonProperty("index") diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceSynchronous.java index ce6222a65..e46730e4b 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceSynchronous.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceSynchronous.java @@ -28,7 +28,7 @@ /** LLMChoiceSynchronous */ // CHECKSTYLE:OFF -public class LLMChoiceSynchronous implements ErrorResponseModuleResultsAllOfOutputUnmaskingInner +public class LLMChoiceSynchronous // CHECKSTYLE:ON { @JsonProperty("index") 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 bc4985f26..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 ErrorResponseModuleResultsAllOfLlm +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 index bede28885..896f2cb73 100644 --- 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 @@ -28,7 +28,7 @@ /** Output of LLM module. Follows the OpenAI spec. */ // CHECKSTYLE:OFF -public class LLMModuleResultSynchronous implements ErrorResponseModuleResultsAllOfLlm +public class LLMModuleResultSynchronous // CHECKSTYLE:ON { @JsonProperty("id") diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java new file mode 100644 index 000000000..a8565a3f5 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.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; + +/** OutputFilterConfig */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = AzureContentSafetyOutputFilterConfig.class), + @JsonSubTypes.Type(value = LlamaGuard38bFilterConfig.class), +}) +public interface OutputFilterConfig {} diff --git a/orchestration/src/main/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index 899a56bb4..1f5b8d89b 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -1328,7 +1328,7 @@ components: description: Language to which the text should be translated. example: "en-US" - ErrorResponse: + ErrorResponseSynchronous: type: object required: - request_id @@ -1344,26 +1344,37 @@ 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 example: "LLM Module" module_results: - allOf: - - $ref: "#/components/schemas/ModuleResultsBase" - - type: object - properties: - llm: - oneOf: - - $ref: "#/components/schemas/LLMModuleResultSynchronous" - - $ref: "#/components/schemas/LLMModuleResultStreaming" - output_unmasking: - type: array - items: - oneOf: - - $ref: "#/components/schemas/LLMChoiceSynchronous" - - $ref: "#/components/schemas/LLMChoiceStreaming" + $ref: "#/components/schemas/ModuleResultsSynchronous" + + 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" responses: BadRequest: @@ -1371,13 +1382,13 @@ components: content: application/json: schema: - $ref: "#/components/schemas/ErrorResponse" + $ref: "#/components/schemas/ErrorResponseSynchronous" CommonError: description: Common Error content: application/json: schema: - $ref: "#/components/schemas/ErrorResponse" + $ref: "#/components/schemas/ErrorResponseSynchronous" # https://pages.github.tools.sap/CPA/api-metadata-validator/rules/oas/sap-oas3-security/ securitySchemes: 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 0cd2e6137..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 @@ -18,10 +18,7 @@ void testToGeneration() { var choice = LLMChoiceStreaming.create() .index(0) - .delta( - ChatDelta.create() - .content("Hello, world!") - .role("")) + .delta(ChatDelta.create().content("Hello, world!").role("")) .finishReason("stop"); Generation generation = OrchestrationSpringChatDelta.toGeneration(choice); 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 fa7147406..b4d915b77 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 @@ -17,11 +17,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; @@ -91,7 +88,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); @@ -106,7 +103,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); @@ -124,10 +121,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") @@ -135,8 +129,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(); @@ -155,8 +148,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") @@ -173,7 +165,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"); @@ -185,8 +177,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(); @@ -201,8 +192,7 @@ void testGrounding() { 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(); } @@ -281,7 +271,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(); } @@ -300,7 +290,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(); } @@ -311,21 +301,21 @@ 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(); } @Test void testResponseFormatJsonSchema() { val result = service.responseFormatJsonSchema("apple").getOriginalResponse(); - val choices = ((LLMModuleResultSynchronous) result.getOrchestrationResult()).getChoices(); + val choices = (result.getOrchestrationResult()).getChoices(); assertThat(choices.get(0).getMessage().getContent()).isNotEmpty(); } @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\":"); @@ -334,14 +324,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(); } @@ -349,7 +339,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(); } @@ -360,7 +350,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(); } From 224fbc20c382282df8eff6f9d653e3f0517a873b Mon Sep 17 00:00:00 2001 From: I538344 Date: Wed, 4 Jun 2025 14:08:32 +0200 Subject: [PATCH 04/12] regenerate --- .../model/AzureContentSafetyInput.java | 320 ------------------ .../AzureContentSafetyInputFilterConfig.java | 286 ---------------- .../model/AzureContentSafetyOutput.java | 284 ---------------- .../AzureContentSafetyOutputFilterConfig.java | 286 ---------------- .../orchestration/model/DPICustomEntity.java | 240 ------------- .../DPICustomEntityReplacementStrategy.java | 22 -- .../model/InputFilterConfig.java | 23 -- .../model/OutputFilterConfig.java | 23 -- 8 files changed, 1484 deletions(-) delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInput.java delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutputFilterConfig.java delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntityReplacementStrategy.java delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java 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 deleted file mode 100644 index 4c4ccd4af..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInput.java +++ /dev/null @@ -1,320 +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.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/AzureContentSafetyInputFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java deleted file mode 100644 index 3de44c4d5..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInputFilterConfig.java +++ /dev/null @@ -1,286 +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.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; - -/** AzureContentSafetyInputFilterConfig */ -// CHECKSTYLE:OFF -public class AzureContentSafetyInputFilterConfig implements InputFilterConfig -// CHECKSTYLE:ON -{ - /** Name of the filter provider type */ - public enum TypeEnum { - /** The AZURE_CONTENT_SAFETY option of this AzureContentSafetyInputFilterConfig */ - AZURE_CONTENT_SAFETY("azure_content_safety"), - - /** The UNKNOWN_DEFAULT_OPEN_API option of this AzureContentSafetyInputFilterConfig */ - 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 AzureContentSafetyInputFilterConfig - */ - @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 AzureContentSafetyInput config; - - @JsonAnySetter @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** Default constructor for AzureContentSafetyInputFilterConfig. */ - protected AzureContentSafetyInputFilterConfig() {} - - /** - * 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 AzureContentSafetyInputFilterConfig} class - */ - @Nonnull - public AzureContentSafetyInputFilterConfig type(@Nonnull final TypeEnum type) { - this.type = type; - return this; - } - - /** - * Name of the filter provider type - * - * @return type The type of this {@link AzureContentSafetyInputFilterConfig} instance. - */ - @Nonnull - public TypeEnum getType() { - return type; - } - - /** - * Set the type of this {@link AzureContentSafetyInputFilterConfig} 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 AzureContentSafetyInputFilterConfig} instance and return the same - * instance. - * - * @param config The config of this {@link AzureContentSafetyInputFilterConfig} - * @return The same instance of this {@link AzureContentSafetyInputFilterConfig} class - */ - @Nonnull - public AzureContentSafetyInputFilterConfig config( - @Nullable final AzureContentSafetyInput config) { - this.config = config; - return this; - } - - /** - * Get config - * - * @return config The config of this {@link AzureContentSafetyInputFilterConfig} instance. - */ - @Nonnull - public AzureContentSafetyInput getConfig() { - return config; - } - - /** - * Set the config of this {@link AzureContentSafetyInputFilterConfig} instance. - * - * @param config The config of this {@link AzureContentSafetyInputFilterConfig} - */ - public void setConfig(@Nullable final AzureContentSafetyInput config) { - this.config = config; - } - - /** - * Get the names of the unrecognizable properties of the {@link - * AzureContentSafetyInputFilterConfig}. - * - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link AzureContentSafetyInputFilterConfig} - * 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( - "AzureContentSafetyInputFilterConfig has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Get the value of all properties of this {@link AzureContentSafetyInputFilterConfig} 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 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 - * @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 AzureContentSafetyInputFilterConfig azureContentSafetyInputFilterConfig = - (AzureContentSafetyInputFilterConfig) o; - return Objects.equals( - this.cloudSdkCustomFields, azureContentSafetyInputFilterConfig.cloudSdkCustomFields) - && Objects.equals(this.type, azureContentSafetyInputFilterConfig.type) - && Objects.equals(this.config, azureContentSafetyInputFilterConfig.config); - } - - @Override - public int hashCode() { - return Objects.hash(type, config, cloudSdkCustomFields); - } - - @Override - @Nonnull - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class AzureContentSafetyInputFilterConfig {\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 - * AzureContentSafetyInputFilterConfig} instance with all required arguments. - */ - public static Builder create() { - return (type) -> new AzureContentSafetyInputFilterConfig().type(type); - } - - /** Builder helper class. */ - public interface Builder { - /** - * Set the type of this {@link AzureContentSafetyInputFilterConfig} instance. - * - * @param type Name of the filter provider type - * @return The AzureContentSafetyInputFilterConfig instance. - */ - AzureContentSafetyInputFilterConfig type(@Nonnull final TypeEnum type); - } -} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java deleted file mode 100644 index f428f183a..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutput.java +++ /dev/null @@ -1,284 +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.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 AzureContentSafetyOutput -// CHECKSTYLE:ON -{ - @JsonProperty("Hate") - private AzureThreshold hate; - - @JsonProperty("SelfHarm") - private AzureThreshold selfHarm; - - @JsonProperty("Sexual") - private AzureThreshold sexual; - - @JsonProperty("Violence") - private AzureThreshold violence; - - @JsonAnySetter @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** Default constructor for AzureContentSafetyOutput. */ - protected AzureContentSafetyOutput() {} - - /** - * Set the hate of this {@link AzureContentSafetyOutput} instance and return the same instance. - * - * @param hate The hate of this {@link AzureContentSafetyOutput} - * @return The same instance of this {@link AzureContentSafetyOutput} class - */ - @Nonnull - public AzureContentSafetyOutput hate(@Nullable final AzureThreshold hate) { - this.hate = hate; - return this; - } - - /** - * Get hate - * - * @return hate The hate of this {@link AzureContentSafetyOutput} instance. - */ - @Nonnull - public AzureThreshold getHate() { - return hate; - } - - /** - * Set the hate of this {@link AzureContentSafetyOutput} instance. - * - * @param hate The hate of this {@link AzureContentSafetyOutput} - */ - public void setHate(@Nullable final AzureThreshold hate) { - this.hate = hate; - } - - /** - * Set the selfHarm of this {@link AzureContentSafetyOutput} instance and return the same - * instance. - * - * @param selfHarm The selfHarm of this {@link AzureContentSafetyOutput} - * @return The same instance of this {@link AzureContentSafetyOutput} class - */ - @Nonnull - public AzureContentSafetyOutput selfHarm(@Nullable final AzureThreshold selfHarm) { - this.selfHarm = selfHarm; - return this; - } - - /** - * Get selfHarm - * - * @return selfHarm The selfHarm of this {@link AzureContentSafetyOutput} instance. - */ - @Nonnull - public AzureThreshold getSelfHarm() { - return selfHarm; - } - - /** - * Set the selfHarm of this {@link AzureContentSafetyOutput} instance. - * - * @param selfHarm The selfHarm of this {@link AzureContentSafetyOutput} - */ - public void setSelfHarm(@Nullable final AzureThreshold selfHarm) { - this.selfHarm = selfHarm; - } - - /** - * Set the sexual of this {@link AzureContentSafetyOutput} instance and return the same instance. - * - * @param sexual The sexual of this {@link AzureContentSafetyOutput} - * @return The same instance of this {@link AzureContentSafetyOutput} class - */ - @Nonnull - public AzureContentSafetyOutput sexual(@Nullable final AzureThreshold sexual) { - this.sexual = sexual; - return this; - } - - /** - * Get sexual - * - * @return sexual The sexual of this {@link AzureContentSafetyOutput} instance. - */ - @Nonnull - public AzureThreshold getSexual() { - return sexual; - } - - /** - * Set the sexual of this {@link AzureContentSafetyOutput} instance. - * - * @param sexual The sexual of this {@link AzureContentSafetyOutput} - */ - public void setSexual(@Nullable final AzureThreshold sexual) { - this.sexual = sexual; - } - - /** - * Set the violence of this {@link AzureContentSafetyOutput} instance and return the same - * instance. - * - * @param violence The violence of this {@link AzureContentSafetyOutput} - * @return The same instance of this {@link AzureContentSafetyOutput} class - */ - @Nonnull - public AzureContentSafetyOutput violence(@Nullable final AzureThreshold violence) { - this.violence = violence; - return this; - } - - /** - * Get violence - * - * @return violence The violence of this {@link AzureContentSafetyOutput} instance. - */ - @Nonnull - public AzureThreshold getViolence() { - return violence; - } - - /** - * Set the violence of this {@link AzureContentSafetyOutput} instance. - * - * @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 AzureContentSafetyOutput}. - * - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link AzureContentSafetyOutput} 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( - "AzureContentSafetyOutput has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Get the value of all properties of this {@link AzureContentSafetyOutput} 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); - return declaredFields; - } - - /** - * 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 - * @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 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 - public int hashCode() { - return Objects.hash(hate, selfHarm, sexual, violence, cloudSdkCustomFields); - } - - @Override - @Nonnull - public String toString() { - final StringBuilder sb = new StringBuilder(); - 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"); - sb.append(" violence: ").append(toIndentedString(violence)).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 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 deleted file mode 100644 index c083b6c20..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutputFilterConfig.java +++ /dev/null @@ -1,286 +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.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/DPICustomEntity.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java deleted file mode 100644 index 25ed33a75..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java +++ /dev/null @@ -1,240 +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.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 DPICustomEntityReplacementStrategy 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 DPICustomEntityReplacementStrategy replacementStrategy) { - this.replacementStrategy = replacementStrategy; - return this; - } - - /** - * Get replacementStrategy - * - * @return replacementStrategy The replacementStrategy of this {@link DPICustomEntity} instance. - */ - @Nonnull - public DPICustomEntityReplacementStrategy getReplacementStrategy() { - return replacementStrategy; - } - - /** - * Set the replacementStrategy of this {@link DPICustomEntity} instance. - * - * @param replacementStrategy The replacementStrategy of this {@link DPICustomEntity} - */ - public void setReplacementStrategy( - @Nonnull final DPICustomEntityReplacementStrategy 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 DPICustomEntityReplacementStrategy replacementStrategy); - } -} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntityReplacementStrategy.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntityReplacementStrategy.java deleted file mode 100644 index 42ede0a51..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntityReplacementStrategy.java +++ /dev/null @@ -1,22 +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.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), -}) -public interface DPICustomEntityReplacementStrategy {} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java deleted file mode 100644 index 2f2daf275..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/InputFilterConfig.java +++ /dev/null @@ -1,23 +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.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -/** InputFilterConfig */ -@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) -@JsonSubTypes({ - @JsonSubTypes.Type(value = AzureContentSafetyInputFilterConfig.class), - @JsonSubTypes.Type(value = LlamaGuard38bFilterConfig.class), -}) -public interface InputFilterConfig {} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java deleted file mode 100644 index a8565a3f5..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java +++ /dev/null @@ -1,23 +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.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -/** OutputFilterConfig */ -@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) -@JsonSubTypes({ - @JsonSubTypes.Type(value = AzureContentSafetyOutputFilterConfig.class), - @JsonSubTypes.Type(value = LlamaGuard38bFilterConfig.class), -}) -public interface OutputFilterConfig {} From 494855e6339db15f5cceb9471804a96edd9cb184 Mon Sep 17 00:00:00 2001 From: I538344 Date: Wed, 4 Jun 2025 14:57:54 +0200 Subject: [PATCH 05/12] regenerate --- .../sap/ai/sdk/orchestration/DpiMasking.java | 4 ++-- .../ai/sdk/orchestration/model/DPIConfig.java | 14 ++++++------ .../orchestration/model/DPIEntityConfig.java | 22 ------------------- .../model/DPIStandardEntity.java | 2 +- .../OrchestrationModuleConfigTest.java | 6 ++--- .../app/controllers/OrchestrationTest.java | 3 +-- 6 files changed, 13 insertions(+), 38 deletions(-) delete mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java 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..e18eee2ea 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 @@ -7,7 +7,7 @@ import com.sap.ai.sdk.orchestration.model.DPIConfig; 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 +95,7 @@ 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 -> 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/model/DPIConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIConfig.java index 27187f1dc..5f708653b 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIConfig.java @@ -151,7 +151,7 @@ public static MethodEnum fromValue(@Nonnull final String value) { private MethodEnum method; @JsonProperty("entities") - private List entities = new ArrayList<>(); + private List entities = new ArrayList<>(); @JsonProperty("allowlist") private List allowlist = new ArrayList<>(); @@ -234,7 +234,7 @@ public void setMethod(@Nonnull final MethodEnum method) { * @return The same instance of this {@link DPIConfig} class */ @Nonnull - public DPIConfig entities(@Nonnull final List entities) { + public DPIConfig entities(@Nonnull final List entities) { this.entities = entities; return this; } @@ -246,7 +246,7 @@ public DPIConfig entities(@Nonnull final List entities) { * @return The same instance of type {@link DPIConfig} */ @Nonnull - public DPIConfig addEntitiesItem(@Nonnull final DPIEntityConfig entitiesItem) { + public DPIConfig addEntitiesItem(@Nonnull final DPIStandardEntity entitiesItem) { if (this.entities == null) { this.entities = new ArrayList<>(); } @@ -260,7 +260,7 @@ public DPIConfig addEntitiesItem(@Nonnull final DPIEntityConfig entitiesItem) { * @return entities The entities of this {@link DPIConfig} instance. */ @Nonnull - public List getEntities() { + public List getEntities() { return entities; } @@ -269,7 +269,7 @@ public List getEntities() { * * @param entities List of entities to be masked */ - public void setEntities(@Nonnull final List entities) { + public void setEntities(@Nonnull final List entities) { this.entities = entities; } @@ -499,7 +499,7 @@ public interface Builder2 { * @param entities List of entities to be masked * @return The DPIConfig instance. */ - DPIConfig entities(@Nonnull final List entities); + DPIConfig entities(@Nonnull final List entities); /** * Set the entities of this {@link DPIConfig} instance. @@ -507,7 +507,7 @@ public interface Builder2 { * @param entities List of entities to be masked * @return The DPIConfig instance. */ - default DPIConfig entities(@Nonnull final DPIEntityConfig... entities) { + default DPIConfig entities(@Nonnull final DPIStandardEntity... entities) { return entities(Arrays.asList(entities)); } } 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 deleted file mode 100644 index bfceb38eb..000000000 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java +++ /dev/null @@ -1,22 +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.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -/** DPIEntityConfig */ -@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) -@JsonSubTypes({ - @JsonSubTypes.Type(value = DPIStandardEntity.class), -}) -public interface DPIEntityConfig {} 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 index 2b93c0692..e21e6fcc2 100644 --- 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 @@ -25,7 +25,7 @@ /** DPIStandardEntity */ // CHECKSTYLE:OFF -public class DPIStandardEntity implements DPIEntityConfig +public class DPIStandardEntity // CHECKSTYLE:ON { @JsonProperty("type") 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 0bca15acd..4cd13fcf9 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,7 +11,6 @@ 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; @@ -88,11 +87,10 @@ 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(((DPIStandardEntity) dpiConfig.getEntities().get(0)).getType()) - .isEqualTo(DPIEntities.ADDRESS); + assertThat(dpiConfig.getEntities().get(0).getType()).isEqualTo(DPIEntities.ADDRESS); assertThat(dpiConfig.getMaskGroundingInput().isEnabled()).isEqualTo(true); assertThat(dpiConfig.getAllowlist()).containsExactly("Alice"); 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 683185aea..66b672d7b 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 @@ -195,8 +195,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@/"); } From e327c1b90050c0c688a582b42ae89f880b43ed54 Mon Sep 17 00:00:00 2001 From: I538344 Date: Wed, 4 Jun 2025 15:53:27 +0200 Subject: [PATCH 06/12] DPI --- .../sap/ai/sdk/orchestration/DpiMasking.java | 4 +- .../ai/sdk/orchestration/model/DPIConfig.java | 14 +- .../orchestration/model/DPICustomEntity.java | 237 ++++++++++++++++++ .../orchestration/model/DPIEntityConfig.java | 23 ++ .../model/DPIStandardEntity.java | 2 +- .../model/TemplateResponseFormat.java | 3 +- .../main/resources/spec/orchestration.yaml | 24 +- .../OrchestrationModuleConfigTest.java | 4 +- 8 files changed, 294 insertions(+), 17 deletions(-) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPICustomEntity.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java 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 e18eee2ea..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 @@ -7,6 +7,7 @@ import com.sap.ai.sdk.orchestration.model.DPIConfig; 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; @@ -95,7 +96,8 @@ public DpiMasking withAllowList(@Nonnull final List allowList) { @Nonnull @Override public DPIConfig createConfig() { - val entitiesDTO = entities.stream().map(it -> DPIStandardEntity.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/model/DPIConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIConfig.java index 5f708653b..27187f1dc 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIConfig.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIConfig.java @@ -151,7 +151,7 @@ public static MethodEnum fromValue(@Nonnull final String value) { private MethodEnum method; @JsonProperty("entities") - private List entities = new ArrayList<>(); + private List entities = new ArrayList<>(); @JsonProperty("allowlist") private List allowlist = new ArrayList<>(); @@ -234,7 +234,7 @@ public void setMethod(@Nonnull final MethodEnum method) { * @return The same instance of this {@link DPIConfig} class */ @Nonnull - public DPIConfig entities(@Nonnull final List entities) { + public DPIConfig entities(@Nonnull final List entities) { this.entities = entities; return this; } @@ -246,7 +246,7 @@ public DPIConfig entities(@Nonnull final List entities) { * @return The same instance of type {@link DPIConfig} */ @Nonnull - public DPIConfig addEntitiesItem(@Nonnull final DPIStandardEntity entitiesItem) { + public DPIConfig addEntitiesItem(@Nonnull final DPIEntityConfig entitiesItem) { if (this.entities == null) { this.entities = new ArrayList<>(); } @@ -260,7 +260,7 @@ public DPIConfig addEntitiesItem(@Nonnull final DPIStandardEntity entitiesItem) * @return entities The entities of this {@link DPIConfig} instance. */ @Nonnull - public List getEntities() { + public List getEntities() { return entities; } @@ -269,7 +269,7 @@ public List getEntities() { * * @param entities List of entities to be masked */ - public void setEntities(@Nonnull final List entities) { + public void setEntities(@Nonnull final List entities) { this.entities = entities; } @@ -499,7 +499,7 @@ public interface Builder2 { * @param entities List of entities to be masked * @return The DPIConfig instance. */ - DPIConfig entities(@Nonnull final List entities); + DPIConfig entities(@Nonnull final List entities); /** * Set the entities of this {@link DPIConfig} instance. @@ -507,7 +507,7 @@ public interface Builder2 { * @param entities List of entities to be masked * @return The DPIConfig instance. */ - default DPIConfig entities(@Nonnull final DPIStandardEntity... entities) { + default DPIConfig entities(@Nonnull final DPIEntityConfig... entities) { return entities(Arrays.asList(entities)); } } 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/DPIEntityConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.java new file mode 100644 index 000000000..5448e04cb --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIEntityConfig.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; + +/** DPIEntityConfig */ +@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/DPIStandardEntity.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/DPIStandardEntity.java index e21e6fcc2..2b93c0692 100644 --- 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 @@ -25,7 +25,7 @@ /** DPIStandardEntity */ // CHECKSTYLE:OFF -public class DPIStandardEntity +public class DPIStandardEntity implements DPIEntityConfig // CHECKSTYLE:ON { @JsonProperty("type") 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/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index 1f5b8d89b..533e3d7d5 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -195,7 +195,7 @@ components: - 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. + # 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: @@ -453,7 +453,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 @@ -510,7 +510,7 @@ components: model: type: string description: Model name - example: "gpt-4" + example: "gpt-4o-mini" system_fingerprint: type: string description: System fingerprint @@ -649,8 +649,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" @@ -1052,6 +1050,22 @@ components: 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 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 4cd13fcf9..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; @@ -90,7 +91,8 @@ void testDpiMaskingConfig() { 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"); From e62952d63df17a252fb85f6e0eb1c677d84e3ea3 Mon Sep 17 00:00:00 2001 From: Roshin Rajan Panackal <36329474+rpanackal@users.noreply.github.com> Date: Wed, 18 Jun 2025 14:37:34 +0200 Subject: [PATCH 07/12] feat: Add embeddings endpoint and refactor orchestration client (#464) Co-authored-by: Roshin Rajan Panackal --- .../orchestration/OrchestrationClient.java | 112 +---- .../OrchestrationHttpExecutor.java | 98 +++++ .../ai/sdk/orchestration/model/Embedding.java | 52 +++ .../orchestration/model/EmbeddingResult.java | 338 ++++++++++++++ .../orchestration/model/EmbeddingsInput.java | 283 ++++++++++++ .../model/EmbeddingsInputText.java | 50 +++ .../model/EmbeddingsModelConfig.java | 185 ++++++++ .../model/EmbeddingsModelDetails.java | 259 +++++++++++ .../model/EmbeddingsModelParams.java | 313 +++++++++++++ .../model/EmbeddingsModuleConfigs.java | 223 ++++++++++ .../model/EmbeddingsOrchestrationConfig.java | 192 ++++++++ .../model/EmbeddingsPostRequest.java | 241 ++++++++++ .../model/EmbeddingsPostResponse.java | 265 +++++++++++ .../model/EmbeddingsResponse.java | 416 ++++++++++++++++++ .../orchestration/model/EmbeddingsUsage.java | 233 ++++++++++ .../main/resources/spec/orchestration.yaml | 209 ++++++++- .../orchestration/OrchestrationUnitTest.java | 167 +++++++ 17 files changed, 3541 insertions(+), 95 deletions(-) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Embedding.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingResult.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInput.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsInputText.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelConfig.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelDetails.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModelParams.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsModuleConfigs.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsOrchestrationConfig.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostRequest.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostResponse.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsResponse.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsUsage.java 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 999d3161c..1b6434a05 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.CompletionPostResponseSynchronous; +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 CompletionPostResponseSynchronous 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, CompletionPostResponseSynchronous.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 - CompletionPostResponseSynchronous 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<>( - CompletionPostResponseSynchronous.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, CompletionPostResponseSynchronous.class)); } /** @@ -245,42 +197,20 @@ CompletionPostResponseSynchronous 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); - } + public 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/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..622f65162 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsOrchestrationConfig.java @@ -0,0 +1,192 @@ +/* + * 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("module_configs") + private EmbeddingsModuleConfigs moduleConfigs; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsOrchestrationConfig. */ + protected EmbeddingsOrchestrationConfig() {} + + /** + * Set the moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance and return the + * same instance. + * + * @param moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} + * @return The same instance of this {@link EmbeddingsOrchestrationConfig} class + */ + @Nonnull + public EmbeddingsOrchestrationConfig moduleConfigs( + @Nonnull final EmbeddingsModuleConfigs moduleConfigs) { + this.moduleConfigs = moduleConfigs; + return this; + } + + /** + * Get moduleConfigs + * + * @return moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance. + */ + @Nonnull + public EmbeddingsModuleConfigs getModuleConfigs() { + return moduleConfigs; + } + + /** + * Set the moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance. + * + * @param moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} + */ + public void setModuleConfigs(@Nonnull final EmbeddingsModuleConfigs moduleConfigs) { + this.moduleConfigs = moduleConfigs; + } + + /** + * 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 (moduleConfigs != null) declaredFields.put("moduleConfigs", moduleConfigs); + 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.moduleConfigs, embeddingsOrchestrationConfig.moduleConfigs); + } + + @Override + public int hashCode() { + return Objects.hash(moduleConfigs, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsOrchestrationConfig {\n"); + sb.append(" moduleConfigs: ").append(toIndentedString(moduleConfigs)).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 (moduleConfigs) -> new EmbeddingsOrchestrationConfig().moduleConfigs(moduleConfigs); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance. + * + * @param moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} + * @return The EmbeddingsOrchestrationConfig instance. + */ + EmbeddingsOrchestrationConfig moduleConfigs( + @Nonnull final EmbeddingsModuleConfigs moduleConfigs); + } +} 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..850108088 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsPostRequest.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.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("orchestration_config") + private EmbeddingsOrchestrationConfig orchestrationConfig; + + @JsonProperty("input") + private EmbeddingsInput input; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for EmbeddingsPostRequest. */ + protected EmbeddingsPostRequest() {} + + /** + * Set the orchestrationConfig of this {@link EmbeddingsPostRequest} instance and return the same + * instance. + * + * @param orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} + * @return The same instance of this {@link EmbeddingsPostRequest} class + */ + @Nonnull + public EmbeddingsPostRequest orchestrationConfig( + @Nonnull final EmbeddingsOrchestrationConfig orchestrationConfig) { + this.orchestrationConfig = orchestrationConfig; + return this; + } + + /** + * Get orchestrationConfig + * + * @return orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} + * instance. + */ + @Nonnull + public EmbeddingsOrchestrationConfig getOrchestrationConfig() { + return orchestrationConfig; + } + + /** + * Set the orchestrationConfig of this {@link EmbeddingsPostRequest} instance. + * + * @param orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} + */ + public void setOrchestrationConfig( + @Nonnull final EmbeddingsOrchestrationConfig orchestrationConfig) { + this.orchestrationConfig = orchestrationConfig; + } + + /** + * 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 (orchestrationConfig != null) declaredFields.put("orchestrationConfig", orchestrationConfig); + 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.orchestrationConfig, embeddingsPostRequest.orchestrationConfig) + && Objects.equals(this.input, embeddingsPostRequest.input); + } + + @Override + public int hashCode() { + return Objects.hash(orchestrationConfig, input, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsPostRequest {\n"); + sb.append(" orchestrationConfig: ") + .append(toIndentedString(orchestrationConfig)) + .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 (orchestrationConfig) -> + (input) -> + new EmbeddingsPostRequest().orchestrationConfig(orchestrationConfig).input(input); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the orchestrationConfig of this {@link EmbeddingsPostRequest} instance. + * + * @param orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} + * @return The EmbeddingsPostRequest builder. + */ + Builder1 orchestrationConfig(@Nonnull final EmbeddingsOrchestrationConfig orchestrationConfig); + } + + /** 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..7ef0372d2 --- /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("module_results") + private ModuleResultsBase moduleResults; + + @JsonProperty("orchestration_result") + private EmbeddingsResponse orchestrationResult; + + @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 moduleResults of this {@link EmbeddingsPostResponse} instance and return the same + * instance. + * + * @param moduleResults The moduleResults of this {@link EmbeddingsPostResponse} + * @return The same instance of this {@link EmbeddingsPostResponse} class + */ + @Nonnull + public EmbeddingsPostResponse moduleResults(@Nullable final ModuleResultsBase moduleResults) { + this.moduleResults = moduleResults; + return this; + } + + /** + * Get moduleResults + * + * @return moduleResults The moduleResults of this {@link EmbeddingsPostResponse} instance. + */ + @Nonnull + public ModuleResultsBase getModuleResults() { + return moduleResults; + } + + /** + * Set the moduleResults of this {@link EmbeddingsPostResponse} instance. + * + * @param moduleResults The moduleResults of this {@link EmbeddingsPostResponse} + */ + public void setModuleResults(@Nullable final ModuleResultsBase moduleResults) { + this.moduleResults = moduleResults; + } + + /** + * Set the orchestrationResult of this {@link EmbeddingsPostResponse} instance and return the same + * instance. + * + * @param orchestrationResult The orchestrationResult of this {@link EmbeddingsPostResponse} + * @return The same instance of this {@link EmbeddingsPostResponse} class + */ + @Nonnull + public EmbeddingsPostResponse orchestrationResult( + @Nullable final EmbeddingsResponse orchestrationResult) { + this.orchestrationResult = orchestrationResult; + return this; + } + + /** + * Get orchestrationResult + * + * @return orchestrationResult The orchestrationResult of this {@link EmbeddingsPostResponse} + * instance. + */ + @Nonnull + public EmbeddingsResponse getOrchestrationResult() { + return orchestrationResult; + } + + /** + * Set the orchestrationResult of this {@link EmbeddingsPostResponse} instance. + * + * @param orchestrationResult The orchestrationResult of this {@link EmbeddingsPostResponse} + */ + public void setOrchestrationResult(@Nullable final EmbeddingsResponse orchestrationResult) { + this.orchestrationResult = orchestrationResult; + } + + /** + * 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 (moduleResults != null) declaredFields.put("moduleResults", moduleResults); + if (orchestrationResult != null) declaredFields.put("orchestrationResult", orchestrationResult); + 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.moduleResults, embeddingsPostResponse.moduleResults) + && Objects.equals(this.orchestrationResult, embeddingsPostResponse.orchestrationResult); + } + + @Override + public int hashCode() { + return Objects.hash(requestId, moduleResults, orchestrationResult, 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(" moduleResults: ").append(toIndentedString(moduleResults)).append("\n"); + sb.append(" orchestrationResult: ") + .append(toIndentedString(orchestrationResult)) + .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..7cd0f3140 --- /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; + +/** EmbeddingsResponse */ +// 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/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index 533e3d7d5..4bddce366 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -9,15 +9,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 @@ -45,6 +42,34 @@ paths: 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: @@ -66,6 +91,182 @@ 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 + - orchestration_config + properties: + orchestration_config: + $ref: "#/components/schemas/EmbeddingsOrchestrationConfig" + input: + $ref: "#/components/schemas/EmbeddingsInput" + EmbeddingsOrchestrationConfig: + type: object + required: + - module_configs + additionalProperties: false + properties: + module_configs: + $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 + module_results: + $ref: "#/components/schemas/ModuleResultsBase" + description: Results of each module of /embeddings endpoint(e.g. input masking). + orchestration_result: + $ref: "#/components/schemas/EmbeddingsResponse" + description: The response from request to embedding model following OpenAI specification. + EmbeddingsResponse: + type: object + 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: 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 d6d41a3e1..8b7ab32bb 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; @@ -38,15 +39,29 @@ 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.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; @@ -1054,4 +1070,155 @@ 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", + "module_results": { + "input_masking": { + "message": "Embedding input is masked successfully.", + "data": { + "masked_input": "['Hello', 'MASKED_PERSON', '!']" + } + } + }, + "orchestration_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() + .moduleConfigs( + EmbeddingsModuleConfigs.create().embeddings(modelConfig).masking(maskingConfig)); + + val inputText = + EmbeddingsInput.create().text(EmbeddingsInputText.create("['Hello', 'Müller', '!']")); + + val request = + EmbeddingsPostRequest.create().orchestrationConfig(orchestrationConfig).input(inputText); + + EmbeddingsPostResponse response = client.embed(request); + + assertThat(response).isNotNull(); + assertThat(response.getRequestId()).isEqualTo("2ee98443-e1ee-9503-b800-e38b5b80fe45"); + + val orchestrationResult = response.getOrchestrationResult(); + 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.getModuleResults(); + 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( + """ + { + "orchestration_config": { + "module_configs": { + "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', '!']" + } + } + """))); + } } From b54ab6e16dbf469c6cb53e7a94a15b5a3ab50762 Mon Sep 17 00:00:00 2001 From: Roshin Rajan Panackal <36329474+rpanackal@users.noreply.github.com> Date: Tue, 1 Jul 2025 11:07:08 +0200 Subject: [PATCH 08/12] fix: [Orchestration] Spec update - Filtering, Remove "Synchronous" suffix and Embedding property renaming (#469) * Introduce filtering schema changes and update generated class names - synchronous suffix removed - `createConfig` removed from `ContentFilter` - release notes updated for filtering changes * Introduce filtering schema changes and update generated class names - synchronous suffix removed - `createConfig` removed from `ContentFilter` - release notes updated for filtering changes * Release notes and jacoco coverage work around * Lower min required jacoco coverage complexity and branch rating. - Release note paraphrasing * Update e2e for input filters --------- Co-authored-by: Roshin Rajan Panackal --- docs/release_notes.md | 3 +- orchestration/pom.xml | 4 +- .../sdk/orchestration/AzureContentFilter.java | 48 ++- .../ai/sdk/orchestration/ContentFilter.java | 18 +- .../ai/sdk/orchestration/JacksonMixins.java | 4 +- .../sdk/orchestration/LlamaGuardFilter.java | 8 +- .../OrchestrationChatResponse.java | 10 +- .../orchestration/OrchestrationClient.java | 10 +- .../sdk/orchestration/OrchestrationError.java | 4 +- .../OrchestrationModuleConfig.java | 10 +- .../model/AzureContentSafetyInput.java | 320 ++++++++++++++++++ ... AzureContentSafetyInputFilterConfig.java} | 80 ++--- ...ety.java => AzureContentSafetyOutput.java} | 95 +++--- .../AzureContentSafetyOutputFilterConfig.java | 286 ++++++++++++++++ ...onous.java => CompletionPostResponse.java} | 132 ++++---- .../model/EmbeddingsOrchestrationConfig.java | 48 ++- .../model/EmbeddingsPostRequest.java | 52 ++- .../model/EmbeddingsPostResponse.java | 76 ++--- ...nseSynchronous.java => ErrorResponse.java} | 145 ++++---- ...lterConfig.java => InputFilterConfig.java} | 6 +- .../model/InputFilteringConfig.java | 24 +- ...MChoiceSynchronous.java => LLMChoice.java} | 110 +++--- ...tSynchronous.java => LLMModuleResult.java} | 178 +++++----- .../model/LlamaGuard38bFilterConfig.java | 2 +- ...ltsSynchronous.java => ModuleResults.java} | 217 ++++++------ .../model/OutputFilterConfig.java | 23 ++ .../model/OutputFilteringConfig.java | 24 +- .../OrchestrationSpringChatResponse.java | 10 +- .../main/resources/spec/orchestration.yaml | 100 ++++-- .../LLMModuleResultDeserializerTest.java | 6 +- .../orchestration/OrchestrationUnitTest.java | 17 +- .../spring/OrchestrationChatResponseTest.java | 8 +- .../app/services/OrchestrationService.java | 2 +- 33 files changed, 1374 insertions(+), 706 deletions(-) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyInput.java rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{AzureContentSafetyFilterConfig.java => AzureContentSafetyInputFilterConfig.java} (71%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{AzureContentSafety.java => AzureContentSafetyOutput.java} (72%) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/AzureContentSafetyOutputFilterConfig.java rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{CompletionPostResponseSynchronous.java => CompletionPostResponse.java} (68%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{ErrorResponseSynchronous.java => ErrorResponse.java} (63%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{FilterConfig.java => InputFilterConfig.java} (88%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{LLMChoiceSynchronous.java => LLMChoice.java} (69%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{LLMModuleResultSynchronous.java => LLMModuleResult.java} (60%) rename orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/{ModuleResultsSynchronous.java => ModuleResults.java} (63%) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java diff --git a/docs/release_notes.md b/docs/release_notes.md index 10d109839..24c0576ec 100644 --- a/docs/release_notes.md +++ b/docs/release_notes.md @@ -18,10 +18,11 @@ Interfaces with only one implementation were reduced. 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] The method `createConfig()` is removed from `ContentFilter`, `AzureContentFilter` and `LlamaGuardFilter` and is replaced by `createInputFilterConfig()` and `createOutputFilterConfig()`. ### ✨ New Functionality -- +- [Orchestration] Added `AzureContentFilter#promptShield()` available for input filtering. ### 📈 Improvements diff --git a/orchestration/pom.xml b/orchestration/pom.xml index 5424fb30d..69ae93798 100644 --- a/orchestration/pom.xml +++ b/orchestration/pom.xml @@ -31,10 +31,10 @@ ${project.basedir}/../ - 84% + 82% 94% 95% - 79% + 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..248ae082a 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; @@ -46,24 +48,52 @@ public class AzureContentFilter implements ContentFilter { /* The filter category for violence content. */ @Nullable AzureFilterThreshold violence; + /* A flag to set prompt shield on input filer.*/ + @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 {@code AzureContentFilter} to its serializable counterpart {@link - * AzureContentSafetyFilterConfig}. + * Converts {@link AzureContentFilter} to its serializable counterpart {@link + * AzureContentSafetyOutput}. * - * @return the corresponding {@code AzureContentSafetyFilterConfig} object. + * @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/JacksonMixins.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/JacksonMixins.java index 73ec77f36..5e43c5a1b 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 @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMModuleResult; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -11,7 +11,7 @@ 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 {} @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) 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/OrchestrationChatResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationChatResponse.java index 1ea0d40b4..908fecedd 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 @@ -5,8 +5,8 @@ import com.sap.ai.sdk.orchestration.model.AssistantChatMessage; import com.sap.ai.sdk.orchestration.model.ChatMessage; import com.sap.ai.sdk.orchestration.model.ChatMessageContent; -import com.sap.ai.sdk.orchestration.model.CompletionPostResponseSynchronous; -import com.sap.ai.sdk.orchestration.model.LLMChoiceSynchronous; +import com.sap.ai.sdk.orchestration.model.CompletionPostResponse; +import com.sap.ai.sdk.orchestration.model.LLMChoice; import com.sap.ai.sdk.orchestration.model.SystemChatMessage; import com.sap.ai.sdk.orchestration.model.TokenUsage; import com.sap.ai.sdk.orchestration.model.ToolChatMessage; @@ -22,7 +22,7 @@ @Value @RequiredArgsConstructor(access = PACKAGE) public class OrchestrationChatResponse { - CompletionPostResponseSynchronous originalResponse; + CompletionPostResponse originalResponse; /** * Get the message content from the output. @@ -97,10 +97,10 @@ public List getAllMessages() throws IllegalArgumentException { /** * Get the LLM response. Useful for accessing the finish reason or further data like logprobs. * - * @return The (first, in case of multiple) {@link LLMChoiceSynchronous}. + * @return The (first, in case of multiple) {@link LLMChoice}. */ @Nonnull - public LLMChoiceSynchronous getChoice() { + public LLMChoice getChoice() { // We expect choices to be defined and never empty. return originalResponse.getOrchestrationResult().getChoices().get(0); } 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 1b6434a05..b93f67a86 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 @@ -9,7 +9,7 @@ import com.google.common.annotations.Beta; import com.sap.ai.sdk.core.AiCoreService; import com.sap.ai.sdk.orchestration.model.CompletionPostRequest; -import com.sap.ai.sdk.orchestration.model.CompletionPostResponseSynchronous; +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; @@ -138,9 +138,9 @@ private static void throwOnContentFilter(@Nonnull final OrchestrationChatComplet * @throws OrchestrationClientException If the request fails. */ @Nonnull - public CompletionPostResponseSynchronous executeRequest( - @Nonnull final CompletionPostRequest request) throws OrchestrationClientException { - return executor.execute("/completion", request, CompletionPostResponseSynchronous.class); + public CompletionPostResponse executeRequest(@Nonnull final CompletionPostRequest request) + throws OrchestrationClientException { + return executor.execute("/completion", request, CompletionPostResponse.class); } /** @@ -182,7 +182,7 @@ public OrchestrationChatResponse executeRequestFromJsonModuleConfig( requestJson.set("orchestration_config", moduleConfigJson); return new OrchestrationChatResponse( - executor.execute("/completion", requestJson, CompletionPostResponseSynchronous.class)); + executor.execute("/completion", requestJson, CompletionPostResponse.class)); } /** diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java index d8d68ce43..4d5956edd 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationError.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.google.common.annotations.Beta; import com.sap.ai.sdk.core.common.ClientError; -import com.sap.ai.sdk.orchestration.model.ErrorResponseSynchronous; +import com.sap.ai.sdk.orchestration.model.ErrorResponse; import javax.annotation.Nonnull; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -18,7 +18,7 @@ @Value @Beta public class OrchestrationError implements ClientError { - ErrorResponseSynchronous originalResponse; + ErrorResponse originalResponse; /** * Gets the error message from the contained original response. 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/CompletionPostResponseSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponse.java similarity index 68% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseSynchronous.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponse.java index ef3fd2789..245223966 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponseSynchronous.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/CompletionPostResponse.java @@ -23,35 +23,34 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** CompletionPostResponseSynchronous */ +/** CompletionPostResponse */ // CHECKSTYLE:OFF -public class CompletionPostResponseSynchronous +public class CompletionPostResponse // CHECKSTYLE:ON { @JsonProperty("request_id") private String requestId; @JsonProperty("module_results") - private ModuleResultsSynchronous moduleResults; + private ModuleResults moduleResults; @JsonProperty("orchestration_result") - private LLMModuleResultSynchronous orchestrationResult; + private LLMModuleResult orchestrationResult; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for CompletionPostResponseSynchronous. */ - protected CompletionPostResponseSynchronous() {} + /** Default constructor for CompletionPostResponse. */ + protected CompletionPostResponse() {} /** - * Set the requestId of this {@link CompletionPostResponseSynchronous} instance and return the - * same instance. + * Set the requestId of this {@link CompletionPostResponse} instance and return the same instance. * * @param requestId ID of the request - * @return The same instance of this {@link CompletionPostResponseSynchronous} class + * @return The same instance of this {@link CompletionPostResponse} class */ @Nonnull - public CompletionPostResponseSynchronous requestId(@Nonnull final String requestId) { + public CompletionPostResponse requestId(@Nonnull final String requestId) { this.requestId = requestId; return this; } @@ -59,7 +58,7 @@ public CompletionPostResponseSynchronous requestId(@Nonnull final String request /** * ID of the request * - * @return requestId The requestId of this {@link CompletionPostResponseSynchronous} instance. + * @return requestId The requestId of this {@link CompletionPostResponse} instance. */ @Nonnull public String getRequestId() { @@ -67,7 +66,7 @@ public String getRequestId() { } /** - * Set the requestId of this {@link CompletionPostResponseSynchronous} instance. + * Set the requestId of this {@link CompletionPostResponse} instance. * * @param requestId ID of the request */ @@ -76,15 +75,14 @@ public void setRequestId(@Nonnull final String requestId) { } /** - * Set the moduleResults of this {@link CompletionPostResponseSynchronous} instance and return the - * same instance. + * Set the moduleResults of this {@link CompletionPostResponse} instance and return the same + * instance. * - * @param moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} - * @return The same instance of this {@link CompletionPostResponseSynchronous} class + * @param moduleResults The moduleResults of this {@link CompletionPostResponse} + * @return The same instance of this {@link CompletionPostResponse} class */ @Nonnull - public CompletionPostResponseSynchronous moduleResults( - @Nonnull final ModuleResultsSynchronous moduleResults) { + public CompletionPostResponse moduleResults(@Nonnull final ModuleResults moduleResults) { this.moduleResults = moduleResults; return this; } @@ -92,34 +90,32 @@ public CompletionPostResponseSynchronous moduleResults( /** * Get moduleResults * - * @return moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} - * instance. + * @return moduleResults The moduleResults of this {@link CompletionPostResponse} instance. */ @Nonnull - public ModuleResultsSynchronous getModuleResults() { + public ModuleResults getModuleResults() { return moduleResults; } /** - * Set the moduleResults of this {@link CompletionPostResponseSynchronous} instance. + * Set the moduleResults of this {@link CompletionPostResponse} instance. * - * @param moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} + * @param moduleResults The moduleResults of this {@link CompletionPostResponse} */ - public void setModuleResults(@Nonnull final ModuleResultsSynchronous moduleResults) { + public void setModuleResults(@Nonnull final ModuleResults moduleResults) { this.moduleResults = moduleResults; } /** - * Set the orchestrationResult of this {@link CompletionPostResponseSynchronous} instance and - * return the same instance. + * Set the orchestrationResult of this {@link CompletionPostResponse} instance and return the same + * instance. * - * @param orchestrationResult The orchestrationResult of this {@link - * CompletionPostResponseSynchronous} - * @return The same instance of this {@link CompletionPostResponseSynchronous} class + * @param orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} + * @return The same instance of this {@link CompletionPostResponse} class */ @Nonnull - public CompletionPostResponseSynchronous orchestrationResult( - @Nonnull final LLMModuleResultSynchronous orchestrationResult) { + public CompletionPostResponse orchestrationResult( + @Nonnull final LLMModuleResult orchestrationResult) { this.orchestrationResult = orchestrationResult; return this; } @@ -127,28 +123,25 @@ public CompletionPostResponseSynchronous orchestrationResult( /** * Get orchestrationResult * - * @return orchestrationResult The orchestrationResult of this {@link - * CompletionPostResponseSynchronous} instance. + * @return orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} + * instance. */ @Nonnull - public LLMModuleResultSynchronous getOrchestrationResult() { + public LLMModuleResult getOrchestrationResult() { return orchestrationResult; } /** - * Set the orchestrationResult of this {@link CompletionPostResponseSynchronous} instance. + * Set the orchestrationResult of this {@link CompletionPostResponse} instance. * - * @param orchestrationResult The orchestrationResult of this {@link - * CompletionPostResponseSynchronous} + * @param orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} */ - public void setOrchestrationResult( - @Nonnull final LLMModuleResultSynchronous orchestrationResult) { + public void setOrchestrationResult(@Nonnull final LLMModuleResult orchestrationResult) { this.orchestrationResult = orchestrationResult; } /** - * Get the names of the unrecognizable properties of the {@link - * CompletionPostResponseSynchronous}. + * Get the names of the unrecognizable properties of the {@link CompletionPostResponse}. * * @return The set of properties names */ @@ -159,8 +152,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link CompletionPostResponseSynchronous} - * instance. + * Get the value of an unrecognizable property of this {@link CompletionPostResponse} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -172,14 +164,14 @@ public Set getCustomFieldNames() { public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { throw new NoSuchElementException( - "CompletionPostResponseSynchronous has no field with name '" + name + "'."); + "CompletionPostResponse has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link CompletionPostResponseSynchronous} instance - * including unrecognized properties. + * Get the value of all properties of this {@link CompletionPostResponse} instance including + * unrecognized properties. * * @return The map of all properties */ @@ -194,9 +186,8 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link CompletionPostResponseSynchronous} instance. If - * the map previously contained a mapping for the key, the old value is replaced by the specified - * value. + * Set an unrecognizable property of this {@link CompletionPostResponse} 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 @@ -214,14 +205,11 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final CompletionPostResponseSynchronous completionPostResponseSynchronous = - (CompletionPostResponseSynchronous) o; - return Objects.equals( - this.cloudSdkCustomFields, completionPostResponseSynchronous.cloudSdkCustomFields) - && Objects.equals(this.requestId, completionPostResponseSynchronous.requestId) - && Objects.equals(this.moduleResults, completionPostResponseSynchronous.moduleResults) - && Objects.equals( - this.orchestrationResult, completionPostResponseSynchronous.orchestrationResult); + final CompletionPostResponse completionPostResponse = (CompletionPostResponse) o; + return Objects.equals(this.cloudSdkCustomFields, completionPostResponse.cloudSdkCustomFields) + && Objects.equals(this.requestId, completionPostResponse.requestId) + && Objects.equals(this.moduleResults, completionPostResponse.moduleResults) + && Objects.equals(this.orchestrationResult, completionPostResponse.orchestrationResult); } @Override @@ -233,7 +221,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class CompletionPostResponseSynchronous {\n"); + sb.append("class CompletionPostResponse {\n"); sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); sb.append(" moduleResults: ").append(toIndentedString(moduleResults)).append("\n"); sb.append(" orchestrationResult: ") @@ -257,14 +245,14 @@ private String toIndentedString(final java.lang.Object o) { } /** - * Create a type-safe, fluent-api builder object to construct a new {@link - * CompletionPostResponseSynchronous} instance with all required arguments. + * Create a type-safe, fluent-api builder object to construct a new {@link CompletionPostResponse} + * instance with all required arguments. */ public static Builder create() { return (requestId) -> (moduleResults) -> (orchestrationResult) -> - new CompletionPostResponseSynchronous() + new CompletionPostResponse() .requestId(requestId) .moduleResults(moduleResults) .orchestrationResult(orchestrationResult); @@ -273,10 +261,10 @@ public static Builder create() { /** Builder helper class. */ public interface Builder { /** - * Set the requestId of this {@link CompletionPostResponseSynchronous} instance. + * Set the requestId of this {@link CompletionPostResponse} instance. * * @param requestId ID of the request - * @return The CompletionPostResponseSynchronous builder. + * @return The CompletionPostResponse builder. */ Builder1 requestId(@Nonnull final String requestId); } @@ -284,24 +272,22 @@ public interface Builder { /** Builder helper class. */ public interface Builder1 { /** - * Set the moduleResults of this {@link CompletionPostResponseSynchronous} instance. + * Set the moduleResults of this {@link CompletionPostResponse} instance. * - * @param moduleResults The moduleResults of this {@link CompletionPostResponseSynchronous} - * @return The CompletionPostResponseSynchronous builder. + * @param moduleResults The moduleResults of this {@link CompletionPostResponse} + * @return The CompletionPostResponse builder. */ - Builder2 moduleResults(@Nonnull final ModuleResultsSynchronous moduleResults); + Builder2 moduleResults(@Nonnull final ModuleResults moduleResults); } /** Builder helper class. */ public interface Builder2 { /** - * Set the orchestrationResult of this {@link CompletionPostResponseSynchronous} instance. + * Set the orchestrationResult of this {@link CompletionPostResponse} instance. * - * @param orchestrationResult The orchestrationResult of this {@link - * CompletionPostResponseSynchronous} - * @return The CompletionPostResponseSynchronous instance. + * @param orchestrationResult The orchestrationResult of this {@link CompletionPostResponse} + * @return The CompletionPostResponse instance. */ - CompletionPostResponseSynchronous orchestrationResult( - @Nonnull final LLMModuleResultSynchronous orchestrationResult); + CompletionPostResponse orchestrationResult(@Nonnull final LLMModuleResult orchestrationResult); } } 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 index 622f65162..ca2d26b1d 100644 --- 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 @@ -28,8 +28,8 @@ public class EmbeddingsOrchestrationConfig // CHECKSTYLE:ON { - @JsonProperty("module_configs") - private EmbeddingsModuleConfigs moduleConfigs; + @JsonProperty("modules") + private EmbeddingsModuleConfigs modules; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -38,36 +38,35 @@ public class EmbeddingsOrchestrationConfig protected EmbeddingsOrchestrationConfig() {} /** - * Set the moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance and return the - * same instance. + * Set the modules of this {@link EmbeddingsOrchestrationConfig} instance and return the same + * instance. * - * @param moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} + * @param modules The modules of this {@link EmbeddingsOrchestrationConfig} * @return The same instance of this {@link EmbeddingsOrchestrationConfig} class */ @Nonnull - public EmbeddingsOrchestrationConfig moduleConfigs( - @Nonnull final EmbeddingsModuleConfigs moduleConfigs) { - this.moduleConfigs = moduleConfigs; + public EmbeddingsOrchestrationConfig modules(@Nonnull final EmbeddingsModuleConfigs modules) { + this.modules = modules; return this; } /** - * Get moduleConfigs + * Get modules * - * @return moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance. + * @return modules The modules of this {@link EmbeddingsOrchestrationConfig} instance. */ @Nonnull - public EmbeddingsModuleConfigs getModuleConfigs() { - return moduleConfigs; + public EmbeddingsModuleConfigs getModules() { + return modules; } /** - * Set the moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance. + * Set the modules of this {@link EmbeddingsOrchestrationConfig} instance. * - * @param moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} + * @param modules The modules of this {@link EmbeddingsOrchestrationConfig} */ - public void setModuleConfigs(@Nonnull final EmbeddingsModuleConfigs moduleConfigs) { - this.moduleConfigs = moduleConfigs; + public void setModules(@Nonnull final EmbeddingsModuleConfigs modules) { + this.modules = modules; } /** @@ -110,7 +109,7 @@ public Object getCustomField(@Nonnull final String name) throws NoSuchElementExc @Nonnull public Map toMap() { final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); - if (moduleConfigs != null) declaredFields.put("moduleConfigs", moduleConfigs); + if (modules != null) declaredFields.put("modules", modules); return declaredFields; } @@ -139,12 +138,12 @@ public boolean equals(@Nullable final java.lang.Object o) { (EmbeddingsOrchestrationConfig) o; return Objects.equals( this.cloudSdkCustomFields, embeddingsOrchestrationConfig.cloudSdkCustomFields) - && Objects.equals(this.moduleConfigs, embeddingsOrchestrationConfig.moduleConfigs); + && Objects.equals(this.modules, embeddingsOrchestrationConfig.modules); } @Override public int hashCode() { - return Objects.hash(moduleConfigs, cloudSdkCustomFields); + return Objects.hash(modules, cloudSdkCustomFields); } @Override @@ -152,7 +151,7 @@ public int hashCode() { public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("class EmbeddingsOrchestrationConfig {\n"); - sb.append(" moduleConfigs: ").append(toIndentedString(moduleConfigs)).append("\n"); + sb.append(" modules: ").append(toIndentedString(modules)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); @@ -175,18 +174,17 @@ private String toIndentedString(final java.lang.Object o) { * EmbeddingsOrchestrationConfig} instance with all required arguments. */ public static Builder create() { - return (moduleConfigs) -> new EmbeddingsOrchestrationConfig().moduleConfigs(moduleConfigs); + return (modules) -> new EmbeddingsOrchestrationConfig().modules(modules); } /** Builder helper class. */ public interface Builder { /** - * Set the moduleConfigs of this {@link EmbeddingsOrchestrationConfig} instance. + * Set the modules of this {@link EmbeddingsOrchestrationConfig} instance. * - * @param moduleConfigs The moduleConfigs of this {@link EmbeddingsOrchestrationConfig} + * @param modules The modules of this {@link EmbeddingsOrchestrationConfig} * @return The EmbeddingsOrchestrationConfig instance. */ - EmbeddingsOrchestrationConfig moduleConfigs( - @Nonnull final EmbeddingsModuleConfigs moduleConfigs); + 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 index 850108088..b8e4c9480 100644 --- 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 @@ -28,8 +28,8 @@ public class EmbeddingsPostRequest // CHECKSTYLE:ON { - @JsonProperty("orchestration_config") - private EmbeddingsOrchestrationConfig orchestrationConfig; + @JsonProperty("config") + private EmbeddingsOrchestrationConfig config; @JsonProperty("input") private EmbeddingsInput input; @@ -41,38 +41,34 @@ public class EmbeddingsPostRequest protected EmbeddingsPostRequest() {} /** - * Set the orchestrationConfig of this {@link EmbeddingsPostRequest} instance and return the same - * instance. + * Set the config of this {@link EmbeddingsPostRequest} instance and return the same instance. * - * @param orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} + * @param config The config of this {@link EmbeddingsPostRequest} * @return The same instance of this {@link EmbeddingsPostRequest} class */ @Nonnull - public EmbeddingsPostRequest orchestrationConfig( - @Nonnull final EmbeddingsOrchestrationConfig orchestrationConfig) { - this.orchestrationConfig = orchestrationConfig; + public EmbeddingsPostRequest config(@Nonnull final EmbeddingsOrchestrationConfig config) { + this.config = config; return this; } /** - * Get orchestrationConfig + * Get config * - * @return orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} - * instance. + * @return config The config of this {@link EmbeddingsPostRequest} instance. */ @Nonnull - public EmbeddingsOrchestrationConfig getOrchestrationConfig() { - return orchestrationConfig; + public EmbeddingsOrchestrationConfig getConfig() { + return config; } /** - * Set the orchestrationConfig of this {@link EmbeddingsPostRequest} instance. + * Set the config of this {@link EmbeddingsPostRequest} instance. * - * @param orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} + * @param config The config of this {@link EmbeddingsPostRequest} */ - public void setOrchestrationConfig( - @Nonnull final EmbeddingsOrchestrationConfig orchestrationConfig) { - this.orchestrationConfig = orchestrationConfig; + public void setConfig(@Nonnull final EmbeddingsOrchestrationConfig config) { + this.config = config; } /** @@ -145,7 +141,7 @@ public Object getCustomField(@Nonnull final String name) throws NoSuchElementExc @Nonnull public Map toMap() { final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); - if (orchestrationConfig != null) declaredFields.put("orchestrationConfig", orchestrationConfig); + if (config != null) declaredFields.put("config", config); if (input != null) declaredFields.put("input", input); return declaredFields; } @@ -172,13 +168,13 @@ public boolean equals(@Nullable final java.lang.Object o) { } final EmbeddingsPostRequest embeddingsPostRequest = (EmbeddingsPostRequest) o; return Objects.equals(this.cloudSdkCustomFields, embeddingsPostRequest.cloudSdkCustomFields) - && Objects.equals(this.orchestrationConfig, embeddingsPostRequest.orchestrationConfig) + && Objects.equals(this.config, embeddingsPostRequest.config) && Objects.equals(this.input, embeddingsPostRequest.input); } @Override public int hashCode() { - return Objects.hash(orchestrationConfig, input, cloudSdkCustomFields); + return Objects.hash(config, input, cloudSdkCustomFields); } @Override @@ -186,9 +182,7 @@ public int hashCode() { public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("class EmbeddingsPostRequest {\n"); - sb.append(" orchestrationConfig: ") - .append(toIndentedString(orchestrationConfig)) - .append("\n"); + sb.append(" config: ").append(toIndentedString(config)).append("\n"); sb.append(" input: ").append(toIndentedString(input)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> @@ -212,20 +206,18 @@ private String toIndentedString(final java.lang.Object o) { * instance with all required arguments. */ public static Builder create() { - return (orchestrationConfig) -> - (input) -> - new EmbeddingsPostRequest().orchestrationConfig(orchestrationConfig).input(input); + return (config) -> (input) -> new EmbeddingsPostRequest().config(config).input(input); } /** Builder helper class. */ public interface Builder { /** - * Set the orchestrationConfig of this {@link EmbeddingsPostRequest} instance. + * Set the config of this {@link EmbeddingsPostRequest} instance. * - * @param orchestrationConfig The orchestrationConfig of this {@link EmbeddingsPostRequest} + * @param config The config of this {@link EmbeddingsPostRequest} * @return The EmbeddingsPostRequest builder. */ - Builder1 orchestrationConfig(@Nonnull final EmbeddingsOrchestrationConfig orchestrationConfig); + Builder1 config(@Nonnull final EmbeddingsOrchestrationConfig config); } /** Builder helper class. */ 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 index 7ef0372d2..16dba27d2 100644 --- 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 @@ -31,11 +31,11 @@ public class EmbeddingsPostResponse @JsonProperty("request_id") private String requestId; - @JsonProperty("module_results") - private ModuleResultsBase moduleResults; + @JsonProperty("intermediate_results") + private ModuleResultsBase intermediateResults; - @JsonProperty("orchestration_result") - private EmbeddingsResponse orchestrationResult; + @JsonProperty("final_result") + private EmbeddingsResponse finalResult; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -75,69 +75,69 @@ public void setRequestId(@Nonnull final String requestId) { } /** - * Set the moduleResults of this {@link EmbeddingsPostResponse} instance and return the same + * Set the intermediateResults of this {@link EmbeddingsPostResponse} instance and return the same * instance. * - * @param moduleResults The moduleResults of this {@link EmbeddingsPostResponse} + * @param intermediateResults The intermediateResults of this {@link EmbeddingsPostResponse} * @return The same instance of this {@link EmbeddingsPostResponse} class */ @Nonnull - public EmbeddingsPostResponse moduleResults(@Nullable final ModuleResultsBase moduleResults) { - this.moduleResults = moduleResults; + public EmbeddingsPostResponse intermediateResults( + @Nullable final ModuleResultsBase intermediateResults) { + this.intermediateResults = intermediateResults; return this; } /** - * Get moduleResults + * Get intermediateResults * - * @return moduleResults The moduleResults of this {@link EmbeddingsPostResponse} instance. + * @return intermediateResults The intermediateResults of this {@link EmbeddingsPostResponse} + * instance. */ @Nonnull - public ModuleResultsBase getModuleResults() { - return moduleResults; + public ModuleResultsBase getIntermediateResults() { + return intermediateResults; } /** - * Set the moduleResults of this {@link EmbeddingsPostResponse} instance. + * Set the intermediateResults of this {@link EmbeddingsPostResponse} instance. * - * @param moduleResults The moduleResults of this {@link EmbeddingsPostResponse} + * @param intermediateResults The intermediateResults of this {@link EmbeddingsPostResponse} */ - public void setModuleResults(@Nullable final ModuleResultsBase moduleResults) { - this.moduleResults = moduleResults; + public void setIntermediateResults(@Nullable final ModuleResultsBase intermediateResults) { + this.intermediateResults = intermediateResults; } /** - * Set the orchestrationResult of this {@link EmbeddingsPostResponse} instance and return the same + * Set the finalResult of this {@link EmbeddingsPostResponse} instance and return the same * instance. * - * @param orchestrationResult The orchestrationResult of this {@link EmbeddingsPostResponse} + * @param finalResult The finalResult of this {@link EmbeddingsPostResponse} * @return The same instance of this {@link EmbeddingsPostResponse} class */ @Nonnull - public EmbeddingsPostResponse orchestrationResult( - @Nullable final EmbeddingsResponse orchestrationResult) { - this.orchestrationResult = orchestrationResult; + public EmbeddingsPostResponse finalResult(@Nullable final EmbeddingsResponse finalResult) { + this.finalResult = finalResult; return this; } /** - * Get orchestrationResult + * Get finalResult * - * @return orchestrationResult The orchestrationResult of this {@link EmbeddingsPostResponse} - * instance. + * @return finalResult The finalResult of this {@link EmbeddingsPostResponse} instance. */ @Nonnull - public EmbeddingsResponse getOrchestrationResult() { - return orchestrationResult; + public EmbeddingsResponse getFinalResult() { + return finalResult; } /** - * Set the orchestrationResult of this {@link EmbeddingsPostResponse} instance. + * Set the finalResult of this {@link EmbeddingsPostResponse} instance. * - * @param orchestrationResult The orchestrationResult of this {@link EmbeddingsPostResponse} + * @param finalResult The finalResult of this {@link EmbeddingsPostResponse} */ - public void setOrchestrationResult(@Nullable final EmbeddingsResponse orchestrationResult) { - this.orchestrationResult = orchestrationResult; + public void setFinalResult(@Nullable final EmbeddingsResponse finalResult) { + this.finalResult = finalResult; } /** @@ -180,8 +180,8 @@ public Object getCustomField(@Nonnull final String name) throws NoSuchElementExc public Map toMap() { final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); if (requestId != null) declaredFields.put("requestId", requestId); - if (moduleResults != null) declaredFields.put("moduleResults", moduleResults); - if (orchestrationResult != null) declaredFields.put("orchestrationResult", orchestrationResult); + if (intermediateResults != null) declaredFields.put("intermediateResults", intermediateResults); + if (finalResult != null) declaredFields.put("finalResult", finalResult); return declaredFields; } @@ -208,13 +208,13 @@ public boolean equals(@Nullable final java.lang.Object o) { final EmbeddingsPostResponse embeddingsPostResponse = (EmbeddingsPostResponse) o; return Objects.equals(this.cloudSdkCustomFields, embeddingsPostResponse.cloudSdkCustomFields) && Objects.equals(this.requestId, embeddingsPostResponse.requestId) - && Objects.equals(this.moduleResults, embeddingsPostResponse.moduleResults) - && Objects.equals(this.orchestrationResult, embeddingsPostResponse.orchestrationResult); + && Objects.equals(this.intermediateResults, embeddingsPostResponse.intermediateResults) + && Objects.equals(this.finalResult, embeddingsPostResponse.finalResult); } @Override public int hashCode() { - return Objects.hash(requestId, moduleResults, orchestrationResult, cloudSdkCustomFields); + return Objects.hash(requestId, intermediateResults, finalResult, cloudSdkCustomFields); } @Override @@ -223,10 +223,10 @@ public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("class EmbeddingsPostResponse {\n"); sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n"); - sb.append(" moduleResults: ").append(toIndentedString(moduleResults)).append("\n"); - sb.append(" orchestrationResult: ") - .append(toIndentedString(orchestrationResult)) + 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")); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java similarity index 63% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseSynchronous.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java index a39ee432a..76fc798e1 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponseSynchronous.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ErrorResponse.java @@ -23,9 +23,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** ErrorResponseSynchronous */ +/** ErrorResponse */ // CHECKSTYLE:OFF -public class ErrorResponseSynchronous +public class ErrorResponse // CHECKSTYLE:ON { @JsonProperty("request_id") @@ -41,23 +41,22 @@ public class ErrorResponseSynchronous private String location; @JsonProperty("module_results") - private ModuleResultsSynchronous moduleResults; + private ModuleResults moduleResults; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for ErrorResponseSynchronous. */ - protected ErrorResponseSynchronous() {} + /** Default constructor for ErrorResponse. */ + protected ErrorResponse() {} /** - * Set the requestId of this {@link ErrorResponseSynchronous} instance and return the same - * instance. + * Set the requestId of this {@link ErrorResponse} instance and return the same instance. * - * @param requestId The requestId of this {@link ErrorResponseSynchronous} - * @return The same instance of this {@link ErrorResponseSynchronous} class + * @param requestId The requestId of this {@link ErrorResponse} + * @return The same instance of this {@link ErrorResponse} class */ @Nonnull - public ErrorResponseSynchronous requestId(@Nonnull final String requestId) { + public ErrorResponse requestId(@Nonnull final String requestId) { this.requestId = requestId; return this; } @@ -65,7 +64,7 @@ public ErrorResponseSynchronous requestId(@Nonnull final String requestId) { /** * Get requestId * - * @return requestId The requestId of this {@link ErrorResponseSynchronous} instance. + * @return requestId The requestId of this {@link ErrorResponse} instance. */ @Nonnull public String getRequestId() { @@ -73,22 +72,22 @@ public String getRequestId() { } /** - * Set the requestId of this {@link ErrorResponseSynchronous} instance. + * Set the requestId of this {@link ErrorResponse} instance. * - * @param requestId The requestId of this {@link ErrorResponseSynchronous} + * @param requestId The requestId of this {@link ErrorResponse} */ public void setRequestId(@Nonnull final String requestId) { this.requestId = requestId; } /** - * Set the code of this {@link ErrorResponseSynchronous} instance and return the same instance. + * Set the code of this {@link ErrorResponse} instance and return the same instance. * - * @param code The code of this {@link ErrorResponseSynchronous} - * @return The same instance of this {@link ErrorResponseSynchronous} class + * @param code The code of this {@link ErrorResponse} + * @return The same instance of this {@link ErrorResponse} class */ @Nonnull - public ErrorResponseSynchronous code(@Nonnull final Integer code) { + public ErrorResponse code(@Nonnull final Integer code) { this.code = code; return this; } @@ -96,7 +95,7 @@ public ErrorResponseSynchronous code(@Nonnull final Integer code) { /** * Get code * - * @return code The code of this {@link ErrorResponseSynchronous} instance. + * @return code The code of this {@link ErrorResponse} instance. */ @Nonnull public Integer getCode() { @@ -104,22 +103,22 @@ public Integer getCode() { } /** - * Set the code of this {@link ErrorResponseSynchronous} instance. + * Set the code of this {@link ErrorResponse} instance. * - * @param code The code of this {@link ErrorResponseSynchronous} + * @param code The code of this {@link ErrorResponse} */ public void setCode(@Nonnull final Integer code) { this.code = code; } /** - * Set the message of this {@link ErrorResponseSynchronous} instance and return the same instance. + * Set the message of this {@link ErrorResponse} instance and return the same instance. * - * @param message The message of this {@link ErrorResponseSynchronous} - * @return The same instance of this {@link ErrorResponseSynchronous} class + * @param message The message of this {@link ErrorResponse} + * @return The same instance of this {@link ErrorResponse} class */ @Nonnull - public ErrorResponseSynchronous message(@Nonnull final String message) { + public ErrorResponse message(@Nonnull final String message) { this.message = message; return this; } @@ -127,7 +126,7 @@ public ErrorResponseSynchronous message(@Nonnull final String message) { /** * Get message * - * @return message The message of this {@link ErrorResponseSynchronous} instance. + * @return message The message of this {@link ErrorResponse} instance. */ @Nonnull public String getMessage() { @@ -135,23 +134,22 @@ public String getMessage() { } /** - * Set the message of this {@link ErrorResponseSynchronous} instance. + * Set the message of this {@link ErrorResponse} instance. * - * @param message The message of this {@link ErrorResponseSynchronous} + * @param message The message of this {@link ErrorResponse} */ public void setMessage(@Nonnull final String message) { this.message = message; } /** - * Set the location of this {@link ErrorResponseSynchronous} instance and return the same - * instance. + * Set the location of this {@link ErrorResponse} instance and return the same instance. * * @param location Where the error occurred - * @return The same instance of this {@link ErrorResponseSynchronous} class + * @return The same instance of this {@link ErrorResponse} class */ @Nonnull - public ErrorResponseSynchronous location(@Nonnull final String location) { + public ErrorResponse location(@Nonnull final String location) { this.location = location; return this; } @@ -159,7 +157,7 @@ public ErrorResponseSynchronous location(@Nonnull final String location) { /** * Where the error occurred * - * @return location The location of this {@link ErrorResponseSynchronous} instance. + * @return location The location of this {@link ErrorResponse} instance. */ @Nonnull public String getLocation() { @@ -167,7 +165,7 @@ public String getLocation() { } /** - * Set the location of this {@link ErrorResponseSynchronous} instance. + * Set the location of this {@link ErrorResponse} instance. * * @param location Where the error occurred */ @@ -176,15 +174,13 @@ public void setLocation(@Nonnull final String location) { } /** - * Set the moduleResults of this {@link ErrorResponseSynchronous} instance and return the same - * instance. + * Set the moduleResults of this {@link ErrorResponse} instance and return the same instance. * - * @param moduleResults The moduleResults of this {@link ErrorResponseSynchronous} - * @return The same instance of this {@link ErrorResponseSynchronous} class + * @param moduleResults The moduleResults of this {@link ErrorResponse} + * @return The same instance of this {@link ErrorResponse} class */ @Nonnull - public ErrorResponseSynchronous moduleResults( - @Nullable final ModuleResultsSynchronous moduleResults) { + public ErrorResponse moduleResults(@Nullable final ModuleResults moduleResults) { this.moduleResults = moduleResults; return this; } @@ -192,24 +188,24 @@ public ErrorResponseSynchronous moduleResults( /** * Get moduleResults * - * @return moduleResults The moduleResults of this {@link ErrorResponseSynchronous} instance. + * @return moduleResults The moduleResults of this {@link ErrorResponse} instance. */ @Nonnull - public ModuleResultsSynchronous getModuleResults() { + public ModuleResults getModuleResults() { return moduleResults; } /** - * Set the moduleResults of this {@link ErrorResponseSynchronous} instance. + * Set the moduleResults of this {@link ErrorResponse} instance. * - * @param moduleResults The moduleResults of this {@link ErrorResponseSynchronous} + * @param moduleResults The moduleResults of this {@link ErrorResponse} */ - public void setModuleResults(@Nullable final ModuleResultsSynchronous moduleResults) { + public void setModuleResults(@Nullable final ModuleResults moduleResults) { this.moduleResults = moduleResults; } /** - * Get the names of the unrecognizable properties of the {@link ErrorResponseSynchronous}. + * Get the names of the unrecognizable properties of the {@link ErrorResponse}. * * @return The set of properties names */ @@ -220,7 +216,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link ErrorResponseSynchronous} instance. + * Get the value of an unrecognizable property of this {@link ErrorResponse} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -231,15 +227,14 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException( - "ErrorResponseSynchronous has no field with name '" + name + "'."); + throw new NoSuchElementException("ErrorResponse has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link ErrorResponseSynchronous} instance including - * unrecognized properties. + * Get the value of all properties of this {@link ErrorResponse} instance including unrecognized + * properties. * * @return The map of all properties */ @@ -256,8 +251,8 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link ErrorResponseSynchronous} instance. If the map - * previously contained a mapping for the key, the old value is replaced by the specified value. + * Set an unrecognizable property of this {@link ErrorResponse} 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 @@ -275,13 +270,13 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final ErrorResponseSynchronous errorResponseSynchronous = (ErrorResponseSynchronous) o; - return Objects.equals(this.cloudSdkCustomFields, errorResponseSynchronous.cloudSdkCustomFields) - && Objects.equals(this.requestId, errorResponseSynchronous.requestId) - && Objects.equals(this.code, errorResponseSynchronous.code) - && Objects.equals(this.message, errorResponseSynchronous.message) - && Objects.equals(this.location, errorResponseSynchronous.location) - && Objects.equals(this.moduleResults, errorResponseSynchronous.moduleResults); + final ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.cloudSdkCustomFields, errorResponse.cloudSdkCustomFields) + && Objects.equals(this.requestId, errorResponse.requestId) + && Objects.equals(this.code, errorResponse.code) + && Objects.equals(this.message, errorResponse.message) + && Objects.equals(this.location, errorResponse.location) + && Objects.equals(this.moduleResults, errorResponse.moduleResults); } @Override @@ -293,7 +288,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class ErrorResponseSynchronous {\n"); + sb.append("class ErrorResponse {\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"); @@ -317,15 +312,15 @@ private String toIndentedString(final java.lang.Object o) { } /** - * Create a type-safe, fluent-api builder object to construct a new {@link - * ErrorResponseSynchronous} instance with all required arguments. + * Create a type-safe, fluent-api builder object to construct a new {@link ErrorResponse} instance + * with all required arguments. */ public static Builder create() { return (requestId) -> (code) -> (message) -> (location) -> - new ErrorResponseSynchronous() + new ErrorResponse() .requestId(requestId) .code(code) .message(message) @@ -335,10 +330,10 @@ public static Builder create() { /** Builder helper class. */ public interface Builder { /** - * Set the requestId of this {@link ErrorResponseSynchronous} instance. + * Set the requestId of this {@link ErrorResponse} instance. * - * @param requestId The requestId of this {@link ErrorResponseSynchronous} - * @return The ErrorResponseSynchronous builder. + * @param requestId The requestId of this {@link ErrorResponse} + * @return The ErrorResponse builder. */ Builder1 requestId(@Nonnull final String requestId); } @@ -346,10 +341,10 @@ public interface Builder { /** Builder helper class. */ public interface Builder1 { /** - * Set the code of this {@link ErrorResponseSynchronous} instance. + * Set the code of this {@link ErrorResponse} instance. * - * @param code The code of this {@link ErrorResponseSynchronous} - * @return The ErrorResponseSynchronous builder. + * @param code The code of this {@link ErrorResponse} + * @return The ErrorResponse builder. */ Builder2 code(@Nonnull final Integer code); } @@ -357,10 +352,10 @@ public interface Builder1 { /** Builder helper class. */ public interface Builder2 { /** - * Set the message of this {@link ErrorResponseSynchronous} instance. + * Set the message of this {@link ErrorResponse} instance. * - * @param message The message of this {@link ErrorResponseSynchronous} - * @return The ErrorResponseSynchronous builder. + * @param message The message of this {@link ErrorResponse} + * @return The ErrorResponse builder. */ Builder3 message(@Nonnull final String message); } @@ -368,11 +363,11 @@ public interface Builder2 { /** Builder helper class. */ public interface Builder3 { /** - * Set the location of this {@link ErrorResponseSynchronous} instance. + * Set the location of this {@link ErrorResponse} instance. * * @param location Where the error occurred - * @return The ErrorResponseSynchronous instance. + * @return The ErrorResponse instance. */ - ErrorResponseSynchronous location(@Nonnull final String location); + ErrorResponse 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/LLMChoiceSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java similarity index 69% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceSynchronous.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java index e46730e4b..c9aea33be 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoiceSynchronous.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMChoice.java @@ -26,9 +26,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** LLMChoiceSynchronous */ +/** LLMChoice */ // CHECKSTYLE:OFF -public class LLMChoiceSynchronous +public class LLMChoice // CHECKSTYLE:ON { @JsonProperty("index") @@ -46,17 +46,17 @@ public class LLMChoiceSynchronous @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for LLMChoiceSynchronous. */ - protected LLMChoiceSynchronous() {} + /** Default constructor for LLMChoice. */ + protected LLMChoice() {} /** - * Set the index of this {@link LLMChoiceSynchronous} instance and return the same instance. + * Set the index of this {@link LLMChoice} instance and return the same instance. * * @param index Index of the choice - * @return The same instance of this {@link LLMChoiceSynchronous} class + * @return The same instance of this {@link LLMChoice} class */ @Nonnull - public LLMChoiceSynchronous index(@Nonnull final Integer index) { + public LLMChoice index(@Nonnull final Integer index) { this.index = index; return this; } @@ -64,7 +64,7 @@ public LLMChoiceSynchronous index(@Nonnull final Integer index) { /** * Index of the choice * - * @return index The index of this {@link LLMChoiceSynchronous} instance. + * @return index The index of this {@link LLMChoice} instance. */ @Nonnull public Integer getIndex() { @@ -72,7 +72,7 @@ public Integer getIndex() { } /** - * Set the index of this {@link LLMChoiceSynchronous} instance. + * Set the index of this {@link LLMChoice} instance. * * @param index Index of the choice */ @@ -81,13 +81,13 @@ public void setIndex(@Nonnull final Integer index) { } /** - * Set the message of this {@link LLMChoiceSynchronous} instance and return the same instance. + * Set the message of this {@link LLMChoice} instance and return the same instance. * - * @param message The message of this {@link LLMChoiceSynchronous} - * @return The same instance of this {@link LLMChoiceSynchronous} class + * @param message The message of this {@link LLMChoice} + * @return The same instance of this {@link LLMChoice} class */ @Nonnull - public LLMChoiceSynchronous message(@Nonnull final ResponseChatMessage message) { + public LLMChoice message(@Nonnull final ResponseChatMessage message) { this.message = message; return this; } @@ -95,7 +95,7 @@ public LLMChoiceSynchronous message(@Nonnull final ResponseChatMessage message) /** * Get message * - * @return message The message of this {@link LLMChoiceSynchronous} instance. + * @return message The message of this {@link LLMChoice} instance. */ @Nonnull public ResponseChatMessage getMessage() { @@ -103,35 +103,35 @@ public ResponseChatMessage getMessage() { } /** - * Set the message of this {@link LLMChoiceSynchronous} instance. + * Set the message of this {@link LLMChoice} instance. * - * @param message The message of this {@link LLMChoiceSynchronous} + * @param message The message of this {@link LLMChoice} */ public void setMessage(@Nonnull final ResponseChatMessage message) { this.message = message; } /** - * Set the logprobs of this {@link LLMChoiceSynchronous} instance and return the same instance. + * Set the logprobs of this {@link LLMChoice} instance and return the same instance. * * @param logprobs Log probabilities - * @return The same instance of this {@link LLMChoiceSynchronous} class + * @return The same instance of this {@link LLMChoice} class */ @Nonnull - public LLMChoiceSynchronous logprobs(@Nullable final Map> logprobs) { + public LLMChoice logprobs(@Nullable final Map> logprobs) { this.logprobs = logprobs; return this; } /** - * Put one logprobs instance to this {@link LLMChoiceSynchronous} instance. + * 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 LLMChoiceSynchronous} + * @return The same instance of type {@link LLMChoice} */ @Nonnull - public LLMChoiceSynchronous putlogprobsItem( + public LLMChoice putlogprobsItem( @Nonnull final String key, @Nonnull final List logprobsItem) { if (this.logprobs == null) { this.logprobs = new HashMap<>(); @@ -143,7 +143,7 @@ public LLMChoiceSynchronous putlogprobsItem( /** * Log probabilities * - * @return logprobs The logprobs of this {@link LLMChoiceSynchronous} instance. + * @return logprobs The logprobs of this {@link LLMChoice} instance. */ @Nonnull public Map> getLogprobs() { @@ -151,7 +151,7 @@ public Map> getLogprobs() { } /** - * Set the logprobs of this {@link LLMChoiceSynchronous} instance. + * Set the logprobs of this {@link LLMChoice} instance. * * @param logprobs Log probabilities */ @@ -160,17 +160,16 @@ public void setLogprobs(@Nullable final Map> logprobs) } /** - * Set the finishReason of this {@link LLMChoiceSynchronous} instance and return the same - * instance. + * Set the finishReason of this {@link LLMChoice} instance and return the same instance. * * @param finishReason 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 - * @return The same instance of this {@link LLMChoiceSynchronous} class + * @return The same instance of this {@link LLMChoice} class */ @Nonnull - public LLMChoiceSynchronous finishReason(@Nonnull final String finishReason) { + public LLMChoice finishReason(@Nonnull final String finishReason) { this.finishReason = finishReason; return this; } @@ -181,7 +180,7 @@ public LLMChoiceSynchronous finishReason(@Nonnull final String finishReason) { * 'content_filter' if content was omitted due to a filter enforced by the LLM model * provider or the content filtering module * - * @return finishReason The finishReason of this {@link LLMChoiceSynchronous} instance. + * @return finishReason The finishReason of this {@link LLMChoice} instance. */ @Nonnull public String getFinishReason() { @@ -189,7 +188,7 @@ public String getFinishReason() { } /** - * Set the finishReason of this {@link LLMChoiceSynchronous} instance. + * Set the finishReason of this {@link LLMChoice} instance. * * @param finishReason 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 @@ -201,7 +200,7 @@ public void setFinishReason(@Nonnull final String finishReason) { } /** - * Get the names of the unrecognizable properties of the {@link LLMChoiceSynchronous}. + * Get the names of the unrecognizable properties of the {@link LLMChoice}. * * @return The set of properties names */ @@ -212,7 +211,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link LLMChoiceSynchronous} instance. + * Get the value of an unrecognizable property of this {@link LLMChoice} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -223,15 +222,14 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException( - "LLMChoiceSynchronous has no field with name '" + name + "'."); + throw new NoSuchElementException("LLMChoice has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link LLMChoiceSynchronous} instance including - * unrecognized properties. + * Get the value of all properties of this {@link LLMChoice} instance including unrecognized + * properties. * * @return The map of all properties */ @@ -247,8 +245,8 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link LLMChoiceSynchronous} instance. If the map - * previously contained a mapping for the key, the old value is replaced by the specified value. + * Set an unrecognizable property of this {@link LLMChoice} 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 @@ -266,12 +264,12 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final LLMChoiceSynchronous llMChoiceSynchronous = (LLMChoiceSynchronous) o; - return Objects.equals(this.cloudSdkCustomFields, llMChoiceSynchronous.cloudSdkCustomFields) - && Objects.equals(this.index, llMChoiceSynchronous.index) - && Objects.equals(this.message, llMChoiceSynchronous.message) - && Objects.equals(this.logprobs, llMChoiceSynchronous.logprobs) - && Objects.equals(this.finishReason, llMChoiceSynchronous.finishReason); + final LLMChoice llMChoice = (LLMChoice) o; + return Objects.equals(this.cloudSdkCustomFields, llMChoice.cloudSdkCustomFields) + && Objects.equals(this.index, llMChoice.index) + && Objects.equals(this.message, llMChoice.message) + && Objects.equals(this.logprobs, llMChoice.logprobs) + && Objects.equals(this.finishReason, llMChoice.finishReason); } @Override @@ -283,7 +281,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class LLMChoiceSynchronous {\n"); + sb.append("class LLMChoice {\n"); sb.append(" index: ").append(toIndentedString(index)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" logprobs: ").append(toIndentedString(logprobs)).append("\n"); @@ -306,23 +304,23 @@ private String toIndentedString(final java.lang.Object o) { } /** - * Create a type-safe, fluent-api builder object to construct a new {@link LLMChoiceSynchronous} - * instance with all required arguments. + * Create a type-safe, fluent-api builder object to construct a new {@link LLMChoice} instance + * with all required arguments. */ public static Builder create() { return (index) -> (message) -> (finishReason) -> - new LLMChoiceSynchronous().index(index).message(message).finishReason(finishReason); + new LLMChoice().index(index).message(message).finishReason(finishReason); } /** Builder helper class. */ public interface Builder { /** - * Set the index of this {@link LLMChoiceSynchronous} instance. + * Set the index of this {@link LLMChoice} instance. * * @param index Index of the choice - * @return The LLMChoiceSynchronous builder. + * @return The LLMChoice builder. */ Builder1 index(@Nonnull final Integer index); } @@ -330,10 +328,10 @@ public interface Builder { /** Builder helper class. */ public interface Builder1 { /** - * Set the message of this {@link LLMChoiceSynchronous} instance. + * Set the message of this {@link LLMChoice} instance. * - * @param message The message of this {@link LLMChoiceSynchronous} - * @return The LLMChoiceSynchronous builder. + * @param message The message of this {@link LLMChoice} + * @return The LLMChoice builder. */ Builder2 message(@Nonnull final ResponseChatMessage message); } @@ -341,14 +339,14 @@ public interface Builder1 { /** Builder helper class. */ public interface Builder2 { /** - * Set the finishReason of this {@link LLMChoiceSynchronous} instance. + * Set the finishReason of this {@link LLMChoice} instance. * * @param finishReason 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 - * @return The LLMChoiceSynchronous instance. + * @return The LLMChoice instance. */ - LLMChoiceSynchronous finishReason(@Nonnull final String finishReason); + LLMChoice finishReason(@Nonnull final String finishReason); } } 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/LLMModuleResult.java similarity index 60% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultSynchronous.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java index 896f2cb73..10063bb70 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultSynchronous.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java @@ -28,7 +28,7 @@ /** Output of LLM module. Follows the OpenAI spec. */ // CHECKSTYLE:OFF -public class LLMModuleResultSynchronous +public class LLMModuleResult // CHECKSTYLE:ON { @JsonProperty("id") @@ -47,7 +47,7 @@ public class LLMModuleResultSynchronous private String systemFingerprint; @JsonProperty("choices") - private List choices = new ArrayList<>(); + private List choices = new ArrayList<>(); @JsonProperty("usage") private TokenUsage usage; @@ -55,17 +55,17 @@ public class LLMModuleResultSynchronous @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for LLMModuleResultSynchronous. */ - protected LLMModuleResultSynchronous() {} + /** Default constructor for LLMModuleResult. */ + protected LLMModuleResult() {} /** - * Set the id of this {@link LLMModuleResultSynchronous} instance and return the same instance. + * 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 LLMModuleResultSynchronous} class + * @return The same instance of this {@link LLMModuleResult} class */ @Nonnull - public LLMModuleResultSynchronous id(@Nonnull final String id) { + public LLMModuleResult id(@Nonnull final String id) { this.id = id; return this; } @@ -73,7 +73,7 @@ public LLMModuleResultSynchronous id(@Nonnull final String id) { /** * ID of the response * - * @return id The id of this {@link LLMModuleResultSynchronous} instance. + * @return id The id of this {@link LLMModuleResult} instance. */ @Nonnull public String getId() { @@ -81,7 +81,7 @@ public String getId() { } /** - * Set the id of this {@link LLMModuleResultSynchronous} instance. + * Set the id of this {@link LLMModuleResult} instance. * * @param id ID of the response */ @@ -90,14 +90,13 @@ public void setId(@Nonnull final String id) { } /** - * Set the _object of this {@link LLMModuleResultSynchronous} instance and return the same - * instance. + * Set the _object of this {@link LLMModuleResult} instance and return the same instance. * * @param _object Object type - * @return The same instance of this {@link LLMModuleResultSynchronous} class + * @return The same instance of this {@link LLMModuleResult} class */ @Nonnull - public LLMModuleResultSynchronous _object(@Nonnull final String _object) { + public LLMModuleResult _object(@Nonnull final String _object) { this._object = _object; return this; } @@ -105,7 +104,7 @@ public LLMModuleResultSynchronous _object(@Nonnull final String _object) { /** * Object type * - * @return _object The _object of this {@link LLMModuleResultSynchronous} instance. + * @return _object The _object of this {@link LLMModuleResult} instance. */ @Nonnull public String getObject() { @@ -113,7 +112,7 @@ public String getObject() { } /** - * Set the _object of this {@link LLMModuleResultSynchronous} instance. + * Set the _object of this {@link LLMModuleResult} instance. * * @param _object Object type */ @@ -122,14 +121,13 @@ public void setObject(@Nonnull final String _object) { } /** - * Set the created of this {@link LLMModuleResultSynchronous} instance and return the same - * instance. + * Set the created of this {@link LLMModuleResult} instance and return the same instance. * * @param created Unix timestamp - * @return The same instance of this {@link LLMModuleResultSynchronous} class + * @return The same instance of this {@link LLMModuleResult} class */ @Nonnull - public LLMModuleResultSynchronous created(@Nonnull final Integer created) { + public LLMModuleResult created(@Nonnull final Integer created) { this.created = created; return this; } @@ -137,7 +135,7 @@ public LLMModuleResultSynchronous created(@Nonnull final Integer created) { /** * Unix timestamp * - * @return created The created of this {@link LLMModuleResultSynchronous} instance. + * @return created The created of this {@link LLMModuleResult} instance. */ @Nonnull public Integer getCreated() { @@ -145,7 +143,7 @@ public Integer getCreated() { } /** - * Set the created of this {@link LLMModuleResultSynchronous} instance. + * Set the created of this {@link LLMModuleResult} instance. * * @param created Unix timestamp */ @@ -154,13 +152,13 @@ public void setCreated(@Nonnull final Integer created) { } /** - * Set the model of this {@link LLMModuleResultSynchronous} instance and return the same instance. + * Set the model of this {@link LLMModuleResult} instance and return the same instance. * * @param model Model name - * @return The same instance of this {@link LLMModuleResultSynchronous} class + * @return The same instance of this {@link LLMModuleResult} class */ @Nonnull - public LLMModuleResultSynchronous model(@Nonnull final String model) { + public LLMModuleResult model(@Nonnull final String model) { this.model = model; return this; } @@ -168,7 +166,7 @@ public LLMModuleResultSynchronous model(@Nonnull final String model) { /** * Model name * - * @return model The model of this {@link LLMModuleResultSynchronous} instance. + * @return model The model of this {@link LLMModuleResult} instance. */ @Nonnull public String getModel() { @@ -176,7 +174,7 @@ public String getModel() { } /** - * Set the model of this {@link LLMModuleResultSynchronous} instance. + * Set the model of this {@link LLMModuleResult} instance. * * @param model Model name */ @@ -185,14 +183,14 @@ public void setModel(@Nonnull final String model) { } /** - * Set the systemFingerprint of this {@link LLMModuleResultSynchronous} instance and return the - * same instance. + * Set the systemFingerprint of this {@link LLMModuleResult} instance and return the same + * instance. * * @param systemFingerprint System fingerprint - * @return The same instance of this {@link LLMModuleResultSynchronous} class + * @return The same instance of this {@link LLMModuleResult} class */ @Nonnull - public LLMModuleResultSynchronous systemFingerprint(@Nullable final String systemFingerprint) { + public LLMModuleResult systemFingerprint(@Nullable final String systemFingerprint) { this.systemFingerprint = systemFingerprint; return this; } @@ -200,8 +198,7 @@ public LLMModuleResultSynchronous systemFingerprint(@Nullable final String syste /** * System fingerprint * - * @return systemFingerprint The systemFingerprint of this {@link LLMModuleResultSynchronous} - * instance. + * @return systemFingerprint The systemFingerprint of this {@link LLMModuleResult} instance. */ @Nonnull public String getSystemFingerprint() { @@ -209,7 +206,7 @@ public String getSystemFingerprint() { } /** - * Set the systemFingerprint of this {@link LLMModuleResultSynchronous} instance. + * Set the systemFingerprint of this {@link LLMModuleResult} instance. * * @param systemFingerprint System fingerprint */ @@ -218,27 +215,25 @@ public void setSystemFingerprint(@Nullable final String systemFingerprint) { } /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance and return the same - * instance. + * Set the choices of this {@link LLMModuleResult} instance and return the same instance. * * @param choices Choices - * @return The same instance of this {@link LLMModuleResultSynchronous} class + * @return The same instance of this {@link LLMModuleResult} class */ @Nonnull - public LLMModuleResultSynchronous choices(@Nonnull final List choices) { + public LLMModuleResult choices(@Nonnull final List choices) { this.choices = choices; return this; } /** - * Add one choices instance to this {@link LLMModuleResultSynchronous}. + * Add one choices instance to this {@link LLMModuleResult}. * * @param choicesItem The choices that should be added - * @return The same instance of type {@link LLMModuleResultSynchronous} + * @return The same instance of type {@link LLMModuleResult} */ @Nonnull - public LLMModuleResultSynchronous addChoicesItem( - @Nonnull final LLMChoiceSynchronous choicesItem) { + public LLMModuleResult addChoicesItem(@Nonnull final LLMChoice choicesItem) { if (this.choices == null) { this.choices = new ArrayList<>(); } @@ -249,30 +244,30 @@ public LLMModuleResultSynchronous addChoicesItem( /** * Choices * - * @return choices The choices of this {@link LLMModuleResultSynchronous} instance. + * @return choices The choices of this {@link LLMModuleResult} instance. */ @Nonnull - public List getChoices() { + public List getChoices() { return choices; } /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance. + * Set the choices of this {@link LLMModuleResult} instance. * * @param choices Choices */ - public void setChoices(@Nonnull final List choices) { + public void setChoices(@Nonnull final List choices) { this.choices = choices; } /** - * Set the usage of this {@link LLMModuleResultSynchronous} instance and return the same instance. + * Set the usage of this {@link LLMModuleResult} instance and return the same instance. * - * @param usage The usage of this {@link LLMModuleResultSynchronous} - * @return The same instance of this {@link LLMModuleResultSynchronous} class + * @param usage The usage of this {@link LLMModuleResult} + * @return The same instance of this {@link LLMModuleResult} class */ @Nonnull - public LLMModuleResultSynchronous usage(@Nonnull final TokenUsage usage) { + public LLMModuleResult usage(@Nonnull final TokenUsage usage) { this.usage = usage; return this; } @@ -280,7 +275,7 @@ public LLMModuleResultSynchronous usage(@Nonnull final TokenUsage usage) { /** * Get usage * - * @return usage The usage of this {@link LLMModuleResultSynchronous} instance. + * @return usage The usage of this {@link LLMModuleResult} instance. */ @Nonnull public TokenUsage getUsage() { @@ -288,16 +283,16 @@ public TokenUsage getUsage() { } /** - * Set the usage of this {@link LLMModuleResultSynchronous} instance. + * Set the usage of this {@link LLMModuleResult} instance. * - * @param usage The usage of this {@link LLMModuleResultSynchronous} + * @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 LLMModuleResultSynchronous}. + * Get the names of the unrecognizable properties of the {@link LLMModuleResult}. * * @return The set of properties names */ @@ -308,8 +303,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link LLMModuleResultSynchronous} - * instance. + * Get the value of an unrecognizable property of this {@link LLMModuleResult} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -320,15 +314,14 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException( - "LLMModuleResultSynchronous has no field with name '" + name + "'."); + throw new NoSuchElementException("LLMModuleResult has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link LLMModuleResultSynchronous} instance including - * unrecognized properties. + * Get the value of all properties of this {@link LLMModuleResult} instance including unrecognized + * properties. * * @return The map of all properties */ @@ -347,8 +340,8 @@ public Map toMap() { } /** - * 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. + * 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 @@ -366,16 +359,15 @@ public boolean equals(@Nullable final java.lang.Object o) { 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); + 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 @@ -388,7 +380,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class LLMModuleResultSynchronous {\n"); + 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"); @@ -414,8 +406,8 @@ private String toIndentedString(final java.lang.Object o) { } /** - * Create a type-safe, fluent-api builder object to construct a new {@link - * LLMModuleResultSynchronous} instance with all required arguments. + * 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) -> @@ -424,7 +416,7 @@ public static Builder create() { (model) -> (choices) -> (usage) -> - new LLMModuleResultSynchronous() + new LLMModuleResult() .id(id) ._object(_object) .created(created) @@ -436,10 +428,10 @@ public static Builder create() { /** Builder helper class. */ public interface Builder { /** - * Set the id of this {@link LLMModuleResultSynchronous} instance. + * Set the id of this {@link LLMModuleResult} instance. * * @param id ID of the response - * @return The LLMModuleResultSynchronous builder. + * @return The LLMModuleResult builder. */ Builder1 id(@Nonnull final String id); } @@ -447,10 +439,10 @@ public interface Builder { /** Builder helper class. */ public interface Builder1 { /** - * Set the _object of this {@link LLMModuleResultSynchronous} instance. + * Set the _object of this {@link LLMModuleResult} instance. * * @param _object Object type - * @return The LLMModuleResultSynchronous builder. + * @return The LLMModuleResult builder. */ Builder2 _object(@Nonnull final String _object); } @@ -458,10 +450,10 @@ public interface Builder1 { /** Builder helper class. */ public interface Builder2 { /** - * Set the created of this {@link LLMModuleResultSynchronous} instance. + * Set the created of this {@link LLMModuleResult} instance. * * @param created Unix timestamp - * @return The LLMModuleResultSynchronous builder. + * @return The LLMModuleResult builder. */ Builder3 created(@Nonnull final Integer created); } @@ -469,10 +461,10 @@ public interface Builder2 { /** Builder helper class. */ public interface Builder3 { /** - * Set the model of this {@link LLMModuleResultSynchronous} instance. + * Set the model of this {@link LLMModuleResult} instance. * * @param model Model name - * @return The LLMModuleResultSynchronous builder. + * @return The LLMModuleResult builder. */ Builder4 model(@Nonnull final String model); } @@ -480,20 +472,20 @@ public interface Builder3 { /** Builder helper class. */ public interface Builder4 { /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance. + * Set the choices of this {@link LLMModuleResult} instance. * * @param choices Choices - * @return The LLMModuleResultSynchronous builder. + * @return The LLMModuleResult builder. */ - Builder5 choices(@Nonnull final List choices); + Builder5 choices(@Nonnull final List choices); /** - * Set the choices of this {@link LLMModuleResultSynchronous} instance. + * Set the choices of this {@link LLMModuleResult} instance. * * @param choices Choices - * @return The LLMModuleResultSynchronous builder. + * @return The LLMModuleResult builder. */ - default Builder5 choices(@Nonnull final LLMChoiceSynchronous... choices) { + default Builder5 choices(@Nonnull final LLMChoice... choices) { return choices(Arrays.asList(choices)); } } @@ -501,11 +493,11 @@ default Builder5 choices(@Nonnull final LLMChoiceSynchronous... choices) { /** Builder helper class. */ public interface Builder5 { /** - * Set the usage of this {@link LLMModuleResultSynchronous} instance. + * Set the usage of this {@link LLMModuleResult} instance. * - * @param usage The usage of this {@link LLMModuleResultSynchronous} - * @return The LLMModuleResultSynchronous instance. + * @param usage The usage of this {@link LLMModuleResult} + * @return The LLMModuleResult instance. */ - LLMModuleResultSynchronous usage(@Nonnull final TokenUsage usage); + LLMModuleResult 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/ModuleResultsSynchronous.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java similarity index 63% rename from orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsSynchronous.java rename to orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java index 7db2e0be2..d5af953ad 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsSynchronous.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResults.java @@ -27,7 +27,7 @@ /** Synchronous results of each module. */ // CHECKSTYLE:OFF -public class ModuleResultsSynchronous +public class ModuleResults // CHECKSTYLE:ON { @JsonProperty("grounding") @@ -52,26 +52,25 @@ public class ModuleResultsSynchronous private GenericModuleResult outputTranslation; @JsonProperty("llm") - private LLMModuleResultSynchronous llm; + private LLMModuleResult llm; @JsonProperty("output_unmasking") - private List outputUnmasking = new ArrayList<>(); + private List outputUnmasking = new ArrayList<>(); @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - /** Default constructor for ModuleResultsSynchronous. */ - protected ModuleResultsSynchronous() {} + /** Default constructor for ModuleResults. */ + protected ModuleResults() {} /** - * Set the grounding of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the grounding of this {@link ModuleResults} instance and return the same instance. * - * @param grounding The grounding of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param grounding The grounding of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous grounding(@Nullable final GenericModuleResult grounding) { + public ModuleResults grounding(@Nullable final GenericModuleResult grounding) { this.grounding = grounding; return this; } @@ -79,7 +78,7 @@ public ModuleResultsSynchronous grounding(@Nullable final GenericModuleResult gr /** * Get grounding * - * @return grounding The grounding of this {@link ModuleResultsSynchronous} instance. + * @return grounding The grounding of this {@link ModuleResults} instance. */ @Nonnull public GenericModuleResult getGrounding() { @@ -87,35 +86,34 @@ public GenericModuleResult getGrounding() { } /** - * Set the grounding of this {@link ModuleResultsSynchronous} instance. + * Set the grounding of this {@link ModuleResults} instance. * - * @param grounding The grounding of this {@link ModuleResultsSynchronous} + * @param grounding The grounding of this {@link ModuleResults} */ public void setGrounding(@Nullable final GenericModuleResult grounding) { this.grounding = grounding; } /** - * Set the templating of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the templating of this {@link ModuleResults} instance and return the same instance. * - * @param templating The templating of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param templating The templating of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous templating(@Nullable final List templating) { + public ModuleResults templating(@Nullable final List templating) { this.templating = templating; return this; } /** - * Add one templating instance to this {@link ModuleResultsSynchronous}. + * Add one templating instance to this {@link ModuleResults}. * * @param templatingItem The templating that should be added - * @return The same instance of type {@link ModuleResultsSynchronous} + * @return The same instance of type {@link ModuleResults} */ @Nonnull - public ModuleResultsSynchronous addTemplatingItem(@Nonnull final ChatMessage templatingItem) { + public ModuleResults addTemplatingItem(@Nonnull final ChatMessage templatingItem) { if (this.templating == null) { this.templating = new ArrayList<>(); } @@ -126,7 +124,7 @@ public ModuleResultsSynchronous addTemplatingItem(@Nonnull final ChatMessage tem /** * Get templating * - * @return templating The templating of this {@link ModuleResultsSynchronous} instance. + * @return templating The templating of this {@link ModuleResults} instance. */ @Nonnull public List getTemplating() { @@ -134,24 +132,22 @@ public List getTemplating() { } /** - * Set the templating of this {@link ModuleResultsSynchronous} instance. + * Set the templating of this {@link ModuleResults} instance. * - * @param templating The templating of this {@link ModuleResultsSynchronous} + * @param templating The templating of this {@link ModuleResults} */ public void setTemplating(@Nullable final List templating) { this.templating = templating; } /** - * Set the inputTranslation of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the inputTranslation of this {@link ModuleResults} instance and return the same instance. * - * @param inputTranslation The inputTranslation of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param inputTranslation The inputTranslation of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous inputTranslation( - @Nullable final GenericModuleResult inputTranslation) { + public ModuleResults inputTranslation(@Nullable final GenericModuleResult inputTranslation) { this.inputTranslation = inputTranslation; return this; } @@ -159,8 +155,7 @@ public ModuleResultsSynchronous inputTranslation( /** * Get inputTranslation * - * @return inputTranslation The inputTranslation of this {@link ModuleResultsSynchronous} - * instance. + * @return inputTranslation The inputTranslation of this {@link ModuleResults} instance. */ @Nonnull public GenericModuleResult getInputTranslation() { @@ -168,23 +163,22 @@ public GenericModuleResult getInputTranslation() { } /** - * Set the inputTranslation of this {@link ModuleResultsSynchronous} instance. + * Set the inputTranslation of this {@link ModuleResults} instance. * - * @param inputTranslation The inputTranslation of this {@link ModuleResultsSynchronous} + * @param inputTranslation The inputTranslation of this {@link ModuleResults} */ public void setInputTranslation(@Nullable final GenericModuleResult inputTranslation) { this.inputTranslation = inputTranslation; } /** - * Set the inputMasking of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the inputMasking of this {@link ModuleResults} instance and return the same instance. * - * @param inputMasking The inputMasking of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param inputMasking The inputMasking of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous inputMasking(@Nullable final GenericModuleResult inputMasking) { + public ModuleResults inputMasking(@Nullable final GenericModuleResult inputMasking) { this.inputMasking = inputMasking; return this; } @@ -192,7 +186,7 @@ public ModuleResultsSynchronous inputMasking(@Nullable final GenericModuleResult /** * Get inputMasking * - * @return inputMasking The inputMasking of this {@link ModuleResultsSynchronous} instance. + * @return inputMasking The inputMasking of this {@link ModuleResults} instance. */ @Nonnull public GenericModuleResult getInputMasking() { @@ -200,24 +194,22 @@ public GenericModuleResult getInputMasking() { } /** - * Set the inputMasking of this {@link ModuleResultsSynchronous} instance. + * Set the inputMasking of this {@link ModuleResults} instance. * - * @param inputMasking The inputMasking of this {@link ModuleResultsSynchronous} + * @param inputMasking The inputMasking of this {@link ModuleResults} */ public void setInputMasking(@Nullable final GenericModuleResult inputMasking) { this.inputMasking = inputMasking; } /** - * Set the inputFiltering of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the inputFiltering of this {@link ModuleResults} instance and return the same instance. * - * @param inputFiltering The inputFiltering of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param inputFiltering The inputFiltering of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous inputFiltering( - @Nullable final GenericModuleResult inputFiltering) { + public ModuleResults inputFiltering(@Nullable final GenericModuleResult inputFiltering) { this.inputFiltering = inputFiltering; return this; } @@ -225,7 +217,7 @@ public ModuleResultsSynchronous inputFiltering( /** * Get inputFiltering * - * @return inputFiltering The inputFiltering of this {@link ModuleResultsSynchronous} instance. + * @return inputFiltering The inputFiltering of this {@link ModuleResults} instance. */ @Nonnull public GenericModuleResult getInputFiltering() { @@ -233,24 +225,22 @@ public GenericModuleResult getInputFiltering() { } /** - * Set the inputFiltering of this {@link ModuleResultsSynchronous} instance. + * Set the inputFiltering of this {@link ModuleResults} instance. * - * @param inputFiltering The inputFiltering of this {@link ModuleResultsSynchronous} + * @param inputFiltering The inputFiltering of this {@link ModuleResults} */ public void setInputFiltering(@Nullable final GenericModuleResult inputFiltering) { this.inputFiltering = inputFiltering; } /** - * Set the outputFiltering of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the outputFiltering of this {@link ModuleResults} instance and return the same instance. * - * @param outputFiltering The outputFiltering of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param outputFiltering The outputFiltering of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous outputFiltering( - @Nullable final GenericModuleResult outputFiltering) { + public ModuleResults outputFiltering(@Nullable final GenericModuleResult outputFiltering) { this.outputFiltering = outputFiltering; return this; } @@ -258,7 +248,7 @@ public ModuleResultsSynchronous outputFiltering( /** * Get outputFiltering * - * @return outputFiltering The outputFiltering of this {@link ModuleResultsSynchronous} instance. + * @return outputFiltering The outputFiltering of this {@link ModuleResults} instance. */ @Nonnull public GenericModuleResult getOutputFiltering() { @@ -266,24 +256,22 @@ public GenericModuleResult getOutputFiltering() { } /** - * Set the outputFiltering of this {@link ModuleResultsSynchronous} instance. + * Set the outputFiltering of this {@link ModuleResults} instance. * - * @param outputFiltering The outputFiltering of this {@link ModuleResultsSynchronous} + * @param outputFiltering The outputFiltering of this {@link ModuleResults} */ public void setOutputFiltering(@Nullable final GenericModuleResult outputFiltering) { this.outputFiltering = outputFiltering; } /** - * Set the outputTranslation of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the outputTranslation of this {@link ModuleResults} instance and return the same instance. * - * @param outputTranslation The outputTranslation of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param outputTranslation The outputTranslation of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous outputTranslation( - @Nullable final GenericModuleResult outputTranslation) { + public ModuleResults outputTranslation(@Nullable final GenericModuleResult outputTranslation) { this.outputTranslation = outputTranslation; return this; } @@ -291,8 +279,7 @@ public ModuleResultsSynchronous outputTranslation( /** * Get outputTranslation * - * @return outputTranslation The outputTranslation of this {@link ModuleResultsSynchronous} - * instance. + * @return outputTranslation The outputTranslation of this {@link ModuleResults} instance. */ @Nonnull public GenericModuleResult getOutputTranslation() { @@ -300,22 +287,22 @@ public GenericModuleResult getOutputTranslation() { } /** - * Set the outputTranslation of this {@link ModuleResultsSynchronous} instance. + * Set the outputTranslation of this {@link ModuleResults} instance. * - * @param outputTranslation The outputTranslation of this {@link ModuleResultsSynchronous} + * @param outputTranslation The outputTranslation of this {@link ModuleResults} */ public void setOutputTranslation(@Nullable final GenericModuleResult outputTranslation) { this.outputTranslation = outputTranslation; } /** - * Set the llm of this {@link ModuleResultsSynchronous} instance and return the same instance. + * Set the llm of this {@link ModuleResults} instance and return the same instance. * - * @param llm The llm of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param llm The llm of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous llm(@Nullable final LLMModuleResultSynchronous llm) { + public ModuleResults llm(@Nullable final LLMModuleResult llm) { this.llm = llm; return this; } @@ -323,45 +310,42 @@ public ModuleResultsSynchronous llm(@Nullable final LLMModuleResultSynchronous l /** * Get llm * - * @return llm The llm of this {@link ModuleResultsSynchronous} instance. + * @return llm The llm of this {@link ModuleResults} instance. */ @Nonnull - public LLMModuleResultSynchronous getLlm() { + public LLMModuleResult getLlm() { return llm; } /** - * Set the llm of this {@link ModuleResultsSynchronous} instance. + * Set the llm of this {@link ModuleResults} instance. * - * @param llm The llm of this {@link ModuleResultsSynchronous} + * @param llm The llm of this {@link ModuleResults} */ - public void setLlm(@Nullable final LLMModuleResultSynchronous llm) { + public void setLlm(@Nullable final LLMModuleResult llm) { this.llm = llm; } /** - * Set the outputUnmasking of this {@link ModuleResultsSynchronous} instance and return the same - * instance. + * Set the outputUnmasking of this {@link ModuleResults} instance and return the same instance. * - * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsSynchronous} - * @return The same instance of this {@link ModuleResultsSynchronous} class + * @param outputUnmasking The outputUnmasking of this {@link ModuleResults} + * @return The same instance of this {@link ModuleResults} class */ @Nonnull - public ModuleResultsSynchronous outputUnmasking( - @Nullable final List outputUnmasking) { + public ModuleResults outputUnmasking(@Nullable final List outputUnmasking) { this.outputUnmasking = outputUnmasking; return this; } /** - * Add one outputUnmasking instance to this {@link ModuleResultsSynchronous}. + * Add one outputUnmasking instance to this {@link ModuleResults}. * * @param outputUnmaskingItem The outputUnmasking that should be added - * @return The same instance of type {@link ModuleResultsSynchronous} + * @return The same instance of type {@link ModuleResults} */ @Nonnull - public ModuleResultsSynchronous addOutputUnmaskingItem( - @Nonnull final LLMChoiceSynchronous outputUnmaskingItem) { + public ModuleResults addOutputUnmaskingItem(@Nonnull final LLMChoice outputUnmaskingItem) { if (this.outputUnmasking == null) { this.outputUnmasking = new ArrayList<>(); } @@ -372,24 +356,24 @@ public ModuleResultsSynchronous addOutputUnmaskingItem( /** * Get outputUnmasking * - * @return outputUnmasking The outputUnmasking of this {@link ModuleResultsSynchronous} instance. + * @return outputUnmasking The outputUnmasking of this {@link ModuleResults} instance. */ @Nonnull - public List getOutputUnmasking() { + public List getOutputUnmasking() { return outputUnmasking; } /** - * Set the outputUnmasking of this {@link ModuleResultsSynchronous} instance. + * Set the outputUnmasking of this {@link ModuleResults} instance. * - * @param outputUnmasking The outputUnmasking of this {@link ModuleResultsSynchronous} + * @param outputUnmasking The outputUnmasking of this {@link ModuleResults} */ - public void setOutputUnmasking(@Nullable final List outputUnmasking) { + public void setOutputUnmasking(@Nullable final List outputUnmasking) { this.outputUnmasking = outputUnmasking; } /** - * Get the names of the unrecognizable properties of the {@link ModuleResultsSynchronous}. + * Get the names of the unrecognizable properties of the {@link ModuleResults}. * * @return The set of properties names */ @@ -400,7 +384,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link ModuleResultsSynchronous} instance. + * Get the value of an unrecognizable property of this {@link ModuleResults} instance. * * @deprecated Use {@link #toMap()} instead. * @param name The name of the property @@ -411,15 +395,14 @@ public Set getCustomFieldNames() { @Deprecated public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { if (!cloudSdkCustomFields.containsKey(name)) { - throw new NoSuchElementException( - "ModuleResultsSynchronous has no field with name '" + name + "'."); + throw new NoSuchElementException("ModuleResults has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Get the value of all properties of this {@link ModuleResultsSynchronous} instance including - * unrecognized properties. + * Get the value of all properties of this {@link ModuleResults} instance including unrecognized + * properties. * * @return The map of all properties */ @@ -440,8 +423,8 @@ public Map toMap() { } /** - * Set an unrecognizable property of this {@link ModuleResultsSynchronous} instance. If the map - * previously contained a mapping for the key, the old value is replaced by the specified value. + * Set an unrecognizable property of this {@link ModuleResults} 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 @@ -459,17 +442,17 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final ModuleResultsSynchronous moduleResultsSynchronous = (ModuleResultsSynchronous) o; - return Objects.equals(this.cloudSdkCustomFields, moduleResultsSynchronous.cloudSdkCustomFields) - && Objects.equals(this.grounding, moduleResultsSynchronous.grounding) - && Objects.equals(this.templating, moduleResultsSynchronous.templating) - && Objects.equals(this.inputTranslation, moduleResultsSynchronous.inputTranslation) - && Objects.equals(this.inputMasking, moduleResultsSynchronous.inputMasking) - && Objects.equals(this.inputFiltering, moduleResultsSynchronous.inputFiltering) - && Objects.equals(this.outputFiltering, moduleResultsSynchronous.outputFiltering) - && Objects.equals(this.outputTranslation, moduleResultsSynchronous.outputTranslation) - && Objects.equals(this.llm, moduleResultsSynchronous.llm) - && Objects.equals(this.outputUnmasking, moduleResultsSynchronous.outputUnmasking); + final ModuleResults moduleResults = (ModuleResults) o; + return Objects.equals(this.cloudSdkCustomFields, moduleResults.cloudSdkCustomFields) + && Objects.equals(this.grounding, moduleResults.grounding) + && Objects.equals(this.templating, moduleResults.templating) + && Objects.equals(this.inputTranslation, moduleResults.inputTranslation) + && Objects.equals(this.inputMasking, moduleResults.inputMasking) + && Objects.equals(this.inputFiltering, moduleResults.inputFiltering) + && Objects.equals(this.outputFiltering, moduleResults.outputFiltering) + && Objects.equals(this.outputTranslation, moduleResults.outputTranslation) + && Objects.equals(this.llm, moduleResults.llm) + && Objects.equals(this.outputUnmasking, moduleResults.outputUnmasking); } @Override @@ -491,7 +474,7 @@ public int hashCode() { @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class ModuleResultsSynchronous {\n"); + sb.append("class ModuleResults {\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"); @@ -518,8 +501,8 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - /** Create a new {@link ModuleResultsSynchronous} instance. No arguments are required. */ - public static ModuleResultsSynchronous create() { - return new ModuleResultsSynchronous(); + /** Create a new {@link ModuleResults} instance. No arguments are required. */ + public static ModuleResults create() { + return new ModuleResults(); } } diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.java new file mode 100644 index 000000000..a8565a3f5 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/OutputFilterConfig.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; + +/** OutputFilterConfig */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = AzureContentSafetyOutputFilterConfig.class), + @JsonSubTypes.Type(value = LlamaGuard38bFilterConfig.class), +}) +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/spring/OrchestrationSpringChatResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationSpringChatResponse.java index fde3e39a1..c57a2c630 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 @@ -2,8 +2,8 @@ import com.google.common.annotations.Beta; import com.sap.ai.sdk.orchestration.OrchestrationChatResponse; -import com.sap.ai.sdk.orchestration.model.LLMChoiceSynchronous; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMChoice; +import com.sap.ai.sdk.orchestration.model.LLMModuleResult; import com.sap.ai.sdk.orchestration.model.TokenUsage; import java.util.List; import java.util.Map; @@ -40,12 +40,12 @@ public class OrchestrationSpringChatResponse extends ChatResponse { } @Nonnull - static List toGenerations(@Nonnull final LLMModuleResultSynchronous result) { + static List toGenerations(@Nonnull final LLMModuleResult result) { return result.getChoices().stream().map(OrchestrationSpringChatResponse::toGeneration).toList(); } @Nonnull - static Generation toGeneration(@Nonnull final LLMChoiceSynchronous choice) { + static Generation toGeneration(@Nonnull final LLMChoice choice) { val metadata = ChatGenerationMetadata.builder().finishReason(choice.getFinishReason()); metadata.metadata("index", choice.getIndex()); if (!choice.getLogprobs().isEmpty()) { @@ -68,7 +68,7 @@ static Generation toGeneration(@Nonnull final LLMChoiceSynchronous 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 4bddce366..270b94f90 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -33,7 +33,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/CompletionPostResponseSynchronous" + $ref: "#/components/schemas/CompletionPostResponse" text/event-stream: schema: $ref: "#/components/schemas/CompletionPostResponseStreaming" @@ -98,19 +98,19 @@ components: additionalProperties: false required: - input - - orchestration_config + - config properties: - orchestration_config: + config: $ref: "#/components/schemas/EmbeddingsOrchestrationConfig" input: $ref: "#/components/schemas/EmbeddingsInput" EmbeddingsOrchestrationConfig: type: object required: - - module_configs + - modules additionalProperties: false properties: - module_configs: + modules: $ref: "#/components/schemas/EmbeddingsModuleConfigs" EmbeddingsInput: type: object @@ -193,10 +193,10 @@ components: properties: request_id: type: string - module_results: + intermediate_results: $ref: "#/components/schemas/ModuleResultsBase" description: Results of each module of /embeddings endpoint(e.g. input masking). - orchestration_result: + final_result: $ref: "#/components/schemas/EmbeddingsResponse" description: The response from request to embedding model following OpenAI specification. EmbeddingsResponse: @@ -514,7 +514,7 @@ components: calling your function. required: - index - CompletionPostResponseSynchronous: + CompletionPostResponse: type: object required: - request_id @@ -526,9 +526,9 @@ components: type: string example: "d4a67ea1-2bf9-4df7-8105-d48203ccff76" module_results: - $ref: "#/components/schemas/ModuleResultsSynchronous" + $ref: "#/components/schemas/ModuleResults" orchestration_result: - $ref: "#/components/schemas/LLMModuleResultSynchronous" + $ref: "#/components/schemas/LLMModuleResult" CompletionPostResponseStreaming: type: object @@ -577,7 +577,7 @@ components: $ref: "#/components/schemas/InputTranslationModuleConfig" output_translation_module_config: $ref: "#/components/schemas/OutputTranslationModuleConfig" - # Abstract base class encompassing fields for both `ModuleResultsSynchronous` and `ModuleResultsStreaming` + # Abstract base class encompassing fields for both `ModuleResults` and `ModuleResultsStreaming` # Not to be instantiated by llm-orchestration code ModuleResultsBase: description: Results of each module. @@ -598,7 +598,7 @@ components: $ref: "#/components/schemas/GenericModuleResult" output_translation: $ref: "#/components/schemas/GenericModuleResult" - ModuleResultsSynchronous: + ModuleResults: description: Synchronous results of each module. type: object additionalProperties: false @@ -607,11 +607,11 @@ components: - type: object properties: llm: - $ref: "#/components/schemas/LLMModuleResultSynchronous" + $ref: "#/components/schemas/LLMModuleResult" output_unmasking: type: array items: - $ref: "#/components/schemas/LLMChoiceSynchronous" + $ref: "#/components/schemas/LLMChoice" ModuleResultsStreaming: description: Streaming results of each module. type: object @@ -685,7 +685,7 @@ components: data: type: object description: Additional data object from the module - LLMModuleResultSynchronous: + LLMModuleResult: type: object description: Output of LLM module. Follows the OpenAI spec. required: @@ -720,7 +720,7 @@ components: type: array description: Choices items: - $ref: "#/components/schemas/LLMChoiceSynchronous" + $ref: "#/components/schemas/LLMChoice" usage: $ref: "#/components/schemas/TokenUsage" LLMModuleResultStreaming: @@ -755,7 +755,7 @@ components: $ref: "#/components/schemas/LLMChoiceStreaming" usage: $ref: "#/components/schemas/TokenUsage" - LLMChoiceSynchronous: + LLMChoice: type: object required: - index @@ -1062,11 +1062,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 @@ -1075,11 +1075,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" @@ -1095,12 +1095,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 @@ -1113,9 +1118,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 @@ -1543,7 +1581,7 @@ components: description: Language to which the text should be translated. example: "en-US" - ErrorResponseSynchronous: + ErrorResponse: type: object required: - request_id @@ -1565,7 +1603,7 @@ components: description: Where the error occurred example: "LLM Module" module_results: - $ref: "#/components/schemas/ModuleResultsSynchronous" + $ref: "#/components/schemas/ModuleResults" ErrorResponseStreaming: type: object @@ -1597,13 +1635,13 @@ components: content: application/json: schema: - $ref: "#/components/schemas/ErrorResponseSynchronous" + $ref: "#/components/schemas/ErrorResponse" CommonError: description: Common Error content: application/json: schema: - $ref: "#/components/schemas/ErrorResponseSynchronous" + $ref: "#/components/schemas/ErrorResponse" # https://pages.github.tools.sap/CPA/api-metadata-validator/rules/oas/sap-oas3-security/ securitySchemes: @@ -1611,4 +1649,4 @@ components: type: http scheme: bearer bearerFormat: JWT - description: To use this API, you must have an AI Core access token. + description: To use this API, you must have an AI Core access token. \ No newline at end of file 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 1b75c75fb..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 @@ -2,7 +2,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMModuleResult; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; @@ -41,7 +41,7 @@ void testSubtypeResolutionSynchronous() { """; var json = String.format(JSON, choices); - var result = OrchestrationClient.JACKSON.readValue(json, LLMModuleResultSynchronous.class); - assertThat(result).isExactlyInstanceOf(LLMModuleResultSynchronous.class); + var result = OrchestrationClient.JACKSON.readValue(json, LLMModuleResult.class); + assertThat(result).isExactlyInstanceOf(LLMModuleResult.class); } } 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 8b7ab32bb..9a3e39dd5 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 @@ -1083,7 +1083,7 @@ void testEmbeddingCallWithMasking() { """ { "request_id": "2ee98443-e1ee-9503-b800-e38b5b80fe45", - "module_results": { + "intermediate_results": { "input_masking": { "message": "Embedding input is masked successfully.", "data": { @@ -1091,7 +1091,7 @@ void testEmbeddingCallWithMasking() { } } }, - "orchestration_result": { + "final_result": { "object": "list", "data": [ { @@ -1134,21 +1134,20 @@ void testEmbeddingCallWithMasking() { val orchestrationConfig = EmbeddingsOrchestrationConfig.create() - .moduleConfigs( + .modules( EmbeddingsModuleConfigs.create().embeddings(modelConfig).masking(maskingConfig)); val inputText = EmbeddingsInput.create().text(EmbeddingsInputText.create("['Hello', 'Müller', '!']")); - val request = - EmbeddingsPostRequest.create().orchestrationConfig(orchestrationConfig).input(inputText); + 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.getOrchestrationResult(); + val orchestrationResult = response.getFinalResult(); assertThat(orchestrationResult).isNotNull(); assertThat(orchestrationResult.getObject()).isEqualTo(EmbeddingsResponse.ObjectEnum.LIST); assertThat(orchestrationResult.getModel()).isEqualTo("text-embedding-3-large"); @@ -1171,7 +1170,7 @@ void testEmbeddingCallWithMasking() { assertThat(usage.getPromptTokens()).isEqualTo(10); assertThat(usage.getTotalTokens()).isEqualTo(10); - val moduleResults = response.getModuleResults(); + val moduleResults = response.getIntermediateResults(); assertThat(moduleResults).isNotNull(); assertThat(moduleResults.getInputMasking()).isNotNull(); assertThat(moduleResults.getInputMasking().getMessage()) @@ -1186,8 +1185,8 @@ void testEmbeddingCallWithMasking() { equalToJson( """ { - "orchestration_config": { - "module_configs": { + "config": { + "modules": { "embeddings": { "model": { "name": "text-embedding-3-large", 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 6b047ecac..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 @@ -2,8 +2,8 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.sap.ai.sdk.orchestration.model.LLMChoiceSynchronous; -import com.sap.ai.sdk.orchestration.model.LLMModuleResultSynchronous; +import com.sap.ai.sdk.orchestration.model.LLMChoice; +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; @@ -15,7 +15,7 @@ class OrchestrationChatResponseTest { @Test void testToGeneration() { var choice = - LLMChoiceSynchronous.create() + LLMChoice.create() .index(0) .message( ResponseChatMessage.create() @@ -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 231cf754c..67b983881 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,7 @@ public OrchestrationChatResponse inputFiltering(@Nonnull final AzureFilterThresh val prompt = new OrchestrationPrompt("'We shall spill blood tonight', said the operation 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); From 4d15b912568e275d6b3e1054d0cb3b10db5735cf Mon Sep 17 00:00:00 2001 From: Roshin Rajan Panackal Date: Tue, 1 Jul 2025 11:25:01 +0200 Subject: [PATCH 09/12] Make embedding client endpoint non-visible and update javadoc (minor) --- .../ai/sdk/orchestration/AzureContentFilter.java | 14 +++++++++----- .../ai/sdk/orchestration/OrchestrationClient.java | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) 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 248ae082a..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 @@ -36,19 +36,23 @@ @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; - /* A flag to set prompt shield on input filer.*/ + /** + * A flag to set prompt shield on input filer. + * + * @since 1.9.0 + */ @Nullable Boolean promptShield; /** 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 b93f67a86..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 @@ -209,7 +209,7 @@ public Stream streamChatCompletionDeltas( * @since 1.9.0 */ @Nonnull - public EmbeddingsPostResponse embed(@Nonnull final EmbeddingsPostRequest request) + EmbeddingsPostResponse embed(@Nonnull final EmbeddingsPostRequest request) throws OrchestrationClientException { return executor.execute("/v2/embeddings", request, EmbeddingsPostResponse.class); } From 05ac10fadecdc203c22868fd13a2cfae6b301d0f Mon Sep 17 00:00:00 2001 From: I538344 Date: Wed, 2 Jul 2025 13:53:41 +0200 Subject: [PATCH 10/12] merge main --- .../sap/ai/sdk/orchestration/OrchestrationChatResponse.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 53d4d4903..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 @@ -123,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() From b58bc5e30a9ef12938e3c12f5d8df173b0dad473 Mon Sep 17 00:00:00 2001 From: SAP Cloud SDK Bot Date: Wed, 2 Jul 2025 11:57:14 +0000 Subject: [PATCH 11/12] Formatting --- .../com/sap/ai/sdk/app/services/OrchestrationService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 2a367136f..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).promptShield(true); + new AzureContentFilter() + .hate(policy) + .selfHarm(policy) + .sexual(policy) + .violence(policy) + .promptShield(true); val configWithFilter = config.withInputFiltering(filterConfig); From 46413d075d03bcddbc2836a43fcd34d93ab92977 Mon Sep 17 00:00:00 2001 From: I538344 Date: Tue, 8 Jul 2025 11:09:24 +0200 Subject: [PATCH 12/12] 0.81.4 --- .../model/ChatCompletionTokenLogprob.java | 354 ++++++++++++++++++ ...ompletionTokenLogprobTopLogprobsInner.java | 301 +++++++++++++++ .../orchestration/model/ChoiceLogprobs.java | 239 ++++++++++++ .../model/EmbeddingsResponse.java | 2 +- .../ai/sdk/orchestration/model/LLMChoice.java | 34 +- .../model/LLMChoiceStreaming.java | 34 +- .../model/ModuleResultsBase.java | 2 +- .../spring/OrchestrationSpringChatDelta.java | 4 +- .../OrchestrationSpringChatResponse.java | 4 +- .../main/resources/spec/orchestration.yaml | 87 ++++- 10 files changed, 984 insertions(+), 77 deletions(-) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprob.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChatCompletionTokenLogprobTopLogprobsInner.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ChoiceLogprobs.java 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/EmbeddingsResponse.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/EmbeddingsResponse.java index 7cd0f3140..c247199bb 100644 --- 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 @@ -28,7 +28,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** EmbeddingsResponse */ +/** The response from request to embedding model following OpenAI specification. */ // CHECKSTYLE:OFF public class EmbeddingsResponse // CHECKSTYLE:ON 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 c9aea33be..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; @@ -38,7 +35,7 @@ public class LLMChoice 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 0ccfaa149..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; @@ -38,7 +35,7 @@ public class LLMChoiceStreaming 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/ModuleResultsBase.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/ModuleResultsBase.java index e3a415e74..5e8c22035 100644 --- 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 @@ -25,7 +25,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** Results of each module. */ +/** Results of each module of /embeddings endpoint(e.g. input masking). */ // CHECKSTYLE:OFF public class ModuleResultsBase // CHECKSTYLE:ON 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 256bcc2b0..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 @@ -42,8 +42,8 @@ static List toGenerations(@Nonnull final LLMModuleResultStreaming re 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(choice.getDelta().getContent()), metadata.build()); } 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 c57a2c630..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 @@ -48,8 +48,8 @@ static List toGenerations(@Nonnull final LLMModuleResult result) { 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() diff --git a/orchestration/src/main/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index 270b94f90..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: @@ -134,7 +138,7 @@ components: items: type: string minLength: 1 - example: "['Hello', 'World', '!']" + 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: @@ -195,12 +199,11 @@ components: type: string intermediate_results: $ref: "#/components/schemas/ModuleResultsBase" - description: Results of each module of /embeddings endpoint(e.g. input masking). final_result: $ref: "#/components/schemas/EmbeddingsResponse" - description: The response from request to embedding model following OpenAI specification. EmbeddingsResponse: type: object + description: The response from request to embedding model following OpenAI specification. additionalProperties: false required: - object @@ -580,7 +583,7 @@ components: # Abstract base class encompassing fields for both `ModuleResults` and `ModuleResultsStreaming` # Not to be instantiated by llm-orchestration code ModuleResultsBase: - description: Results of each module. + description: Results of each module of /embeddings endpoint(e.g. input masking). type: object additionalProperties: false properties: @@ -665,6 +668,7 @@ components: frequency_penalty: 0 presence_penalty: 0 n: 2 + logprobs: true stream_options: include_usage: true additionalProperties: true @@ -769,12 +773,7 @@ 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" @@ -791,12 +790,7 @@ 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 @@ -1629,6 +1623,65 @@ components: 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 @@ -1649,4 +1702,4 @@ components: type: http scheme: bearer bearerFormat: JWT - description: To use this API, you must have an AI Core access token. \ No newline at end of file + description: To use this API, you must have an AI Core access token.