Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/spec-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ jobs:
FILE_PATH='core-services/prompt-registry/src/main/resources/spec/prompt-registry.yaml'
MODULE_PATH='core-services/prompt-registry'
;;
sap-rpt) # https://github.tools.sap/DL-COE/sap-rpt-1-public-content
API_URL="$API_BASE_URL/DL-COE/sap-rpt-1-public-content/contents/sap-rpt-1_openapi.json?ref=$REF"
FILE_PATH='foundation-models/sap-rpt/src/main/resources/spec/sap-rpt-1_openapi.json'
sap-rpt) # https://github.tools.sap/DL-COE/sap-rpt-resources
API_URL="$API_BASE_URL/DL-COE/sap-rpt-resources/contents/sap-rpt-1.5_openapi.json?ref=$REF"
FILE_PATH='foundation-models/sap-rpt/src/main/resources/spec/sap-rpt_openapi.json'
MODULE_PATH='foundation-models/sap-rpt'
;;
batch)
Expand Down
2 changes: 1 addition & 1 deletion foundation-models/sap-rpt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/spec/sap-rpt-1_openapi.json</inputSpec>
<inputSpec>${project.basedir}/src/main/resources/spec/sap-rpt_openapi.json</inputSpec>
<modelPackage>com.sap.ai.sdk.foundationmodels.rpt.generated.model</modelPackage>
<apiPackage>com.sap.ai.sdk.foundationmodels.rpt.generated.client</apiPackage>
<additionalProperties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.sap.ai.sdk.core.JacksonConfiguration.getDefaultObjectMapper;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.annotations.Beta;
import com.sap.ai.sdk.core.AiCoreService;
import com.sap.ai.sdk.core.DeploymentResolutionException;
Expand All @@ -14,6 +13,7 @@
import com.sap.cloud.sdk.cloudplatform.connectivity.Destination;
import com.sap.cloud.sdk.services.openapi.apache.apiclient.ApiClient;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Nonnull;
import lombok.AccessLevel;
Expand Down Expand Up @@ -107,10 +107,11 @@ public PredictResponsePayload tableCompletion(@Nonnull final PredictRequestPaylo
public PredictResponsePayload tableCompletion(
@Nonnull final File parquetFile, @Nonnull final PredictionConfig predictionConfig) {
try {
final var config =
JacksonConfiguration.getDefaultObjectMapper().writeValueAsString(predictionConfig);
return api.predictParquet(parquetFile, config);
} catch (JsonProcessingException e) {
final File tempFile = File.createTempFile("prediction-config", ".json");
tempFile.deleteOnExit();
JacksonConfiguration.getDefaultObjectMapper().writeValue(tempFile, predictionConfig);
return api.predictParquet(parquetFile, tempFile);
} catch (IOException e) {
throw new IllegalArgumentException("Failed to serialize PredictionConfig to JSON", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*/
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 Relational Pre-trained Transformer 1.5 model. */
public static final RptModel SAP_RPT_15 = new RptModel("sap-rpt-1.5", null);

/** SAP RPT 1 Large model. */
public static final RptModel SAP_RPT_1_LARGE = new RptModel("sap-rpt-1-large", null);
/** SAP Relational Pre-trained Transformer Large 1.5 model. */
public static final RptModel SAP_RPT_15_LARGE = new RptModel("sap-rpt-1.5-large", null);

/**
* Create a new instance of RptModel with the provided version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import javax.annotation.Nullable;

/**
* SAP-RPT-1 Tabular AI in version 0.1.0.
* SAP RPT in version 1.5.0.
*
* <p>A REST API for in-context learning with the SAP-RPT-1 model.
* <p>A REST API for in-context learning with SAP RPT models.
*/
public class DefaultApi extends BaseApi {

/**
* Instantiates this API class to invoke operations on the SAP-RPT-1 Tabular AI.
* Instantiates this API class to invoke operations on the SAP RPT.
*
* @param httpDestination The destination that API should be used with
*/
Expand All @@ -34,8 +34,8 @@ public DefaultApi(@Nonnull final Destination httpDestination) {
}

/**
* Instantiates this API class to invoke operations on the SAP-RPT-1 Tabular AI based on a given
* {@link ApiClient}.
* Instantiates this API class to invoke operations on the SAP RPT based on a given {@link
* ApiClient}.
*
* @param apiClient ApiClient to invoke the API on
*/
Expand All @@ -57,13 +57,53 @@ public DefaultApi withDefaultHeaders(@Nonnull final Map<String, String> defaultH
}

/**
* Make in-context predictions for specified target columns based on provided table data JSON
* (optionally gzip-compressed).
* Health Check
*
* <p>Make in-context predictions for specified target columns. Either \&quot;rows\&quot; or
* \&quot;columns\&quot; must be provided and must contain both context and query rows. You can
* optionally send gzip-compressed JSON payloads and set a \&quot;Content-Encoding: gzip\&quot;
* header.
* <p>
*
* <p><b>200</b> - Successful Response
*
* @return Object
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API
*/
@Nonnull
public Object health() throws OpenApiRequestException {

// create path and map variables
final String localVarPath = "/health";

final StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
final List<Pair> localVarQueryParams = new ArrayList<Pair>();
final List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
final Map<String, String> localVarHeaderParams = new HashMap<String, String>(defaultHeaders);
final Map<String, Object> localVarFormParams = new HashMap<String, Object>();

final String[] localVarAccepts = {"application/json"};
final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {};

final String localVarContentType = ApiClient.selectHeaderContentType(localVarContentTypes);

final TypeReference<Object> localVarReturnType = new TypeReference<Object>() {};

return apiClient.invokeAPI(
localVarPath,
"GET",
localVarQueryParams,
localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(),
null,
localVarHeaderParams,
localVarFormParams,
localVarAccept,
localVarContentType,
localVarReturnType);
}

/**
* Make predictions from JSON (optionally gzip-compressed).
*
* <p>
*
* <p><b>200</b> - Successful Prediction
*
Expand All @@ -75,12 +115,18 @@ public DefaultApi withDefaultHeaders(@Nonnull final Map<String, String> defaultH
*
* <p><b>500</b> - Internal Server Error
*
* @param predictRequestPayload The value for the parameter predictRequestPayload
* <p><b>503</b> - Service Unavailable
*
* @param predictRequestPayload (required) The value for the parameter predictRequestPayload
* @param contentEncoding (optional) Content encoding of the request body. Use &#39;gzip&#39; for
* gzip-compressed payloads. Use compression level 1.
* @return PredictResponsePayload
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API
*/
@Nonnull
public PredictResponsePayload predict(@Nonnull final PredictRequestPayload predictRequestPayload)
public PredictResponsePayload predict(
@Nonnull final PredictRequestPayload predictRequestPayload,
@Nullable final String contentEncoding)
throws OpenApiRequestException {

// verify the required parameter 'predictRequestPayload' is set
Expand All @@ -99,6 +145,9 @@ public PredictResponsePayload predict(@Nonnull final PredictRequestPayload predi
final Map<String, String> localVarHeaderParams = new HashMap<String, String>(defaultHeaders);
final Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (contentEncoding != null)
localVarHeaderParams.put("Content-Encoding", ApiClient.parameterToString(contentEncoding));

final String[] localVarAccepts = {"application/json"};
final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {"application/json"};
Expand All @@ -122,11 +171,36 @@ public PredictResponsePayload predict(@Nonnull final PredictRequestPayload predi
}

/**
* Make in-context predictions for specified target columns based on provided table data Parquet
* file.
* Make predictions from JSON (optionally gzip-compressed).
*
* <p>
*
* <p><b>200</b> - Successful Prediction
*
* <p><b>400</b> - Bad Request - Invalid input data
*
* <p><b>413</b> - Payload Too Large
*
* <p><b>422</b> - Validation Error
*
* <p><b>500</b> - Internal Server Error
*
* <p><b>503</b> - Service Unavailable
*
* @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 {
return predict(predictRequestPayload, null);
}

/**
* Make predictions from Parquet file
*
* <p>Make in-context predictions for specified target columns based on provided table data
* Parquet file.
* <p>
*
* <p><b>200</b> - Successful Prediction
*
Expand All @@ -138,17 +212,20 @@ public PredictResponsePayload predict(@Nonnull final PredictRequestPayload predi
*
* <p><b>500</b> - Internal Server Error
*
* @param _file (required) Parquet file containing the data
* @param predictionConfig (required) JSON string for prediction_config
* @param indexColumn (optional) Optional index column name
* @param parseDataTypes (optional, default to true) Whether to parse data types
* <p><b>503</b> - Service Unavailable
*
* @param _file (required) The value for the parameter _file
* @param predictionConfig (required) JSON string containing the prediction configuration (see
* PredictionConfig schema).
* @param indexColumn (optional) The value for the parameter indexColumn
* @param parseDataTypes (optional, default to false) The value for the parameter parseDataTypes
* @return PredictResponsePayload
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API
*/
@Nonnull
public PredictResponsePayload predictParquet(
@Nonnull final File _file,
@Nonnull final String predictionConfig,
@Nonnull final File predictionConfig,
@Nullable final String indexColumn,
@Nullable final Boolean parseDataTypes)
throws OpenApiRequestException {
Expand Down Expand Up @@ -204,11 +281,9 @@ public PredictResponsePayload predictParquet(
}

/**
* Make in-context predictions for specified target columns based on provided table data Parquet
* file.
* Make predictions from Parquet file
*
* <p>Make in-context predictions for specified target columns based on provided table data
* Parquet file.
* <p>
*
* <p><b>200</b> - Successful Prediction
*
Expand All @@ -220,14 +295,17 @@ public PredictResponsePayload predictParquet(
*
* <p><b>500</b> - Internal Server Error
*
* @param _file Parquet file containing the data
* @param predictionConfig JSON string for prediction_config
* <p><b>503</b> - Service Unavailable
*
* @param _file The value for the parameter _file
* @param predictionConfig JSON string containing the prediction configuration (see
* PredictionConfig schema).
* @return PredictResponsePayload
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API
*/
@Nonnull
public PredictResponsePayload predictParquet(
@Nonnull final File _file, @Nonnull final String predictionConfig)
@Nonnull final File _file, @Nonnull final File predictionConfig)
throws OpenApiRequestException {
return predictParquet(_file, predictionConfig, null, null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SAP-RPT-1 Tabular AI
* A REST API for in-context learning with the SAP-RPT-1 model.
* SAP RPT
* A REST API for in-context learning with SAP RPT models.
*
*
*
Expand All @@ -15,14 +15,45 @@
import com.fasterxml.jackson.annotation.JsonValue;
import javax.annotation.Nonnull;

/** Gets or Sets ColumnType */
/**
* Supported column data types for the data schema. Includes base types (string, numeric, date) and
* additional types derived from SAP CDS (https://cap.cloud.sap/docs/cds/types#core-built-in-types).
* Additional types are mapped to the corresponding base type internally. All values are lowercase
* for case-insensitive matching.
*/
public enum ColumnType {
STRING("string"),

NUMERIC("numeric"),

DATE("date"),

BOOLEAN("boolean"),

LARGESTRING("largestring"),

UUID("uuid"),

INTEGER("integer"),

INT16("int16"),

INT32("int32"),

INT64("int64"),

UINT8("uint8"),

DECIMAL("decimal"),

DOUBLE("double"),

TIME("time"),

DATETIME("datetime"),

TIMESTAMP("timestamp"),

UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");

private final String value;
Expand Down
Loading
Loading