diff --git a/.pipeline/checkstyle-suppressions.xml b/.pipeline/checkstyle-suppressions.xml index 84779d480..519684154 100644 --- a/.pipeline/checkstyle-suppressions.xml +++ b/.pipeline/checkstyle-suppressions.xml @@ -9,6 +9,7 @@ + diff --git a/foundation-models/sap-rpt/pom.xml b/foundation-models/sap-rpt/pom.xml new file mode 100644 index 000000000..38f1c8ccd --- /dev/null +++ b/foundation-models/sap-rpt/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + + com.sap.ai.sdk + sdk-parent + 1.16.0-SNAPSHOT + ../../pom.xml + + com.sap.ai.sdk.foundationmodels + sap-rpt + SAP RPT Model Client + SAP Cloud SDK for AI is the official Software Development Kit (SDK) for SAP AI Core, SAP Generative AI Hub, and Orchestration Service. This is the client for consuming SAP RPT model for in-context learning predictions on tabular data. + https://github.com/SAP/ai-sdk-java?tab=readme-ov-file#documentation + + SAP SE + https://www.sap.com + + + + The Apache Software License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + SAP + cloudsdk@sap.com + SAP SE + https://www.sap.com + + + + scm:git:git://github.com/SAP/ai-sdk-java.git + scm:git:ssh://github.com:SAP/ai-sdk-java.git + https://github.com/SAP/ai-sdk-java/tree/main + + + ${project.basedir}/../../ + 83% + 77% + 82% + 100% + 83% + + + + + com.sap.ai.sdk + core + + + com.sap.cloud.sdk.cloudplatform + cloudplatform-connectivity + + + com.sap.cloud.sdk.datamodel + openapi-core + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.google.code.findbugs + jsr305 + + + + org.projectlombok + lombok + provided + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.assertj + assertj-core + test + + + org.wiremock + wiremock + test + + + com.sap.cloud.sdk.cloudplatform + connectivity-apache-httpclient5 + test + + + + + generate + + false + + generate + + + + + + com.sap.cloud.sdk.datamodel + openapi-generator-maven-plugin + + ${project.basedir}/src/main/java + true + COMPILE + true + + + + sap-rpt + + generate + + generate-sources + + ${project.basedir}/src/main/resources/spec/sap-rpt-1_openapi.json + com.sap.ai.sdk.foundationmodels.rpt.generated.model + com.sap.ai.sdk.foundationmodels.rpt.generated.client + true + + apache-httpclient + create + true + true + true + true + /predict_parquet + + + + + + + + + + diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptClient.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptClient.java new file mode 100644 index 000000000..51e8aa66b --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptClient.java @@ -0,0 +1,68 @@ +package com.sap.ai.sdk.foundationmodels.rpt; + +import static com.sap.ai.sdk.core.JacksonConfiguration.getDefaultObjectMapper; + +import com.sap.ai.sdk.core.AiCoreService; +import com.sap.ai.sdk.core.DeploymentResolutionException; +import com.sap.ai.sdk.foundationmodels.rpt.generated.client.DefaultApi; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictRequestPayload; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictResponsePayload; +import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; +import com.sap.cloud.sdk.services.openapi.apache.ApiClient; +import javax.annotation.Nonnull; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; + +/** + * Client for interacting with SAP RPT foundation models. + * + * @since 1.16.0 + */ +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public class RptClient { + @Nonnull private final DefaultApi api; + + /** + * Creates a new RptClient for the specified foundation model. + * + * @param foundationModel The foundation model to use. + * @return A new instance of RptClient. + * @throws DeploymentResolutionException If there is an error resolving the deployment. + */ + @Nonnull + public static RptClient forModel(@Nonnull final RptModel foundationModel) + throws DeploymentResolutionException { + final var destination = new AiCoreService().getInferenceDestination().forModel(foundationModel); + return forDestination(destination); + } + + /** + * Creates a new RptClient for the specified destination. + * + * @param destination The destination to use. + * @return A new instance of RptClient. + */ + static RptClient forDestination(@Nonnull final Destination destination) { + final var apiClient = ApiClient.create(destination).withObjectMapper(getDefaultObjectMapper()); + return new RptClient(new DefaultApi(apiClient)); + } + + /** + * Predict targets using SAP RPT model with structured data. * + * + *

200 - Successful response with predictive insights. + * + *

400 - Bad Request - Invalid input. + * + *

422 - Unprocessable Content - Invalid input. + * + *

