generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 16
feat: [DevOps] Poc RPT #732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rpanackal
wants to merge
25
commits into
main
Choose a base branch
from
poc-rpt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4a88b37
Drafting yaml response part
rpanackal 8363a6f
Reorganize and add more spec components
rpanackal 920963f
Draft full request and response components in spec
rpanackal 53d8fa8
Setting up new sap-rpt sub-module
rpanackal 3d4c979
Minor component renaming
rpanackal faa656a
Complete working draft with e2e test
rpanackal 1931444
Unit test coverage
rpanackal 65ce38c
Use office beta spec file
rpanackal 47b981c
disable wire logs
rpanackal 70d0234
Prevent serialization of null
rpanackal ff33f98
Merge remote-tracking branch 'origin/main' into poc-rpt
rpanackal 80c6167
Merge remote-tracking branch 'origin/main' into poc-rpt
rpanackal b580486
Disable /predict_parquet
rpanackal 640a57a
pmd and checkstyle
rpanackal 1d1e851
Update version
rpanackal d8d56f6
Update dependency management
rpanackal 5fd47b6
Merge branch 'main' into poc-rpt
rpanackal ee539a0
Mark the new module non-release
rpanackal 58a8bfb
Fix coverage nums and javadoc
rpanackal 50fdd4e
Merge branch 'refs/heads/main' into poc-rpt
rpanackal b2f5255
Regenerate with Apache HttpClient
rpanackal 5e94444
Update generated config
rpanackal 7a7fee7
tabCompletion -> tableCompletion
rpanackal 114bf89
spec update workflow
CharlesDuboisSAP fd935ec
fix filename
CharlesDuboisSAP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>com.sap.ai.sdk</groupId> | ||
| <artifactId>sdk-parent</artifactId> | ||
| <version>1.16.0-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
| <groupId>com.sap.ai.sdk.foundationmodels</groupId> | ||
| <artifactId>sap-rpt</artifactId> | ||
| <name>SAP RPT Model Client</name> | ||
| <description>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.</description> | ||
| <url>https://github.com/SAP/ai-sdk-java?tab=readme-ov-file#documentation</url> | ||
| <organization> | ||
| <name>SAP SE</name> | ||
| <url>https://www.sap.com</url> | ||
| </organization> | ||
| <licenses> | ||
| <license> | ||
| <name>The Apache Software License, Version 2.0</name> | ||
| <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
| </license> | ||
| </licenses> | ||
| <developers> | ||
| <developer> | ||
| <name>SAP</name> | ||
| <email>cloudsdk@sap.com</email> | ||
| <organization>SAP SE</organization> | ||
| <organizationUrl>https://www.sap.com</organizationUrl> | ||
| </developer> | ||
| </developers> | ||
| <scm> | ||
| <connection>scm:git:git://github.com/SAP/ai-sdk-java.git</connection> | ||
| <developerConnection>scm:git:ssh://github.com:SAP/ai-sdk-java.git</developerConnection> | ||
| <url>https://github.com/SAP/ai-sdk-java/tree/main</url> | ||
| </scm> | ||
| <properties> | ||
| <project.rootdir>${project.basedir}/../../</project.rootdir> | ||
| <coverage.complexity>83%</coverage.complexity> | ||
| <coverage.line>77%</coverage.line> | ||
| <coverage.instruction>82%</coverage.instruction> | ||
| <coverage.branch>100%</coverage.branch> | ||
| <coverage.method>83%</coverage.method> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.sap.ai.sdk</groupId> | ||
| <artifactId>core</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.sap.cloud.sdk.cloudplatform</groupId> | ||
| <artifactId>cloudplatform-connectivity</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.sap.cloud.sdk.datamodel</groupId> | ||
| <artifactId>openapi-core</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-core</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-annotations</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.code.findbugs</groupId> | ||
| <artifactId>jsr305</artifactId> | ||
| </dependency> | ||
| <!-- scope "provided" --> | ||
| <dependency> | ||
| <groupId>org.projectlombok</groupId> | ||
| <artifactId>lombok</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <!-- scope "test" --> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.wiremock</groupId> | ||
| <artifactId>wiremock</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.sap.cloud.sdk.cloudplatform</groupId> | ||
| <artifactId>connectivity-apache-httpclient5</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| <profiles> | ||
| <profile> | ||
| <id>generate</id> | ||
| <activation> | ||
| <activeByDefault>false</activeByDefault> | ||
| <property> | ||
| <name>generate</name> | ||
| </property> | ||
| </activation> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>com.sap.cloud.sdk.datamodel</groupId> | ||
| <artifactId>openapi-generator-maven-plugin</artifactId> | ||
| <configuration> | ||
| <outputDirectory>${project.basedir}/src/main/java</outputDirectory> | ||
| <enableOneOfAnyOfGeneration>true</enableOneOfAnyOfGeneration> | ||
| <compileScope>COMPILE</compileScope> | ||
| <deleteOutputDirectory>true</deleteOutputDirectory> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <id>sap-rpt</id> | ||
| <goals> | ||
| <goal>generate</goal> | ||
| </goals> | ||
| <phase>generate-sources</phase> | ||
| <configuration> | ||
| <inputSpec>${project.basedir}/src/main/resources/spec/sap-rpt-1_openapi.json</inputSpec> | ||
| <modelPackage>com.sap.ai.sdk.foundationmodels.rpt.generated.model</modelPackage> | ||
| <apiPackage>com.sap.ai.sdk.foundationmodels.rpt.generated.client</apiPackage> | ||
| <additionalProperties> | ||
| <library>apache-httpclient</library> | ||
| <pojoBuilderMethodName>create</pojoBuilderMethodName> | ||
| <pojoConstructorVisibility>protected</pojoConstructorVisibility> | ||
| <enumUnknownDefaultCase>true</enumUnknownDefaultCase> | ||
| <useOneOfInterfaces>true</useOneOfInterfaces> | ||
| <useOneOfCreators>true</useOneOfCreators> | ||
| <useFloatArrays>true</useFloatArrays> | ||
| <excludePaths>/predict_parquet</excludePaths> | ||
| </additionalProperties> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
| </project> | ||
68 changes: 68 additions & 0 deletions
68
foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. * | ||
| * | ||
| * <p><b>200</b> - Successful response with predictive insights. | ||
| * | ||
| * <p><b>400</b> - Bad Request - Invalid input. | ||
| * | ||
| * <p><b>422</b> - Unprocessable Content - Invalid input. | ||
| * | ||
| * <p><b>500</b> - Internal Server Error. | ||
| * | ||
| * @param requestBody The prediction request | ||
| * @return prediction response from the RPT model | ||
| */ | ||
| @Nonnull | ||
| public PredictResponsePayload tableCompletion(@Nonnull final PredictRequestPayload requestBody) { | ||
| return api.predict(requestBody); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
foundation-models/sap-rpt/src/main/java/com/sap/ai/sdk/foundationmodels/rpt/RptModel.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try with and without
pojoBuildMethodNameAdd
<pojoConstructorVisibility>protected</pojoConstructorVisibility>Add
<aiSdkConstructor>true</aiSdkConstructor>Try with and without
removeOperationIdPrefixTry with and without
fixResponseSchemaTitlesUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added
<pojoConstructorVisibility>protected</pojoConstructorVisibility><pojoBuildMethodName>is not irrelevant since we have a curried builder.<aiSdkConstructor>true</aiSdkConstructor>is not relevant when you want a deployment's url for some particular model and not anAiCoreServiceinstance pointing atAI_API_URLfromAICORE_SERVICE_KEY<removeOperationIdPrefix>is relevant only when a very long"operationId"is specified in spec. Also not relevant for provided spec.<fixResponseSchemaTitles>is used when generator creates pojo classes likeInlineObject1,InlineObject2etc and loses ordering on regeneration. That is not the case here but maybe in future this becomes relevant.