500 - Internal Server Error. + * + * @param requestBody The prediction request + * @return prediction response from the RPT model + */ + @Nonnull + public PredictResponsePayload tabCompletion(@Nonnull final PredictRequestPayload requestBody) { + return api.predict(requestBody); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptModel.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptModel.java new file mode 100644 index 000000000..1afead85c --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptModel.java @@ -0,0 +1,32 @@ +package com.sap.ai.sdk.foundationmodels.rpt; + +import com.sap.ai.sdk.core.AiModel; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Represents an SAP RPT foundation model. + * + * @param name The name of the model. + * @param version The version of the model (optional). + * @since 1.16.0 + */ +public record RptModel(@Nonnull String name, @Nullable String version) implements AiModel { + + /** SAP RPT 1 Small model. */ + public static final RptModel SAP_RPT_1_SMALL = new RptModel("sap-rpt-1-small", null); + + /** SAP RPT 1 Large model. */ + public static final RptModel SAP_RPT_1_LARGE = new RptModel("sap-rpt-1-large", null); + + /** + * Create a new instance of RptModel with the provided version. + * + * @param version The version of the model. + * @return The new instance of RptModel. + */ + @Nonnull + public RptModel withVersion(@Nonnull final String version) { + return new RptModel(name, version); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/client/DefaultApi.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/client/DefaultApi.java new file mode 100644 index 000000000..d6878b280 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/client/DefaultApi.java @@ -0,0 +1,111 @@ +package com.sap.ai.sdk.foundationmodels.rpt.generated.client; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictRequestPayload; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictResponsePayload; +import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; +import com.sap.cloud.sdk.services.openapi.apache.ApiClient; +import com.sap.cloud.sdk.services.openapi.apache.BaseApi; +import com.sap.cloud.sdk.services.openapi.apache.Pair; +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; +import javax.annotation.Nonnull; + +/** + * SAP-RPT-1 Tabular AI in version 0.1.0. + * + *

A REST API for in-context learning with the SAP-RPT-1 model. + */ +public class DefaultApi extends BaseApi { + + /** Instantiates this API class to invoke operations on the SAP-RPT-1 Tabular AI */ + public DefaultApi() {} + + /** + * Instantiates this API class to invoke operations on the SAP-RPT-1 Tabular AI. + * + * @param httpDestination The destination that API should be used with + */ + public DefaultApi(@Nonnull final Destination httpDestination) { + super(httpDestination); + } + + /** + * Instantiates this API class to invoke operations on the SAP-RPT-1 Tabular AI based on a given + * {@link ApiClient}. + * + * @param apiClient ApiClient to invoke the API on + */ + public DefaultApi(@Nonnull final ApiClient apiClient) { + super(apiClient); + } + + /** + * Make in-context predictions for specified target columns based on provided table data JSON + * (optionally gzip-compressed). + * + *

Make in-context predictions for specified target columns. Either \"rows\" or + * \"columns\" must be provided and must contain both context and query rows. You can + * optionally send gzip-compressed JSON payloads and set a \"Content-Encoding: gzip\" + * header. + * + *

200 - Successful Prediction + * + *

400 - Bad Request - Invalid input data + * + *

413 - Payload Too Large + * + *

422 - Validation Error + * + *

500 - Internal Server Error + * + * @param predictRequestPayload The value for the parameter predictRequestPayload + * @return PredictResponsePayload + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public PredictResponsePayload predict(@Nonnull final PredictRequestPayload predictRequestPayload) + throws OpenApiRequestException { + + // verify the required parameter 'predictRequestPayload' is set + if (predictRequestPayload == null) { + throw new OpenApiRequestException( + "Missing the required parameter 'predictRequestPayload' when calling predict") + .statusCode(400); + } + + // create path and map variables + final String localVarPath = "/predict"; + + final StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + final List localVarQueryParams = new ArrayList(); + final List localVarCollectionQueryParams = new ArrayList(); + final Map localVarHeaderParams = new HashMap(); + final Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = ApiClient.selectHeaderContentType(localVarContentTypes); + + final TypeReference localVarReturnType = + new TypeReference() {}; + + return apiClient.invokeAPI( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + predictRequestPayload, + localVarHeaderParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarReturnType); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/BodyPredictParquet.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/BodyPredictParquet.java new file mode 100644 index 000000000..c3dd7b890 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/BodyPredictParquet.java @@ -0,0 +1,308 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.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.io.File; +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; + +/** BodyPredictParquet */ +// CHECKSTYLE:OFF +public class BodyPredictParquet +// CHECKSTYLE:ON +{ + @JsonProperty("file") + private File _file; + + @JsonProperty("prediction_config") + private String predictionConfig; + + @JsonProperty("index_column") + private String indexColumn; + + @JsonProperty("parse_data_types") + private Boolean parseDataTypes = true; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the _file of this {@link BodyPredictParquet} instance and return the same instance. + * + * @param _file Parquet file containing the data + * @return The same instance of this {@link BodyPredictParquet} class + */ + @Nonnull + public BodyPredictParquet _file(@Nonnull final File _file) { + this._file = _file; + return this; + } + + /** + * Parquet file containing the data + * + * @return _file The _file of this {@link BodyPredictParquet} instance. + */ + @Nonnull + public File getFile() { + return _file; + } + + /** + * Set the _file of this {@link BodyPredictParquet} instance. + * + * @param _file Parquet file containing the data + */ + public void setFile(@Nonnull final File _file) { + this._file = _file; + } + + /** + * Set the predictionConfig of this {@link BodyPredictParquet} instance and return the same + * instance. + * + * @param predictionConfig JSON string for prediction_config + * @return The same instance of this {@link BodyPredictParquet} class + */ + @Nonnull + public BodyPredictParquet predictionConfig(@Nonnull final String predictionConfig) { + this.predictionConfig = predictionConfig; + return this; + } + + /** + * JSON string for prediction_config + * + * @return predictionConfig The predictionConfig of this {@link BodyPredictParquet} instance. + */ + @Nonnull + public String getPredictionConfig() { + return predictionConfig; + } + + /** + * Set the predictionConfig of this {@link BodyPredictParquet} instance. + * + * @param predictionConfig JSON string for prediction_config + */ + public void setPredictionConfig(@Nonnull final String predictionConfig) { + this.predictionConfig = predictionConfig; + } + + /** + * Set the indexColumn of this {@link BodyPredictParquet} instance and return the same instance. + * + * @param indexColumn Optional index column name + * @return The same instance of this {@link BodyPredictParquet} class + */ + @Nonnull + public BodyPredictParquet indexColumn(@Nullable final String indexColumn) { + this.indexColumn = indexColumn; + return this; + } + + /** + * Optional index column name + * + * @return indexColumn The indexColumn of this {@link BodyPredictParquet} instance. + */ + @Nonnull + public String getIndexColumn() { + return indexColumn; + } + + /** + * Set the indexColumn of this {@link BodyPredictParquet} instance. + * + * @param indexColumn Optional index column name + */ + public void setIndexColumn(@Nullable final String indexColumn) { + this.indexColumn = indexColumn; + } + + /** + * Set the parseDataTypes of this {@link BodyPredictParquet} instance and return the same + * instance. + * + * @param parseDataTypes Whether to parse data types + * @return The same instance of this {@link BodyPredictParquet} class + */ + @Nonnull + public BodyPredictParquet parseDataTypes(@Nullable final Boolean parseDataTypes) { + this.parseDataTypes = parseDataTypes; + return this; + } + + /** + * Whether to parse data types + * + * @return parseDataTypes The parseDataTypes of this {@link BodyPredictParquet} instance. + */ + @Nonnull + public Boolean isParseDataTypes() { + return parseDataTypes; + } + + /** + * Set the parseDataTypes of this {@link BodyPredictParquet} instance. + * + * @param parseDataTypes Whether to parse data types + */ + public void setParseDataTypes(@Nullable final Boolean parseDataTypes) { + this.parseDataTypes = parseDataTypes; + } + + /** + * Get the names of the unrecognizable properties of the {@link BodyPredictParquet}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link BodyPredictParquet} 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("BodyPredictParquet has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link BodyPredictParquet} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (_file != null) declaredFields.put("_file", _file); + if (predictionConfig != null) declaredFields.put("predictionConfig", predictionConfig); + if (indexColumn != null) declaredFields.put("indexColumn", indexColumn); + if (parseDataTypes != null) declaredFields.put("parseDataTypes", parseDataTypes); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link BodyPredictParquet} 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 BodyPredictParquet bodyPredictParquet = (BodyPredictParquet) o; + return Objects.equals(this.cloudSdkCustomFields, bodyPredictParquet.cloudSdkCustomFields) + && Objects.equals(this._file, bodyPredictParquet._file) + && Objects.equals(this.predictionConfig, bodyPredictParquet.predictionConfig) + && Objects.equals(this.indexColumn, bodyPredictParquet.indexColumn) + && Objects.equals(this.parseDataTypes, bodyPredictParquet.parseDataTypes); + } + + @Override + public int hashCode() { + return Objects.hash(_file, predictionConfig, indexColumn, parseDataTypes, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class BodyPredictParquet {\n"); + sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); + sb.append(" predictionConfig: ").append(toIndentedString(predictionConfig)).append("\n"); + sb.append(" indexColumn: ").append(toIndentedString(indexColumn)).append("\n"); + sb.append(" parseDataTypes: ").append(toIndentedString(parseDataTypes)).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 BodyPredictParquet} + * instance with all required arguments. + */ + public static Builder create() { + return (_file) -> + (predictionConfig) -> + new BodyPredictParquet()._file(_file).predictionConfig(predictionConfig); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the _file of this {@link BodyPredictParquet} instance. + * + * @param _file Parquet file containing the data + * @return The BodyPredictParquet builder. + */ + Builder1 _file(@Nonnull final File _file); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the predictionConfig of this {@link BodyPredictParquet} instance. + * + * @param predictionConfig JSON string for prediction_config + * @return The BodyPredictParquet instance. + */ + BodyPredictParquet predictionConfig(@Nonnull final String predictionConfig); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/ColumnType.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/ColumnType.java new file mode 100644 index 000000000..1afaa9b08 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/ColumnType.java @@ -0,0 +1,66 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.annotation.Nonnull; + +/** Gets or Sets ColumnType */ +public enum ColumnType { + STRING("string"), + + NUMERIC("numeric"), + + DATE("date"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private final String value; + + ColumnType(String value) { + this.value = value; + } + + /** + * @return The enum value. + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * @return The String representation of the enum value. + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Converts the given value to its enum representation. + * + * @param value The input value. + * @return The enum representation of the given value. + */ + @JsonCreator + public static ColumnType fromValue(@Nonnull final String value) { + for (final ColumnType b : ColumnType.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictRequestPayload.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictRequestPayload.java new file mode 100644 index 000000000..65ca2bc75 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictRequestPayload.java @@ -0,0 +1,443 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.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.HashMap; +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; + +/** + * Users need to specify a list of rows, which contains both the context rows and the rows for which + * to predict a label, and a mapping of column names to placeholder values. The model will predict + * the value for any column specified in `predict_columns` for all rows that have the + * placeholder value in that column. + */ +// CHECKSTYLE:OFF +public class PredictRequestPayload +// CHECKSTYLE:ON +{ + @JsonProperty("prediction_config") + private PredictionConfig predictionConfig; + + @JsonProperty("rows") + private List> rows = new ArrayList<>(); + + @JsonProperty("columns") + private Map> columns; + + @JsonProperty("index_column") + private String indexColumn; + + @JsonProperty("parse_data_types") + private Boolean parseDataTypes = true; + + @JsonProperty("data_schema") + private Map dataSchema; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the predictionConfig of this {@link PredictRequestPayload} instance and return the same + * instance. + * + * @param predictionConfig Configuration of target columns and placeholder value. + * @return The same instance of this {@link PredictRequestPayload} class + */ + @Nonnull + public PredictRequestPayload predictionConfig(@Nonnull final PredictionConfig predictionConfig) { + this.predictionConfig = predictionConfig; + return this; + } + + /** + * Configuration of target columns and placeholder value. + * + * @return predictionConfig The predictionConfig of this {@link PredictRequestPayload} instance. + */ + @Nonnull + public PredictionConfig getPredictionConfig() { + return predictionConfig; + } + + /** + * Set the predictionConfig of this {@link PredictRequestPayload} instance. + * + * @param predictionConfig Configuration of target columns and placeholder value. + */ + public void setPredictionConfig(@Nonnull final PredictionConfig predictionConfig) { + this.predictionConfig = predictionConfig; + } + + /** + * Set the rows of this {@link PredictRequestPayload} instance and return the same instance. + * + * @param rows Table rows, i.e. list of objects where each object is a mapping of column names to + * values. Either \"rows\" or \"columns\" must be provided. + * @return The same instance of this {@link PredictRequestPayload} class + */ + @Nonnull + public PredictRequestPayload rows(@Nullable final List> rows) { + this.rows = rows; + return this; + } + + /** + * Add one rows instance to this {@link PredictRequestPayload}. + * + * @param rowsItem The rows that should be added + * @return The same instance of type {@link PredictRequestPayload} + */ + @Nonnull + public PredictRequestPayload addRowsItem(@Nonnull final Map rowsItem) { + if (this.rows == null) { + this.rows = new ArrayList<>(); + } + this.rows.add(rowsItem); + return this; + } + + /** + * Table rows, i.e. list of objects where each object is a mapping of column names to values. + * Either \"rows\" or \"columns\" must be provided. + * + * @return rows The rows of this {@link PredictRequestPayload} instance. + */ + @Nonnull + public List> getRows() { + return rows; + } + + /** + * Set the rows of this {@link PredictRequestPayload} instance. + * + * @param rows Table rows, i.e. list of objects where each object is a mapping of column names to + * values. Either \"rows\" or \"columns\" must be provided. + */ + public void setRows(@Nullable final List> rows) { + this.rows = rows; + } + + /** + * Set the columns of this {@link PredictRequestPayload} instance and return the same instance. + * + * @param columns The columns of this {@link PredictRequestPayload} + * @return The same instance of this {@link PredictRequestPayload} class + */ + @Nonnull + public PredictRequestPayload columns(@Nullable final Map> columns) { + this.columns = columns; + return this; + } + + /** + * Put one columns instance to this {@link PredictRequestPayload} instance. + * + * @param key The String key of this columns instance + * @param columnsItem The columns that should be added under the given key + * @return The same instance of type {@link PredictRequestPayload} + */ + @Nonnull + public PredictRequestPayload putcolumnsItem( + @Nonnull final String key, @Nonnull final List columnsItem) { + if (this.columns == null) { + this.columns = new HashMap<>(); + } + this.columns.put(key, columnsItem); + return this; + } + + /** + * Get columns + * + * @return columns The columns of this {@link PredictRequestPayload} instance. + */ + @Nullable + public Map> getColumns() { + return columns; + } + + /** + * Set the columns of this {@link PredictRequestPayload} instance. + * + * @param columns The columns of this {@link PredictRequestPayload} + */ + public void setColumns(@Nullable final Map> columns) { + this.columns = columns; + } + + /** + * Set the indexColumn of this {@link PredictRequestPayload} instance and return the same + * instance. + * + * @param indexColumn The indexColumn of this {@link PredictRequestPayload} + * @return The same instance of this {@link PredictRequestPayload} class + */ + @Nonnull + public PredictRequestPayload indexColumn(@Nullable final String indexColumn) { + this.indexColumn = indexColumn; + return this; + } + + /** + * Get indexColumn + * + * @return indexColumn The indexColumn of this {@link PredictRequestPayload} instance. + */ + @Nullable + public String getIndexColumn() { + return indexColumn; + } + + /** + * Set the indexColumn of this {@link PredictRequestPayload} instance. + * + * @param indexColumn The indexColumn of this {@link PredictRequestPayload} + */ + public void setIndexColumn(@Nullable final String indexColumn) { + this.indexColumn = indexColumn; + } + + /** + * Set the parseDataTypes of this {@link PredictRequestPayload} instance and return the same + * instance. + * + * @param parseDataTypes Whether to parse the data types of the columns. If set to True, numeric + * columns will be parsed to float or integer and dates in ISO format YYYY-MM-DD will be + * parsed. + * @return The same instance of this {@link PredictRequestPayload} class + */ + @Nonnull + public PredictRequestPayload parseDataTypes(@Nullable final Boolean parseDataTypes) { + this.parseDataTypes = parseDataTypes; + return this; + } + + /** + * Whether to parse the data types of the columns. If set to True, numeric columns will be parsed + * to float or integer and dates in ISO format YYYY-MM-DD will be parsed. + * + * @return parseDataTypes The parseDataTypes of this {@link PredictRequestPayload} instance. + */ + @Nonnull + public Boolean isParseDataTypes() { + return parseDataTypes; + } + + /** + * Set the parseDataTypes of this {@link PredictRequestPayload} instance. + * + * @param parseDataTypes Whether to parse the data types of the columns. If set to True, numeric + * columns will be parsed to float or integer and dates in ISO format YYYY-MM-DD will be + * parsed. + */ + public void setParseDataTypes(@Nullable final Boolean parseDataTypes) { + this.parseDataTypes = parseDataTypes; + } + + /** + * Set the dataSchema of this {@link PredictRequestPayload} instance and return the same instance. + * + * @param dataSchema The dataSchema of this {@link PredictRequestPayload} + * @return The same instance of this {@link PredictRequestPayload} class + */ + @Nonnull + public PredictRequestPayload dataSchema( + @Nullable final Map dataSchema) { + this.dataSchema = dataSchema; + return this; + } + + /** + * Put one dataSchema instance to this {@link PredictRequestPayload} instance. + * + * @param key The String key of this dataSchema instance + * @param dataSchemaItem The dataSchema that should be added under the given key + * @return The same instance of type {@link PredictRequestPayload} + */ + @Nonnull + public PredictRequestPayload putdataSchemaItem( + @Nonnull final String key, @Nonnull final SchemaFieldConfig dataSchemaItem) { + if (this.dataSchema == null) { + this.dataSchema = new HashMap<>(); + } + this.dataSchema.put(key, dataSchemaItem); + return this; + } + + /** + * Get dataSchema + * + * @return dataSchema The dataSchema of this {@link PredictRequestPayload} instance. + */ + @Nullable + public Map getDataSchema() { + return dataSchema; + } + + /** + * Set the dataSchema of this {@link PredictRequestPayload} instance. + * + * @param dataSchema The dataSchema of this {@link PredictRequestPayload} + */ + public void setDataSchema(@Nullable final Map dataSchema) { + this.dataSchema = dataSchema; + } + + /** + * Get the names of the unrecognizable properties of the {@link PredictRequestPayload}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link PredictRequestPayload} 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( + "PredictRequestPayload has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link PredictRequestPayload} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (predictionConfig != null) declaredFields.put("predictionConfig", predictionConfig); + if (rows != null) declaredFields.put("rows", rows); + if (columns != null) declaredFields.put("columns", columns); + if (indexColumn != null) declaredFields.put("indexColumn", indexColumn); + if (parseDataTypes != null) declaredFields.put("parseDataTypes", parseDataTypes); + if (dataSchema != null) declaredFields.put("dataSchema", dataSchema); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link PredictRequestPayload} 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 PredictRequestPayload predictRequestPayload = (PredictRequestPayload) o; + return Objects.equals(this.cloudSdkCustomFields, predictRequestPayload.cloudSdkCustomFields) + && Objects.equals(this.predictionConfig, predictRequestPayload.predictionConfig) + && Objects.equals(this.rows, predictRequestPayload.rows) + && Objects.equals(this.columns, predictRequestPayload.columns) + && Objects.equals(this.indexColumn, predictRequestPayload.indexColumn) + && Objects.equals(this.parseDataTypes, predictRequestPayload.parseDataTypes) + && Objects.equals(this.dataSchema, predictRequestPayload.dataSchema); + } + + @Override + public int hashCode() { + return Objects.hash( + predictionConfig, + rows, + columns, + indexColumn, + parseDataTypes, + dataSchema, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PredictRequestPayload {\n"); + sb.append(" predictionConfig: ").append(toIndentedString(predictionConfig)).append("\n"); + sb.append(" rows: ").append(toIndentedString(rows)).append("\n"); + sb.append(" columns: ").append(toIndentedString(columns)).append("\n"); + sb.append(" indexColumn: ").append(toIndentedString(indexColumn)).append("\n"); + sb.append(" parseDataTypes: ").append(toIndentedString(parseDataTypes)).append("\n"); + sb.append(" dataSchema: ").append(toIndentedString(dataSchema)).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 PredictRequestPayload} + * instance with all required arguments. + */ + public static Builder create() { + return (predictionConfig) -> new PredictRequestPayload().predictionConfig(predictionConfig); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the predictionConfig of this {@link PredictRequestPayload} instance. + * + * @param predictionConfig Configuration of target columns and placeholder value. + * @return The PredictRequestPayload instance. + */ + PredictRequestPayload predictionConfig(@Nonnull final PredictionConfig predictionConfig); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponseMetadata.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponseMetadata.java new file mode 100644 index 000000000..9e0c27fb2 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponseMetadata.java @@ -0,0 +1,337 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.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; + +/** Metadata about the prediction request. */ +// CHECKSTYLE:OFF +public class PredictResponseMetadata +// CHECKSTYLE:ON +{ + @JsonProperty("num_columns") + private Integer numColumns; + + @JsonProperty("num_rows") + private Integer numRows; + + @JsonProperty("num_predictions") + private Integer numPredictions; + + @JsonProperty("num_query_rows") + private Integer numQueryRows; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the numColumns of this {@link PredictResponseMetadata} instance and return the same + * instance. + * + * @param numColumns Number of columns in the input data. + * @return The same instance of this {@link PredictResponseMetadata} class + */ + @Nonnull + public PredictResponseMetadata numColumns(@Nonnull final Integer numColumns) { + this.numColumns = numColumns; + return this; + } + + /** + * Number of columns in the input data. + * + * @return numColumns The numColumns of this {@link PredictResponseMetadata} instance. + */ + @Nonnull + public Integer getNumColumns() { + return numColumns; + } + + /** + * Set the numColumns of this {@link PredictResponseMetadata} instance. + * + * @param numColumns Number of columns in the input data. + */ + public void setNumColumns(@Nonnull final Integer numColumns) { + this.numColumns = numColumns; + } + + /** + * Set the numRows of this {@link PredictResponseMetadata} instance and return the same instance. + * + * @param numRows Number of rows in the input data. + * @return The same instance of this {@link PredictResponseMetadata} class + */ + @Nonnull + public PredictResponseMetadata numRows(@Nonnull final Integer numRows) { + this.numRows = numRows; + return this; + } + + /** + * Number of rows in the input data. + * + * @return numRows The numRows of this {@link PredictResponseMetadata} instance. + */ + @Nonnull + public Integer getNumRows() { + return numRows; + } + + /** + * Set the numRows of this {@link PredictResponseMetadata} instance. + * + * @param numRows Number of rows in the input data. + */ + public void setNumRows(@Nonnull final Integer numRows) { + this.numRows = numRows; + } + + /** + * Set the numPredictions of this {@link PredictResponseMetadata} instance and return the same + * instance. + * + * @param numPredictions Number of table cells containing the specified placeholder value. + * @return The same instance of this {@link PredictResponseMetadata} class + */ + @Nonnull + public PredictResponseMetadata numPredictions(@Nonnull final Integer numPredictions) { + this.numPredictions = numPredictions; + return this; + } + + /** + * Number of table cells containing the specified placeholder value. + * + * @return numPredictions The numPredictions of this {@link PredictResponseMetadata} instance. + */ + @Nonnull + public Integer getNumPredictions() { + return numPredictions; + } + + /** + * Set the numPredictions of this {@link PredictResponseMetadata} instance. + * + * @param numPredictions Number of table cells containing the specified placeholder value. + */ + public void setNumPredictions(@Nonnull final Integer numPredictions) { + this.numPredictions = numPredictions; + } + + /** + * Set the numQueryRows of this {@link PredictResponseMetadata} instance and return the same + * instance. + * + * @param numQueryRows Number of rows for which a prediction was made. + * @return The same instance of this {@link PredictResponseMetadata} class + */ + @Nonnull + public PredictResponseMetadata numQueryRows(@Nonnull final Integer numQueryRows) { + this.numQueryRows = numQueryRows; + return this; + } + + /** + * Number of rows for which a prediction was made. + * + * @return numQueryRows The numQueryRows of this {@link PredictResponseMetadata} instance. + */ + @Nonnull + public Integer getNumQueryRows() { + return numQueryRows; + } + + /** + * Set the numQueryRows of this {@link PredictResponseMetadata} instance. + * + * @param numQueryRows Number of rows for which a prediction was made. + */ + public void setNumQueryRows(@Nonnull final Integer numQueryRows) { + this.numQueryRows = numQueryRows; + } + + /** + * Get the names of the unrecognizable properties of the {@link PredictResponseMetadata}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link PredictResponseMetadata} 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( + "PredictResponseMetadata has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link PredictResponseMetadata} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (numColumns != null) declaredFields.put("numColumns", numColumns); + if (numRows != null) declaredFields.put("numRows", numRows); + if (numPredictions != null) declaredFields.put("numPredictions", numPredictions); + if (numQueryRows != null) declaredFields.put("numQueryRows", numQueryRows); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link PredictResponseMetadata} 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 PredictResponseMetadata predictResponseMetadata = (PredictResponseMetadata) o; + return Objects.equals(this.cloudSdkCustomFields, predictResponseMetadata.cloudSdkCustomFields) + && Objects.equals(this.numColumns, predictResponseMetadata.numColumns) + && Objects.equals(this.numRows, predictResponseMetadata.numRows) + && Objects.equals(this.numPredictions, predictResponseMetadata.numPredictions) + && Objects.equals(this.numQueryRows, predictResponseMetadata.numQueryRows); + } + + @Override + public int hashCode() { + return Objects.hash(numColumns, numRows, numPredictions, numQueryRows, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PredictResponseMetadata {\n"); + sb.append(" numColumns: ").append(toIndentedString(numColumns)).append("\n"); + sb.append(" numRows: ").append(toIndentedString(numRows)).append("\n"); + sb.append(" numPredictions: ").append(toIndentedString(numPredictions)).append("\n"); + sb.append(" numQueryRows: ").append(toIndentedString(numQueryRows)).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 + * PredictResponseMetadata} instance with all required arguments. + */ + public static Builder create() { + return (numColumns) -> + (numRows) -> + (numPredictions) -> + (numQueryRows) -> + new PredictResponseMetadata() + .numColumns(numColumns) + .numRows(numRows) + .numPredictions(numPredictions) + .numQueryRows(numQueryRows); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the numColumns of this {@link PredictResponseMetadata} instance. + * + * @param numColumns Number of columns in the input data. + * @return The PredictResponseMetadata builder. + */ + Builder1 numColumns(@Nonnull final Integer numColumns); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the numRows of this {@link PredictResponseMetadata} instance. + * + * @param numRows Number of rows in the input data. + * @return The PredictResponseMetadata builder. + */ + Builder2 numRows(@Nonnull final Integer numRows); + } + + /** Builder helper class. */ + public interface Builder2 { + /** + * Set the numPredictions of this {@link PredictResponseMetadata} instance. + * + * @param numPredictions Number of table cells containing the specified placeholder value. + * @return The PredictResponseMetadata builder. + */ + Builder3 numPredictions(@Nonnull final Integer numPredictions); + } + + /** Builder helper class. */ + public interface Builder3 { + /** + * Set the numQueryRows of this {@link PredictResponseMetadata} instance. + * + * @param numQueryRows Number of rows for which a prediction was made. + * @return The PredictResponseMetadata instance. + */ + PredictResponseMetadata numQueryRows(@Nonnull final Integer numQueryRows); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponsePayload.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponsePayload.java new file mode 100644 index 000000000..631e53f9e --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponsePayload.java @@ -0,0 +1,367 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Response payload for prediction requests. Contains a list of prediction results. */ +// CHECKSTYLE:OFF +public class PredictResponsePayload +// CHECKSTYLE:ON +{ + @JsonProperty("id") + private String id; + + @JsonProperty("status") + private PredictResponseStatus status; + + @JsonProperty("predictions") + private List> predictions = new ArrayList<>(); + + @JsonProperty("metadata") + private PredictResponseMetadata metadata; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the id of this {@link PredictResponsePayload} instance and return the same instance. + * + * @param id Unique ID for the request. + * @return The same instance of this {@link PredictResponsePayload} class + */ + @Nonnull + public PredictResponsePayload id(@Nonnull final String id) { + this.id = id; + return this; + } + + /** + * Unique ID for the request. + * + * @return id The id of this {@link PredictResponsePayload} instance. + */ + @Nonnull + public String getId() { + return id; + } + + /** + * Set the id of this {@link PredictResponsePayload} instance. + * + * @param id Unique ID for the request. + */ + public void setId(@Nonnull final String id) { + this.id = id; + } + + /** + * Set the status of this {@link PredictResponsePayload} instance and return the same instance. + * + * @param status Status message that can indicate warnings (e.g. about suboptimal data). + * @return The same instance of this {@link PredictResponsePayload} class + */ + @Nonnull + public PredictResponsePayload status(@Nonnull final PredictResponseStatus status) { + this.status = status; + return this; + } + + /** + * Status message that can indicate warnings (e.g. about suboptimal data). + * + * @return status The status of this {@link PredictResponsePayload} instance. + */ + @Nonnull + public PredictResponseStatus getStatus() { + return status; + } + + /** + * Set the status of this {@link PredictResponsePayload} instance. + * + * @param status Status message that can indicate warnings (e.g. about suboptimal data). + */ + public void setStatus(@Nonnull final PredictResponseStatus status) { + this.status = status; + } + + /** + * Set the predictions of this {@link PredictResponsePayload} instance and return the same + * instance. + * + * @param predictions Mapping of column names to their list of prediction results or index column. + * @return The same instance of this {@link PredictResponsePayload} class + */ + @Nonnull + public PredictResponsePayload predictions( + @Nonnull final List> predictions) { + this.predictions = predictions; + return this; + } + + /** + * Add one predictions instance to this {@link PredictResponsePayload}. + * + * @param predictionsItem The predictions that should be added + * @return The same instance of type {@link PredictResponsePayload} + */ + @Nonnull + public PredictResponsePayload addPredictionsItem( + @Nonnull final Map predictionsItem) { + if (this.predictions == null) { + this.predictions = new ArrayList<>(); + } + this.predictions.add(predictionsItem); + return this; + } + + /** + * Mapping of column names to their list of prediction results or index column. + * + * @return predictions The predictions of this {@link PredictResponsePayload} instance. + */ + @Nonnull + public List> getPredictions() { + return predictions; + } + + /** + * Set the predictions of this {@link PredictResponsePayload} instance. + * + * @param predictions Mapping of column names to their list of prediction results or index column. + */ + public void setPredictions(@Nonnull final List> predictions) { + this.predictions = predictions; + } + + /** + * Set the metadata of this {@link PredictResponsePayload} instance and return the same instance. + * + * @param metadata The metadata of this {@link PredictResponsePayload} + * @return The same instance of this {@link PredictResponsePayload} class + */ + @Nonnull + public PredictResponsePayload metadata(@Nonnull final PredictResponseMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get metadata + * + * @return metadata The metadata of this {@link PredictResponsePayload} instance. + */ + @Nonnull + public PredictResponseMetadata getMetadata() { + return metadata; + } + + /** + * Set the metadata of this {@link PredictResponsePayload} instance. + * + * @param metadata The metadata of this {@link PredictResponsePayload} + */ + public void setMetadata(@Nonnull final PredictResponseMetadata metadata) { + this.metadata = metadata; + } + + /** + * Get the names of the unrecognizable properties of the {@link PredictResponsePayload}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link PredictResponsePayload} 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( + "PredictResponsePayload has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link PredictResponsePayload} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (id != null) declaredFields.put("id", id); + if (status != null) declaredFields.put("status", status); + if (predictions != null) declaredFields.put("predictions", predictions); + if (metadata != null) declaredFields.put("metadata", metadata); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link PredictResponsePayload} 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 PredictResponsePayload predictResponsePayload = (PredictResponsePayload) o; + return Objects.equals(this.cloudSdkCustomFields, predictResponsePayload.cloudSdkCustomFields) + && Objects.equals(this.id, predictResponsePayload.id) + && Objects.equals(this.status, predictResponsePayload.status) + && Objects.equals(this.predictions, predictResponsePayload.predictions) + && Objects.equals(this.metadata, predictResponsePayload.metadata); + } + + @Override + public int hashCode() { + return Objects.hash(id, status, predictions, metadata, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PredictResponsePayload {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" predictions: ").append(toIndentedString(predictions)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).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 PredictResponsePayload} + * instance with all required arguments. + */ + public static Builder create() { + return (id) -> + (status) -> + (predictions) -> + (metadata) -> + new PredictResponsePayload() + .id(id) + .status(status) + .predictions(predictions) + .metadata(metadata); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the id of this {@link PredictResponsePayload} instance. + * + * @param id Unique ID for the request. + * @return The PredictResponsePayload builder. + */ + Builder1 id(@Nonnull final String id); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the status of this {@link PredictResponsePayload} instance. + * + * @param status Status message that can indicate warnings (e.g. about suboptimal data). + * @return The PredictResponsePayload builder. + */ + Builder2 status(@Nonnull final PredictResponseStatus status); + } + + /** Builder helper class. */ + public interface Builder2 { + /** + * Set the predictions of this {@link PredictResponsePayload} instance. + * + * @param predictions Mapping of column names to their list of prediction results or index + * column. + * @return The PredictResponsePayload builder. + */ + Builder3 predictions(@Nonnull final List> predictions); + + /** + * Set the predictions of this {@link PredictResponsePayload} instance. + * + * @param predictions Mapping of column names to their list of prediction results or index + * column. + * @return The PredictResponsePayload builder. + */ + default Builder3 predictions(@Nonnull final Map... predictions) { + return predictions(Arrays.asList(predictions)); + } + } + + /** Builder helper class. */ + public interface Builder3 { + /** + * Set the metadata of this {@link PredictResponsePayload} instance. + * + * @param metadata The metadata of this {@link PredictResponsePayload} + * @return The PredictResponsePayload instance. + */ + PredictResponsePayload metadata(@Nonnull final PredictResponseMetadata metadata); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponseStatus.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponseStatus.java new file mode 100644 index 000000000..5a0f5a46a --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictResponseStatus.java @@ -0,0 +1,233 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.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; + +/** Output status for prediction requests. */ +// CHECKSTYLE:OFF +public class PredictResponseStatus +// CHECKSTYLE:ON +{ + @JsonProperty("code") + private Integer code; + + @JsonProperty("message") + private String message; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the code of this {@link PredictResponseStatus} instance and return the same instance. + * + * @param code Status code (zero means success, other status codes indicate warnings) + * @return The same instance of this {@link PredictResponseStatus} class + */ + @Nonnull + public PredictResponseStatus code(@Nonnull final Integer code) { + this.code = code; + return this; + } + + /** + * Status code (zero means success, other status codes indicate warnings) + * + * @return code The code of this {@link PredictResponseStatus} instance. + */ + @Nonnull + public Integer getCode() { + return code; + } + + /** + * Set the code of this {@link PredictResponseStatus} instance. + * + * @param code Status code (zero means success, other status codes indicate warnings) + */ + public void setCode(@Nonnull final Integer code) { + this.code = code; + } + + /** + * Set the message of this {@link PredictResponseStatus} instance and return the same instance. + * + * @param message Status message, either \"ok\" or contains a warning / more + * information. + * @return The same instance of this {@link PredictResponseStatus} class + */ + @Nonnull + public PredictResponseStatus message(@Nonnull final String message) { + this.message = message; + return this; + } + + /** + * Status message, either \"ok\" or contains a warning / more information. + * + * @return message The message of this {@link PredictResponseStatus} instance. + */ + @Nonnull + public String getMessage() { + return message; + } + + /** + * Set the message of this {@link PredictResponseStatus} instance. + * + * @param message Status message, either \"ok\" or contains a warning / more + * information. + */ + public void setMessage(@Nonnull final String message) { + this.message = message; + } + + /** + * Get the names of the unrecognizable properties of the {@link PredictResponseStatus}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link PredictResponseStatus} 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( + "PredictResponseStatus has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link PredictResponseStatus} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (code != null) declaredFields.put("code", code); + if (message != null) declaredFields.put("message", message); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link PredictResponseStatus} 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 PredictResponseStatus predictResponseStatus = (PredictResponseStatus) o; + return Objects.equals(this.cloudSdkCustomFields, predictResponseStatus.cloudSdkCustomFields) + && Objects.equals(this.code, predictResponseStatus.code) + && Objects.equals(this.message, predictResponseStatus.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PredictResponseStatus {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 PredictResponseStatus} + * instance with all required arguments. + */ + public static Builder create() { + return (code) -> (message) -> new PredictResponseStatus().code(code).message(message); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the code of this {@link PredictResponseStatus} instance. + * + * @param code Status code (zero means success, other status codes indicate warnings) + * @return The PredictResponseStatus builder. + */ + Builder1 code(@Nonnull final Integer code); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the message of this {@link PredictResponseStatus} instance. + * + * @param message Status message, either \"ok\" or contains a warning / more + * information. + * @return The PredictResponseStatus instance. + */ + PredictResponseStatus message(@Nonnull final String message); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/Prediction.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/Prediction.java new file mode 100644 index 000000000..17a13e67d --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/Prediction.java @@ -0,0 +1,50 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.model; + +import java.math.BigDecimal; +import javax.annotation.Nonnull; + +/** The predicted value for the column. */ +public interface Prediction { + /** Helper class to create {@code String } that implements {@link Prediction}. */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) + implements Prediction {} + + /** + * Creator to enable deserialization of {@code 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 {@code BigDecimal } that implements {@link Prediction}. */ + record InnerBigDecimal(@com.fasterxml.jackson.annotation.JsonValue @Nonnull BigDecimal value) + implements Prediction {} + + /** + * Creator to enable deserialization of {@code BigDecimal }. + * + * @param val the value to use + * @return a new instance of {@link InnerBigDecimal}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerBigDecimal create(@Nonnull final BigDecimal val) { + return new InnerBigDecimal(val); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionConfig.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionConfig.java new file mode 100644 index 000000000..dba99d910 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionConfig.java @@ -0,0 +1,210 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Configuration of the prediction model. */ +// CHECKSTYLE:OFF +public class PredictionConfig +// CHECKSTYLE:ON +{ + @JsonProperty("target_columns") + private List targetColumns = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the targetColumns of this {@link PredictionConfig} instance and return the same instance. + * + * @param targetColumns The targetColumns of this {@link PredictionConfig} + * @return The same instance of this {@link PredictionConfig} class + */ + @Nonnull + public PredictionConfig targetColumns(@Nonnull final List targetColumns) { + this.targetColumns = targetColumns; + return this; + } + + /** + * Add one targetColumns instance to this {@link PredictionConfig}. + * + * @param targetColumnsItem The targetColumns that should be added + * @return The same instance of type {@link PredictionConfig} + */ + @Nonnull + public PredictionConfig addTargetColumnsItem( + @Nonnull final TargetColumnConfig targetColumnsItem) { + if (this.targetColumns == null) { + this.targetColumns = new ArrayList<>(); + } + this.targetColumns.add(targetColumnsItem); + return this; + } + + /** + * Get targetColumns + * + * @return targetColumns The targetColumns of this {@link PredictionConfig} instance. + */ + @Nonnull + public List getTargetColumns() { + return targetColumns; + } + + /** + * Set the targetColumns of this {@link PredictionConfig} instance. + * + * @param targetColumns The targetColumns of this {@link PredictionConfig} + */ + public void setTargetColumns(@Nonnull final List targetColumns) { + this.targetColumns = targetColumns; + } + + /** + * Get the names of the unrecognizable properties of the {@link PredictionConfig}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link PredictionConfig} 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("PredictionConfig has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link PredictionConfig} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (targetColumns != null) declaredFields.put("targetColumns", targetColumns); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link PredictionConfig} 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 PredictionConfig predictionConfig = (PredictionConfig) o; + return Objects.equals(this.cloudSdkCustomFields, predictionConfig.cloudSdkCustomFields) + && Objects.equals(this.targetColumns, predictionConfig.targetColumns); + } + + @Override + public int hashCode() { + return Objects.hash(targetColumns, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PredictionConfig {\n"); + sb.append(" targetColumns: ").append(toIndentedString(targetColumns)).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 PredictionConfig} + * instance with all required arguments. + */ + public static Builder create() { + return (targetColumns) -> new PredictionConfig().targetColumns(targetColumns); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the targetColumns of this {@link PredictionConfig} instance. + * + * @param targetColumns The targetColumns of this {@link PredictionConfig} + * @return The PredictionConfig instance. + */ + PredictionConfig targetColumns(@Nonnull final List targetColumns); + + /** + * Set the targetColumns of this {@link PredictionConfig} instance. + * + * @param targetColumns The targetColumns of this {@link PredictionConfig} + * @return The PredictionConfig instance. + */ + default PredictionConfig targetColumns(@Nonnull final TargetColumnConfig... targetColumns) { + return targetColumns(Arrays.asList(targetColumns)); + } + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionPlaceholder.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionPlaceholder.java new file mode 100644 index 000000000..a454b170a --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionPlaceholder.java @@ -0,0 +1,53 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.model; + +import java.math.BigDecimal; +import javax.annotation.Nonnull; + +/** + * The placeholder value in any column for which to predict a value. The model will predict a value + * for all table cells containing this value. + */ +public interface PredictionPlaceholder { + /** Helper class to create {@code String } that implements {@link PredictionPlaceholder}. */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) + implements PredictionPlaceholder {} + + /** + * Creator to enable deserialization of {@code 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 {@code BigDecimal } that implements {@link PredictionPlaceholder}. */ + record InnerBigDecimal(@com.fasterxml.jackson.annotation.JsonValue @Nonnull BigDecimal value) + implements PredictionPlaceholder {} + + /** + * Creator to enable deserialization of {@code BigDecimal }. + * + * @param val the value to use + * @return a new instance of {@link InnerBigDecimal}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerBigDecimal create(@Nonnull final BigDecimal val) { + return new InnerBigDecimal(val); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionResult.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionResult.java new file mode 100644 index 000000000..c768c4bb3 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionResult.java @@ -0,0 +1,219 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.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.math.BigDecimal; +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; + +/** A single prediction result for a single column in a single row. */ +// CHECKSTYLE:OFF +public class PredictionResult +// CHECKSTYLE:ON +{ + @JsonProperty("prediction") + private Prediction prediction; + + @JsonProperty("confidence") + private BigDecimal confidence; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the prediction of this {@link PredictionResult} instance and return the same instance. + * + * @param prediction The prediction of this {@link PredictionResult} + * @return The same instance of this {@link PredictionResult} class + */ + @Nonnull + public PredictionResult prediction(@Nonnull final Prediction prediction) { + this.prediction = prediction; + return this; + } + + /** + * Get prediction + * + * @return prediction The prediction of this {@link PredictionResult} instance. + */ + @Nonnull + public Prediction getPrediction() { + return prediction; + } + + /** + * Set the prediction of this {@link PredictionResult} instance. + * + * @param prediction The prediction of this {@link PredictionResult} + */ + public void setPrediction(@Nonnull final Prediction prediction) { + this.prediction = prediction; + } + + /** + * Set the confidence of this {@link PredictionResult} instance and return the same instance. + * + * @param confidence The confidence of this {@link PredictionResult} + * @return The same instance of this {@link PredictionResult} class + */ + @Nonnull + public PredictionResult confidence(@Nullable final BigDecimal confidence) { + this.confidence = confidence; + return this; + } + + /** + * Get confidence + * + * @return confidence The confidence of this {@link PredictionResult} instance. + */ + @Nullable + public BigDecimal getConfidence() { + return confidence; + } + + /** + * Set the confidence of this {@link PredictionResult} instance. + * + * @param confidence The confidence of this {@link PredictionResult} + */ + public void setConfidence(@Nullable final BigDecimal confidence) { + this.confidence = confidence; + } + + /** + * Get the names of the unrecognizable properties of the {@link PredictionResult}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link PredictionResult} 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("PredictionResult has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link PredictionResult} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (prediction != null) declaredFields.put("prediction", prediction); + if (confidence != null) declaredFields.put("confidence", confidence); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link PredictionResult} 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 PredictionResult predictionResult = (PredictionResult) o; + return Objects.equals(this.cloudSdkCustomFields, predictionResult.cloudSdkCustomFields) + && Objects.equals(this.prediction, predictionResult.prediction) + && Objects.equals(this.confidence, predictionResult.confidence); + } + + @Override + public int hashCode() { + return Objects.hash(prediction, confidence, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PredictionResult {\n"); + sb.append(" prediction: ").append(toIndentedString(prediction)).append("\n"); + sb.append(" confidence: ").append(toIndentedString(confidence)).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 PredictionResult} + * instance with all required arguments. + */ + public static Builder create() { + return (prediction) -> new PredictionResult().prediction(prediction); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the prediction of this {@link PredictionResult} instance. + * + * @param prediction The prediction of this {@link PredictionResult} + * @return The PredictionResult instance. + */ + PredictionResult prediction(@Nonnull final Prediction prediction); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionsInnerValue.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionsInnerValue.java new file mode 100644 index 000000000..d817ff9fb --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/PredictionsInnerValue.java @@ -0,0 +1,71 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.model; + +import java.util.List; +import javax.annotation.Nonnull; + +/** PredictionsInnerValue */ +public interface PredictionsInnerValue { + /** + * Helper class to create {@code List } that implements {@link + * PredictionsInnerValue}. + */ + record ListOfPredictionResults( + @com.fasterxml.jackson.annotation.JsonValue @Nonnull List values) + implements PredictionsInnerValue {} + + /** + * Creator to enable deserialization of {@code List }. + * + * @param val the value to use + * @return a new instance of {@link ListOfPredictionResults}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static ListOfPredictionResults createListOfPredictionResults( + @Nonnull final List val) { + return new ListOfPredictionResults(val); + } + + /** Helper class to create {@code String } that implements {@link PredictionsInnerValue}. */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) + implements PredictionsInnerValue {} + + /** + * Creator to enable deserialization of {@code 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 {@code Integer } that implements {@link PredictionsInnerValue}. */ + record InnerInteger(@com.fasterxml.jackson.annotation.JsonValue @Nonnull Integer value) + implements PredictionsInnerValue {} + + /** + * Creator to enable deserialization of {@code Integer }. + * + * @param val the value to use + * @return a new instance of {@link InnerInteger}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerInteger create(@Nonnull final Integer val) { + return new InnerInteger(val); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/RowsInnerValue.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/RowsInnerValue.java new file mode 100644 index 000000000..286c7006c --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/RowsInnerValue.java @@ -0,0 +1,66 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.model; + +import java.math.BigDecimal; +import javax.annotation.Nonnull; + +/** RowsInnerValue */ +public interface RowsInnerValue { + /** Helper class to create {@code String } that implements {@link RowsInnerValue}. */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) + implements RowsInnerValue {} + + /** + * Creator to enable deserialization of {@code 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 {@code Integer } that implements {@link RowsInnerValue}. */ + record InnerInteger(@com.fasterxml.jackson.annotation.JsonValue @Nonnull Integer value) + implements RowsInnerValue {} + + /** + * Creator to enable deserialization of {@code Integer }. + * + * @param val the value to use + * @return a new instance of {@link InnerInteger}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerInteger create(@Nonnull final Integer val) { + return new InnerInteger(val); + } + + /** Helper class to create {@code BigDecimal } that implements {@link RowsInnerValue}. */ + record InnerBigDecimal(@com.fasterxml.jackson.annotation.JsonValue @Nonnull BigDecimal value) + implements RowsInnerValue {} + + /** + * Creator to enable deserialization of {@code BigDecimal }. + * + * @param val the value to use + * @return a new instance of {@link InnerBigDecimal}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerBigDecimal create(@Nonnull final BigDecimal val) { + return new InnerBigDecimal(val); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/SchemaFieldConfig.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/SchemaFieldConfig.java new file mode 100644 index 000000000..9ca69ea61 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/SchemaFieldConfig.java @@ -0,0 +1,185 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.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; + +/** Configuration for a single field in the input data schema. */ +// CHECKSTYLE:OFF +public class SchemaFieldConfig +// CHECKSTYLE:ON +{ + @JsonProperty("dtype") + private ColumnType dtype; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the dtype of this {@link SchemaFieldConfig} instance and return the same instance. + * + * @param dtype The data type of the target column. Supported types are ['string', + * 'numeric', 'date']. + * @return The same instance of this {@link SchemaFieldConfig} class + */ + @Nonnull + public SchemaFieldConfig dtype(@Nonnull final ColumnType dtype) { + this.dtype = dtype; + return this; + } + + /** + * The data type of the target column. Supported types are ['string', 'numeric', + * 'date']. + * + * @return dtype The dtype of this {@link SchemaFieldConfig} instance. + */ + @Nonnull + public ColumnType getDtype() { + return dtype; + } + + /** + * Set the dtype of this {@link SchemaFieldConfig} instance. + * + * @param dtype The data type of the target column. Supported types are ['string', + * 'numeric', 'date']. + */ + public void setDtype(@Nonnull final ColumnType dtype) { + this.dtype = dtype; + } + + /** + * Get the names of the unrecognizable properties of the {@link SchemaFieldConfig}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link SchemaFieldConfig} 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("SchemaFieldConfig has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link SchemaFieldConfig} instance including + * unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (dtype != null) declaredFields.put("dtype", dtype); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link SchemaFieldConfig} 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 SchemaFieldConfig schemaFieldConfig = (SchemaFieldConfig) o; + return Objects.equals(this.cloudSdkCustomFields, schemaFieldConfig.cloudSdkCustomFields) + && Objects.equals(this.dtype, schemaFieldConfig.dtype); + } + + @Override + public int hashCode() { + return Objects.hash(dtype, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class SchemaFieldConfig {\n"); + sb.append(" dtype: ").append(toIndentedString(dtype)).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 SchemaFieldConfig} + * instance with all required arguments. + */ + public static Builder create() { + return (dtype) -> new SchemaFieldConfig().dtype(dtype); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the dtype of this {@link SchemaFieldConfig} instance. + * + * @param dtype The data type of the target column. Supported types are ['string', + * 'numeric', 'date']. + * @return The SchemaFieldConfig instance. + */ + SchemaFieldConfig dtype(@Nonnull final ColumnType dtype); + } +} diff --git a/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/TargetColumnConfig.java b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/TargetColumnConfig.java new file mode 100644 index 000000000..ec0324c3f --- /dev/null +++ b/foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/generated/model/TargetColumnConfig.java @@ -0,0 +1,371 @@ +/* + * SAP-RPT-1 Tabular AI + * A REST API for in-context learning with the SAP-RPT-1 model. + * + * + * + * 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.foundationmodels.rpt.generated.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; + +/** Configuration for a target column in the prediction model. */ +// CHECKSTYLE:OFF +public class TargetColumnConfig +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("prediction_placeholder") + private PredictionPlaceholder predictionPlaceholder; + + /** Gets or Sets taskType */ + public enum TaskTypeEnum { + /** The CLASSIFICATION option of this TargetColumnConfig */ + CLASSIFICATION("classification"), + + /** The REGRESSION option of this TargetColumnConfig */ + REGRESSION("regression"), + + /** The UNKNOWN_DEFAULT_OPEN_API option of this TargetColumnConfig */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TaskTypeEnum(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 TargetColumnConfig + */ + @JsonCreator + @Nullable + public static TaskTypeEnum fromValue(@Nonnull final String value) { + for (TaskTypeEnum b : TaskTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } + } + + @JsonProperty("task_type") + private TaskTypeEnum taskType; + + @JsonProperty("top_k") + private Integer topK; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link TargetColumnConfig} instance and return the same instance. + * + * @param name The name of the target column. + * @return The same instance of this {@link TargetColumnConfig} class + */ + @Nonnull + public TargetColumnConfig name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the target column. + * + * @return name The name of this {@link TargetColumnConfig} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link TargetColumnConfig} instance. + * + * @param name The name of the target column. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the predictionPlaceholder of this {@link TargetColumnConfig} instance and return the same + * instance. + * + * @param predictionPlaceholder The predictionPlaceholder of this {@link TargetColumnConfig} + * @return The same instance of this {@link TargetColumnConfig} class + */ + @Nonnull + public TargetColumnConfig predictionPlaceholder( + @Nonnull final PredictionPlaceholder predictionPlaceholder) { + this.predictionPlaceholder = predictionPlaceholder; + return this; + } + + /** + * Get predictionPlaceholder + * + * @return predictionPlaceholder The predictionPlaceholder of this {@link TargetColumnConfig} + * instance. + */ + @Nonnull + public PredictionPlaceholder getPredictionPlaceholder() { + return predictionPlaceholder; + } + + /** + * Set the predictionPlaceholder of this {@link TargetColumnConfig} instance. + * + * @param predictionPlaceholder The predictionPlaceholder of this {@link TargetColumnConfig} + */ + public void setPredictionPlaceholder(@Nonnull final PredictionPlaceholder predictionPlaceholder) { + this.predictionPlaceholder = predictionPlaceholder; + } + + /** + * Set the taskType of this {@link TargetColumnConfig} instance and return the same instance. + * + * @param taskType The taskType of this {@link TargetColumnConfig} + * @return The same instance of this {@link TargetColumnConfig} class + */ + @Nonnull + public TargetColumnConfig taskType(@Nullable final TaskTypeEnum taskType) { + this.taskType = taskType; + return this; + } + + /** + * Get taskType + * + * @return taskType The taskType of this {@link TargetColumnConfig} instance. + */ + @Nullable + public TaskTypeEnum getTaskType() { + return taskType; + } + + /** + * Set the taskType of this {@link TargetColumnConfig} instance. + * + * @param taskType The taskType of this {@link TargetColumnConfig} + */ + public void setTaskType(@Nullable final TaskTypeEnum taskType) { + this.taskType = taskType; + } + + /** + * Set the topK of this {@link TargetColumnConfig} instance and return the same instance. + * + * @param topK The topK of this {@link TargetColumnConfig} + * @return The same instance of this {@link TargetColumnConfig} class + */ + @Nonnull + public TargetColumnConfig topK(@Nullable final Integer topK) { + this.topK = topK; + return this; + } + + /** + * Get topK + * + * @return topK The topK of this {@link TargetColumnConfig} instance. + */ + @Nullable + public Integer getTopK() { + return topK; + } + + /** + * Set the topK of this {@link TargetColumnConfig} instance. + * + * @param topK The topK of this {@link TargetColumnConfig} + */ + public void setTopK(@Nullable final Integer topK) { + this.topK = topK; + } + + /** + * Get the names of the unrecognizable properties of the {@link TargetColumnConfig}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link TargetColumnConfig} 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("TargetColumnConfig has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link TargetColumnConfig} 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 (predictionPlaceholder != null) + declaredFields.put("predictionPlaceholder", predictionPlaceholder); + if (taskType != null) declaredFields.put("taskType", taskType); + if (topK != null) declaredFields.put("topK", topK); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link TargetColumnConfig} 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 TargetColumnConfig targetColumnConfig = (TargetColumnConfig) o; + return Objects.equals(this.cloudSdkCustomFields, targetColumnConfig.cloudSdkCustomFields) + && Objects.equals(this.name, targetColumnConfig.name) + && Objects.equals(this.predictionPlaceholder, targetColumnConfig.predictionPlaceholder) + && Objects.equals(this.taskType, targetColumnConfig.taskType) + && Objects.equals(this.topK, targetColumnConfig.topK); + } + + @Override + public int hashCode() { + return Objects.hash(name, predictionPlaceholder, taskType, topK, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class TargetColumnConfig {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" predictionPlaceholder: ") + .append(toIndentedString(predictionPlaceholder)) + .append("\n"); + sb.append(" taskType: ").append(toIndentedString(taskType)).append("\n"); + sb.append(" topK: ").append(toIndentedString(topK)).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 TargetColumnConfig} + * instance with all required arguments. + */ + public static Builder create() { + return (name) -> + (predictionPlaceholder) -> + new TargetColumnConfig().name(name).predictionPlaceholder(predictionPlaceholder); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the name of this {@link TargetColumnConfig} instance. + * + * @param name The name of the target column. + * @return The TargetColumnConfig builder. + */ + Builder1 name(@Nonnull final String name); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the predictionPlaceholder of this {@link TargetColumnConfig} instance. + * + * @param predictionPlaceholder The predictionPlaceholder of this {@link TargetColumnConfig} + * @return The TargetColumnConfig instance. + */ + TargetColumnConfig predictionPlaceholder( + @Nonnull final PredictionPlaceholder predictionPlaceholder); + } +} diff --git a/foundation-models/sap-rpt/src/main/resources/spec/sap-rpt-1_openapi.json b/foundation-models/sap-rpt/src/main/resources/spec/sap-rpt-1_openapi.json new file mode 100644 index 000000000..40a9e2846 --- /dev/null +++ b/foundation-models/sap-rpt/src/main/resources/spec/sap-rpt-1_openapi.json @@ -0,0 +1,848 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "SAP-RPT-1 Tabular AI", + "description": "A REST API for in-context learning with the SAP-RPT-1 model.", + "version": "0.1.0", + "x-logo": { + "url": "https://www.sap.com/favicon.ico" + } + }, + "servers": [ + { + "url": "/v1" + } + ], + "paths": { + "/predict": { + "post": { + "summary": "Make in-context predictions for specified target columns based on provided table data JSON (optionally gzip-compressed).", + "description": "Make in-context predictions for specified target columns.\nEither \"rows\" or \"columns\" must be provided and must contain both context and query rows.\nYou can optionally send gzip-compressed JSON payloads and set a \"Content-Encoding: gzip\" header.", + "operationId": "predict", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PredictRequestPayload" + }, + "examples": { + "classification_example": { + "summary": "Classification Example", + "description": "Predict product category using in-context learning", + "value": { + "index_column": "id", + "prediction_config": { + "target_columns": [ + { + "name": "category", + "prediction_placeholder": "?", + "task_type": "classification" + } + ] + }, + "columns": { + "id": [ + 1, + 2, + 3, + 4 + ], + "product": [ + "Laptop", + "Mouse", + "Keyboard", + "Monitor" + ], + "price": [ + 899, + 25, + 75, + 350 + ], + "category": [ + "Electronics", + "Accessories", + "Accessories", + "?" + ], + "stock": [ + "150", + "500", + "320", + "200" + ] + }, + "data_schema": { + "id": { + "dtype": "numeric" + }, + "product": { + "dtype": "string" + }, + "price": { + "dtype": "numeric" + }, + "category": { + "dtype": "string" + }, + "stock": { + "dtype": "numeric" + } + } + } + }, + "regression_example": { + "summary": "Regression Example", + "description": "Predict multiple columns including regression using in-context learning", + "value": { + "index_column": "ID", + "prediction_config": { + "target_columns": [ + { + "name": "PRICE", + "prediction_placeholder": "[?]", + "task_type": "regression" + }, + { + "name": "COSTCENTER", + "prediction_placeholder": "[PREDICT]", + "task_type": "classification" + } + ] + }, + "columns": { + "PRODUCT": [ + "Couch", + "Office Chair", + "Server Rack", + "Server Rack" + ], + "PRICE": [ + "[?]", + 150.8, + "210.0", + "[?]" + ], + "ORDERDATE": [ + "2025-11-28", + "2025-11-02", + "2025-11-01", + "2025-11-01" + ], + "ID": [ + "35", + "44", + "108", + "104" + ], + "COSTCENTER": [ + "[PREDICT]", + "Office Furniture", + "Data Infrastructure", + "[PREDICT]" + ] + }, + "data_schema": { + "PRODUCT": { + "dtype": "string" + }, + "PRICE": { + "dtype": "numeric" + }, + "ORDERDATE": { + "dtype": "date" + }, + "ID": { + "dtype": "string" + }, + "COSTCENTER": { + "dtype": "string" + } + } + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Prediction", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PredictResponsePayload" + }, + "example": { + "id": "781bf15e-602a-4503-a8ff-dc32b20f804a", + "status": { + "code": 0, + "message": "ok" + }, + "predictions": [ + { + "COSTCENTER": [ + { + "prediction": "Office Furniture", + "confidence": 0.52 + } + ], + "PRICE": [ + { + "prediction": 195.090179443359 + } + ], + "ID": "35" + }, + { + "COSTCENTER": [ + { + "prediction": "Data Infrastructure", + "confidence": 1 + } + ], + "PRICE": [ + { + "prediction": 209.380523681641 + } + ], + "ID": "104" + } + ], + "metadata": { + "num_columns": 5, + "num_rows": 2, + "num_predictions": 4, + "num_query_rows": 2 + } + } + } + } + }, + "400": { + "description": "Bad Request - Invalid input data", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 2, + "message": "Invalid input" + }, + "detail": [ + { + "loc": [ + "body", + "prediction_config" + ], + "msg": "Field required", + "type": "missing" + } + ] + } + } + } + }, + "413": { + "description": "Payload Too Large", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 2, + "message": "Invalid input" + }, + "detail": [ + { + "loc": [], + "msg": "Request body too large (\u003E10485760 bytes)", + "type": "value_error" + } + ] + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 2, + "message": "Invalid input" + }, + "detail": [ + { + "loc": [ + "body", + "prediction_config" + ], + "msg": "Field required", + "type": "value_error" + } + ] + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 3, + "message": "Internal server error" + }, + "detail": [] + } + } + } + } + } + } + }, + "/predict_parquet": { + "post": { + "summary": "Make in-context predictions for specified target columns based on provided table data Parquet file.", + "description": "Make in-context predictions for specified target columns based on provided table data Parquet file.", + "operationId": "predict_parquet", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/Body_predict_parquet" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Prediction", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PredictResponsePayload" + }, + "example": { + "id": "781bf15e-602a-4503-a8ff-dc32b20f804a", + "status": { + "code": 0, + "message": "ok" + }, + "predictions": [ + { + "COSTCENTER": [ + { + "prediction": "Office Furniture", + "confidence": 0.52 + } + ], + "PRICE": [ + { + "prediction": 195.090179443359 + } + ], + "ID": "35" + }, + { + "COSTCENTER": [ + { + "prediction": "Data Infrastructure", + "confidence": 1 + } + ], + "PRICE": [ + { + "prediction": 209.380523681641 + } + ], + "ID": "104" + } + ], + "metadata": { + "num_columns": 5, + "num_rows": 2, + "num_predictions": 4, + "num_query_rows": 2 + } + } + } + } + }, + "400": { + "description": "Bad Request - Invalid input data", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 2, + "message": "Invalid input" + }, + "detail": [ + { + "loc": [ + "body", + "prediction_config" + ], + "msg": "Field required", + "type": "missing" + } + ] + } + } + } + }, + "413": { + "description": "Payload Too Large", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 2, + "message": "Invalid input" + }, + "detail": [ + { + "loc": [], + "msg": "Request body too large (\u003E10485760 bytes)", + "type": "value_error" + } + ] + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 2, + "message": "Invalid input" + }, + "detail": [ + { + "loc": [ + "body", + "prediction_config" + ], + "msg": "Field required", + "type": "value_error" + } + ] + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "example": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "status": { + "code": 3, + "message": "Internal server error" + }, + "detail": [] + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Body_predict_parquet": { + "properties": { + "file": { + "type": "string", + "format": "binary", + "title": "File", + "description": "Parquet file containing the data" + }, + "prediction_config": { + "type": "string", + "title": "Prediction Config", + "description": "JSON string for prediction_config" + }, + "index_column": { + "type": "string", + "title": "Index Column", + "description": "Optional index column name" + }, + "parse_data_types": { + "type": "boolean", + "title": "Parse Data Types", + "description": "Whether to parse data types", + "default": true + } + }, + "type": "object", + "required": [ + "file", + "prediction_config" + ], + "title": "Body_predict_parquet" + }, + "PredictResponseMetadata": { + "properties": { + "num_columns": { + "type": "integer", + "title": "Num Columns", + "description": "Number of columns in the input data." + }, + "num_rows": { + "type": "integer", + "title": "Num Rows", + "description": "Number of rows in the input data." + }, + "num_predictions": { + "type": "integer", + "title": "Num Predictions", + "description": "Number of table cells containing the specified placeholder value." + }, + "num_query_rows": { + "type": "integer", + "title": "Num Query Rows", + "description": "Number of rows for which a prediction was made." + } + }, + "type": "object", + "required": [ + "num_columns", + "num_rows", + "num_predictions", + "num_query_rows" + ], + "title": "PredictResponseMetadata", + "description": "Metadata about the prediction request." + }, + "PredictResponsePayload": { + "properties": { + "id": { + "type": "string", + "title": "Id", + "description": "Unique ID for the request." + }, + "status": { + "$ref": "#/components/schemas/PredictResponseStatus", + "description": "Status message that can indicate warnings (e.g. about suboptimal data)." + }, + "predictions": { + "items": { + "additionalProperties": { + "anyOf": [ + { + "items": { + "$ref": "#/components/schemas/PredictionResult" + }, + "type": "array" + }, + { + "type": "string" + }, + { + "type": "integer" + } + ] + }, + "type": "object" + }, + "type": "array", + "title": "Predictions", + "description": "Mapping of column names to their list of prediction results or index column." + }, + "metadata": { + "$ref": "#/components/schemas/PredictResponseMetadata" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "id", + "status", + "predictions", + "metadata" + ], + "title": "PredictResponsePayload", + "description": "Response payload for prediction requests.\nContains a list of prediction results." + }, + "PredictResponseStatus": { + "properties": { + "code": { + "type": "integer", + "title": "Code", + "description": "Status code (zero means success, other status codes indicate warnings)" + }, + "message": { + "type": "string", + "title": "Message", + "description": "Status message, either \"ok\" or contains a warning / more information." + } + }, + "type": "object", + "required": [ + "code", + "message" + ], + "title": "PredictResponseStatus", + "description": "Output status for prediction requests." + }, + "PredictionResult": { + "properties": { + "prediction": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ], + "title": "Prediction", + "description": "The predicted value for the column." + }, + "confidence": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Confidence", + "description": "The confidence of the prediction (currently not provided)." + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "prediction" + ], + "title": "PredictionResult", + "description": "A single prediction result for a single column in a single row." + }, + "ColumnType": { + "enum": [ + "string", + "numeric", + "date" + ], + "title": "ColumnType", + "type": "string" + }, + "PredictionConfig": { + "additionalProperties": false, + "description": "Configuration of the prediction model.", + "properties": { + "target_columns": { + "items": { + "$ref": "#/components/schemas/TargetColumnConfig" + }, + "title": "Target Columns", + "type": "array" + } + }, + "required": [ + "target_columns" + ], + "title": "PredictionConfig", + "type": "object" + }, + "SchemaFieldConfig": { + "description": "Configuration for a single field in the input data schema.", + "properties": { + "dtype": { + "$ref": "#/components/schemas/ColumnType", + "description": "The data type of the target column. Supported types are ['string', 'numeric', 'date']." + } + }, + "required": [ + "dtype" + ], + "title": "SchemaFieldConfig", + "type": "object" + }, + "TargetColumnConfig": { + "description": "Configuration for a target column in the prediction model.", + "properties": { + "name": { + "description": "The name of the target column.", + "title": "Name", + "type": "string" + }, + "prediction_placeholder": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ], + "description": "The placeholder value in any column for which to predict a value. The model will predict a value for all table cells containing this value.", + "title": "Prediction Placeholder" + }, + "task_type": { + "anyOf": [ + { + "enum": [ + "classification", + "regression" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "The type of prediction task for this column. If not provided, the model will infer the task type from the data.", + "title": "Task Type" + }, + "top_k": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "description": "How many predictions to output per classification column.If not provided, only a single prediction is returned. Only relevant for classification.", + "title": "Top K" + } + }, + "required": [ + "name", + "prediction_placeholder" + ], + "title": "TargetColumnConfig", + "type": "object" + }, + "PredictRequestPayload": { + "additionalProperties": false, + "description": "Users need to specify a list of rows, which contains both the context rows\nand the rows for which to predict a label, and a mapping of column names\nto placeholder values. The model will predict the value for any column\nspecified in `predict_columns` for all rows that have the placeholder\nvalue in that column.", + "properties": { + "prediction_config": { + "$ref": "#/components/schemas/PredictionConfig", + "description": "Configuration of target columns and placeholder value." + }, + "rows": { + "default": null, + "description": "Table rows, i.e. list of objects where each object is a mapping of column names to values. Either \"rows\" or \"columns\" must be provided.", + "items": { + "additionalProperties": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "type": "object" + }, + "title": "Rows", + "type": "array" + }, + "columns": { + "anyOf": [ + { + "additionalProperties": { + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "integer" + }, + { + "type": "null" + } + ] + }, + "type": "array" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Alternative to rows: columns of data where each key is a column name and the value is a list of all column values. Either \"rows\" or \"columns\" must be provided.", + "title": "Columns" + }, + "index_column": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "description": "The name of the index column. If provided, the service will return this column's value in each prediction object to facilitate aligning the output predictions with the input rows on the client side. If not provided, the column will not be included in the output.", + "title": "Index Column" + }, + "parse_data_types": { + "default": true, + "description": "Whether to parse the data types of the columns. If set to True, numeric columns will be parsed to float or integer and dates in ISO format YYYY-MM-DD will be parsed.", + "title": "Parse Data Types", + "type": "boolean" + }, + "data_schema": { + "anyOf": [ + { + "additionalProperties": { + "$ref": "#/components/schemas/SchemaFieldConfig" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "default": null, + "description": "Optional schema defining the data types of each column. If provided, this will override automatic data type parsing.", + "title": "Data Schema" + } + }, + "required": [ + "prediction_config" + ], + "title": "PredictRequestPayload", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/foundation-models/sap-rpt/src/test/java/com/sap/ai/sdk/foundationmodels/rpt/RptClientTest.java b/foundation-models/sap-rpt/src/test/java/com/sap/ai/sdk/foundationmodels/rpt/RptClientTest.java new file mode 100644 index 000000000..a183d7f77 --- /dev/null +++ b/foundation-models/sap-rpt/src/test/java/com/sap/ai/sdk/foundationmodels/rpt/RptClientTest.java @@ -0,0 +1,167 @@ +package com.sap.ai.sdk.foundationmodels.rpt; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.*; +import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Accessor; +import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Cache; +import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@WireMockTest +class RptClientTest { + private static RptClient client; + + @BeforeEach + void setup(final WireMockRuntimeInfo server) { + final DefaultHttpDestination destination = + DefaultHttpDestination.builder(server.getHttpBaseUrl()).build(); + client = RptClient.forDestination(destination); + ApacheHttpClient5Accessor.setHttpClientCache(ApacheHttpClient5Cache.DISABLED); + } + + @Test + void testRptModels() { + assertThat(RptModel.SAP_RPT_1_SMALL.name()).isEqualTo("sap-rpt-1-small"); + assertThat(RptModel.SAP_RPT_1_SMALL.version()).isNull(); + + assertThat(RptModel.SAP_RPT_1_LARGE.name()).isEqualTo("sap-rpt-1-large"); + assertThat(RptModel.SAP_RPT_1_LARGE.version()).isNull(); + + final var modelWithVersion = RptModel.SAP_RPT_1_SMALL.withVersion("v1.0"); + assertThat(modelWithVersion.name()).isEqualTo("sap-rpt-1-small"); + assertThat(modelWithVersion.version()).isEqualTo("v1.0"); + } + + static PredictRequestPayload createBaseRequest() { + final var dataSchema = + Map.of( + "PRODUCT", SchemaFieldConfig.create().dtype(ColumnType.STRING), + "PRICE", SchemaFieldConfig.create().dtype(ColumnType.STRING), + "ORDERDATE", SchemaFieldConfig.create().dtype(ColumnType.DATE), + "ID", SchemaFieldConfig.create().dtype(ColumnType.STRING), + "COSTCENTER", SchemaFieldConfig.create().dtype(ColumnType.STRING)); + final var targetColumns = + List.of( + TargetColumnConfig.create() + .name("COSTCENTER") + .predictionPlaceholder(PredictionPlaceholder.create("[PREDICT]")) + .taskType(TargetColumnConfig.TaskTypeEnum.CLASSIFICATION)); + + return PredictRequestPayload.create() + .predictionConfig(PredictionConfig.create().targetColumns(targetColumns)) + .indexColumn("ID") + .dataSchema(dataSchema) + .parseDataTypes(true); + } + + @Test + void testTabCompletionWithRowsFormat() { + final List> rows = + List.of( + Map.of( + "PRODUCT", RowsInnerValue.create("Couch"), + "PRICE", RowsInnerValue.create(BigDecimal.valueOf(999.99)), + "ORDERDATE", RowsInnerValue.create("28-11-2025"), + "ID", RowsInnerValue.create("35"), + "COSTCENTER", RowsInnerValue.create("[PREDICT]")), + Map.of( + "PRODUCT", RowsInnerValue.create("Office Chair"), + "PRICE", RowsInnerValue.create(BigDecimal.valueOf(150.8)), + "ORDERDATE", RowsInnerValue.create("02-11-2025"), + "ID", RowsInnerValue.create("44"), + "COSTCENTER", RowsInnerValue.create("Office Furniture")), + Map.of( + "PRODUCT", RowsInnerValue.create("Server Rack"), + "PRICE", RowsInnerValue.create(BigDecimal.valueOf(2200.00)), + "ORDERDATE", RowsInnerValue.create("01-11-2025"), + "ID", RowsInnerValue.create("104"), + "COSTCENTER", RowsInnerValue.create("Data Infrastructure"))); + final var request = createBaseRequest().rows(rows); + + final var response = client.tabCompletion(request); + assertThat(response).isNotNull(); + assertThat(response.getId()).isEqualTo("0381c575-9ee5-46f1-9223-4f9caf039e48"); + assertThat(response.getMetadata().getNumColumns()).isEqualTo(5); + assertThat(response.getMetadata().getNumPredictions()).isEqualTo(1); + assertThat(response.getMetadata().getNumQueryRows()).isEqualTo(1); + assertThat(response.getMetadata().getNumRows()).isEqualTo(2); + + assertThat(response.getStatus().getCode()).isEqualTo(0); + assertThat(response.getStatus().getMessage()).isEqualTo("ok"); + assertThat(response.getPredictions()).hasSize(1); + + final Map prediction = response.getPredictions().get(0); + assertThat(prediction) + .containsEntry("ID", PredictionsInnerValue.create("35")) + .containsEntry( + "COSTCENTER", + PredictionsInnerValue.createListOfPredictionResults( + List.of( + PredictionResult.create() + .prediction(Prediction.create("Office Furniture")) + .confidence(BigDecimal.valueOf(0.97))))); + } + + @Test + void testTabCompletionWithColumnsFormat() { + final Map> columns = + Map.of( + "PRODUCT", + List.of( + RowsInnerValue.create("Couch"), + RowsInnerValue.create("Office Chair"), + RowsInnerValue.create("Server Rack")), + "PRICE", + List.of( + RowsInnerValue.create(BigDecimal.valueOf(999.99)), + RowsInnerValue.create(BigDecimal.valueOf(150.8)), + RowsInnerValue.create(BigDecimal.valueOf(2200.00))), + "ORDERDATE", + List.of( + RowsInnerValue.create("28-11-2025"), + RowsInnerValue.create("02-11-2025"), + RowsInnerValue.create("01-11-2025")), + "ID", + List.of( + RowsInnerValue.create("35"), + RowsInnerValue.create("44"), + RowsInnerValue.create("104")), + "COSTCENTER", + List.of( + RowsInnerValue.create("[PREDICT]"), + RowsInnerValue.create("Office Furniture"), + RowsInnerValue.create("Data Infrastructure"))); + final var request = createBaseRequest().columns(columns); + + final var response = client.tabCompletion(request); + + assertThat(response).isNotNull(); + assertThat(response.getId()).isEqualTo("f89fb682-8d6b-4ef5-97f4-bd3c9aab8c49"); + assertThat(response.getMetadata().getNumColumns()).isEqualTo(5); + assertThat(response.getMetadata().getNumPredictions()).isEqualTo(1); + assertThat(response.getMetadata().getNumQueryRows()).isEqualTo(1); + assertThat(response.getMetadata().getNumRows()).isEqualTo(2); + + assertThat(response.getStatus().getCode()).isEqualTo(0); + assertThat(response.getStatus().getMessage()).isEqualTo("ok"); + assertThat(response.getPredictions()).hasSize(1); + + final Map prediction = response.getPredictions().get(0); + assertThat(prediction) + .containsEntry("ID", PredictionsInnerValue.create("35")) + .containsEntry( + "COSTCENTER", + PredictionsInnerValue.createListOfPredictionResults( + List.of( + PredictionResult.create() + .prediction(Prediction.create("Office Furniture")) + .confidence(BigDecimal.valueOf(0.97))))); + } +} diff --git a/foundation-models/sap-rpt/src/test/resources/mappings/predictColumnWise.json b/foundation-models/sap-rpt/src/test/resources/mappings/predictColumnWise.json new file mode 100644 index 000000000..b04f39fb9 --- /dev/null +++ b/foundation-models/sap-rpt/src/test/resources/mappings/predictColumnWise.json @@ -0,0 +1,98 @@ +{ + "request": { + "method": "POST", + "url": "/predict", + "bodyPatterns": [ + { + "equalToJson": { + "prediction_config": { + "target_columns": [ + { + "name": "COSTCENTER", + "prediction_placeholder": "[PREDICT]", + "task_type": "classification" + } + ] + }, + "rows": [], + "columns": { + "PRICE": [ + 999.99, + 150.8, + 2200.0 + ], + "ID": [ + "35", + "44", + "104" + ], + "PRODUCT": [ + "Couch", + "Office Chair", + "Server Rack" + ], + "COSTCENTER": [ + "[PREDICT]", + "Office Furniture", + "Data Infrastructure" + ], + "ORDERDATE": [ + "28-11-2025", + "02-11-2025", + "01-11-2025" + ] + }, + "index_column": "ID", + "parse_data_types": true, + "data_schema": { + "PRICE": { + "dtype": "string" + }, + "ID": { + "dtype": "string" + }, + "PRODUCT": { + "dtype": "string" + }, + "COSTCENTER": { + "dtype": "string" + }, + "ORDERDATE": { + "dtype": "date" + } + } + } + } + ] + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json" + }, + "jsonBody": { + "id": "f89fb682-8d6b-4ef5-97f4-bd3c9aab8c49", + "metadata": { + "num_columns": 5, + "num_predictions": 1, + "num_query_rows": 1, + "num_rows": 2 + }, + "predictions": [ + { + "COSTCENTER": [ + { + "confidence": 0.97, + "prediction": "Office Furniture" + } + ], + "ID": "35" + } + ], + "status": { + "code": 0, + "message": "ok" + } + } + } +} \ No newline at end of file diff --git a/foundation-models/sap-rpt/src/test/resources/mappings/predictRowWise.json b/foundation-models/sap-rpt/src/test/resources/mappings/predictRowWise.json new file mode 100644 index 000000000..9d97f1f84 --- /dev/null +++ b/foundation-models/sap-rpt/src/test/resources/mappings/predictRowWise.json @@ -0,0 +1,93 @@ +{ + "request": { + "method": "POST", + "url": "/predict", + "bodyPatterns": [ + { + "equalToJson": { + "prediction_config": { + "target_columns": [ + { + "name": "COSTCENTER", + "prediction_placeholder": "[PREDICT]", + "task_type": "classification" + } + ] + }, + "rows": [ + { + "ORDERDATE": "28-11-2025", + "PRICE": 999.99, + "ID": "35", + "PRODUCT": "Couch", + "COSTCENTER": "[PREDICT]" + }, + { + "ORDERDATE": "02-11-2025", + "PRICE": 150.8, + "ID": "44", + "PRODUCT": "Office Chair", + "COSTCENTER": "Office Furniture" + }, + { + "ORDERDATE": "01-11-2025", + "PRICE": 2200.0, + "ID": "104", + "PRODUCT": "Server Rack", + "COSTCENTER": "Data Infrastructure" + } + ], + "index_column": "ID", + "parse_data_types": true, + "data_schema": { + "ORDERDATE": { + "dtype": "date" + }, + "PRICE": { + "dtype": "string" + }, + "ID": { + "dtype": "string" + }, + "PRODUCT": { + "dtype": "string" + }, + "COSTCENTER": { + "dtype": "string" + } + } + } + } + ] + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json" + }, + "jsonBody": { + "id": "0381c575-9ee5-46f1-9223-4f9caf039e48", + "metadata": { + "num_columns": 5, + "num_predictions": 1, + "num_query_rows": 1, + "num_rows": 2 + }, + "predictions": [ + { + "COSTCENTER": [ + { + "confidence": 0.97, + "prediction": "Office Furniture" + } + ], + "ID": "35" + } + ], + "status": { + "code": 0, + "message": "ok" + } + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8a849c4b3..446c615d3 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ core-services/document-grounding core-services/prompt-registry foundation-models/openai + foundation-models/sap-rpt scm:git:git://github.com/SAP/ai-sdk-java.git @@ -55,7 +56,7 @@ full UTF-8 2025-04-03T13:23:00Z - 5.25.0 + 5.26.0 6.0.2 3.13.2 3.27.6 @@ -250,6 +251,11 @@ openai ${project.version} + + com.sap.ai.sdk.foundationmodels + sap-rpt + ${project.version} + com.sap.ai.sdk.app spring-app @@ -656,6 +662,7 @@ https://gitbox.apache.org/repos/asf?p=maven-pmd-plugin.git;a=blob_plain;f=src/ma com/sap/ai/sdk/core/client/* com/sap/ai/sdk/core/model/* com/sap/ai/sdk/foundationmodels/openai/generated/model/* + com/sap/ai/sdk/foundationmodels/rpt/generated/** com/sap/ai/sdk/orchestration/model/* com/sap/ai/sdk/grounding/client/* com/sap/ai/sdk/grounding/model/* @@ -683,6 +690,7 @@ https://gitbox.apache.org/repos/asf?p=maven-pmd-plugin.git;a=blob_plain;f=src/ma com/sap/ai/sdk/core/model/* com/sap/ai/sdk/orchestration/model/* com/sap/ai/sdk/foundationmodels/openai/generated/model/* + com/sap/ai/sdk/foundationmodels/rpt/generated/** com/sap/ai/sdk/grounding/client/* com/sap/ai/sdk/grounding/model/* com/sap/ai/sdk/prompt/registry/model/* @@ -803,6 +811,7 @@ https://gitbox.apache.org/repos/asf?p=maven-pmd-plugin.git;a=blob_plain;f=src/ma sample-code/spring-app + foundation-models/sap-rpt diff --git a/sample-code/spring-app/pom.xml b/sample-code/spring-app/pom.xml index fa0d93e63..ac60a48ef 100644 --- a/sample-code/spring-app/pom.xml +++ b/sample-code/spring-app/pom.xml @@ -83,6 +83,10 @@ com.sap.ai.sdk prompt-registry + + com.sap.ai.sdk.foundationmodels + sap-rpt + com.sap.cloud.sdk.cloudplatform cloudplatform-core diff --git a/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/RptService.java b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/RptService.java new file mode 100644 index 000000000..38e2931bb --- /dev/null +++ b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/RptService.java @@ -0,0 +1,73 @@ +package com.sap.ai.sdk.app.services; + +import com.sap.ai.sdk.foundationmodels.rpt.RptClient; +import com.sap.ai.sdk.foundationmodels.rpt.RptModel; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.ColumnType; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictRequestPayload; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictResponsePayload; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictionConfig; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.PredictionPlaceholder; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.RowsInnerValue; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.SchemaFieldConfig; +import com.sap.ai.sdk.foundationmodels.rpt.generated.model.TargetColumnConfig; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import javax.annotation.Nonnull; + +/** Service to interact with the RPT model for predictions. */ +public class RptService { + + static final RptClient rptClient = RptClient.forModel(RptModel.SAP_RPT_1_SMALL); + + /** + * Makes a prediction request to the RPT model. * + * + * @return the prediction response payload from the RPT model + */ + @Nonnull + public PredictResponsePayload predict() { + final var dataSchema = + Map.of( + "PRODUCT", SchemaFieldConfig.create().dtype(ColumnType.STRING), + "PRICE", SchemaFieldConfig.create().dtype(ColumnType.STRING), + "ORDERDATE", SchemaFieldConfig.create().dtype(ColumnType.DATE), + "ID", SchemaFieldConfig.create().dtype(ColumnType.STRING), + "COSTCENTER", SchemaFieldConfig.create().dtype(ColumnType.STRING)); + final var targetColumns = + List.of( + TargetColumnConfig.create() + .name("COSTCENTER") + .predictionPlaceholder(PredictionPlaceholder.create("[PREDICT]")) + .taskType(TargetColumnConfig.TaskTypeEnum.CLASSIFICATION)); + final List> rows = + List.of( + Map.of( + "PRODUCT", RowsInnerValue.create("Couch"), + "PRICE", RowsInnerValue.create(BigDecimal.valueOf(999.99)), + "ORDERDATE", RowsInnerValue.create("28-11-2025"), + "ID", RowsInnerValue.create("35"), + "COSTCENTER", RowsInnerValue.create("[PREDICT]")), + Map.of( + "PRODUCT", RowsInnerValue.create("Office Chair"), + "PRICE", RowsInnerValue.create(BigDecimal.valueOf(150.8)), + "ORDERDATE", RowsInnerValue.create("02-11-2025"), + "ID", RowsInnerValue.create("44"), + "COSTCENTER", RowsInnerValue.create("Office Furniture")), + Map.of( + "PRODUCT", RowsInnerValue.create("Server Rack"), + "PRICE", RowsInnerValue.create(BigDecimal.valueOf(2200.00)), + "ORDERDATE", RowsInnerValue.create("01-11-2025"), + "ID", RowsInnerValue.create("104"), + "COSTCENTER", RowsInnerValue.create("Data Infrastructure"))); + + final var request = + PredictRequestPayload.create() + .predictionConfig(PredictionConfig.create().targetColumns(targetColumns)) + .indexColumn("ID") + .dataSchema(dataSchema) + .parseDataTypes(true) + .rows(rows); + return rptClient.tabCompletion(request); + } +} diff --git a/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/RptTest.java b/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/RptTest.java new file mode 100644 index 000000000..b70b7c406 --- /dev/null +++ b/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/RptTest.java @@ -0,0 +1,21 @@ +package com.sap.ai.sdk.app.controllers; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.sap.ai.sdk.app.services.RptService; +import org.junit.jupiter.api.Test; + +class RptTest { + @Test + void testRpt() { + final var service = new RptService(); + final var response = service.predict(); + + assertThat(response).isNotNull(); + assertThat(response.getMetadata().getNumRows()).isEqualTo(2); + assertThat(response.getMetadata().getNumColumns()).isEqualTo(5); + assertThat(response.getMetadata().getNumQueryRows()).isEqualTo(1); + assertThat(response.getMetadata().getNumPredictions()).isEqualTo(1); + assertThat(response.getPredictions().get(0)).containsKey("COSTCENTER"); + } +}