Skip to content

Commit

Permalink
Renamed e2e-test-app to sample-code/spring-app (#61)
Browse files Browse the repository at this point in the history
* Renamed `e2e-test-app` to `sample-code/spring-app`

* Added relativePath
  • Loading branch information
CharlesDuboisSAP authored Sep 18, 2024
1 parent d43eaf2 commit cf2b8f3
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ jobs:
- name: "Run tests"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} surefire:test -pl :e2e-test-app -DskipTests=false"
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} surefire:test -pl :spring-app -DskipTests=false"
mvn $MVN_ARGS
env:
# See "End-to-end test application instructions" on the README.md to update the secret
AICORE_SERVICE_KEY: ${{ secrets.AICORE_SERVICE_KEY }}

- name: "Start Application Locally"
run: |
cd e2e-test-app
cd sample-code/spring-app
mvn spring-boot:run &
timeout=15
while ! nc -z localhost 8080; do
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ We maintain [a list of currently available and tested AI Core APIs](docs/list-of
- Java 17 or higher
- Maven 3.9 or higher
- if Spring Boot is used, then minimum version 3
- [Set the AI Core credentials as an environment variable for local testing](#set-ai-core-credentials-as-environment-variable)
- [Set the AI Core credentials as an environment variable for local testing](#set-credentials-as-dedicated-environment-variable)

### Maven dependencies

Expand All @@ -67,7 +67,7 @@ Add the following dependencies to your `pom.xml` file:
</dependencies>
```

See [an example pom in our Spring Boot application](e2e-test-app/pom.xml)
See [an example pom in our Spring Boot application](sample-code/spring-app/pom.xml)

### Create a Deployment

Expand All @@ -88,7 +88,7 @@ public AiDeploymentCreationResponse createDeployment() {
}
```

See [an example in our Spring Boot application](e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java)
See [an example in our Spring Boot application](sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java)

### Delete a Deployment

Expand All @@ -110,7 +110,7 @@ public AiDeploymentDeletionResponse deleteDeployment(AiDeploymentCreationRespons
}
```

See [an example in our Spring Boot application](e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java)
See [an example in our Spring Boot application](sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java)

## OpenAI chat completion

Expand Down Expand Up @@ -161,7 +161,7 @@ See [an example in our Spring Boot application](e2e-test-app/src/main/java/com/s
- Java 17 or higher
- Maven 3.9 or higher
- if Spring Boot is used, then minimum version 3
- [Set the AI Core credentials as an environment variable for local testing](#set-ai-core-credentials-as-environment-variable)
- [Set the AI Core credentials as an environment variable for local testing](#set-credentials-as-dedicated-environment-variable)

### Maven dependencies

Expand All @@ -177,7 +177,7 @@ Add the following dependencies to your `pom.xml` file:
</dependencies>
```

See [an example pom in our Spring Boot application](e2e-test-app/pom.xml)
See [an example pom in our Spring Boot application](sample-code/spring-app/pom.xml)

### Simple chat completion

Expand Down Expand Up @@ -206,7 +206,7 @@ final OpenAiChatCompletionOutput result =
final String resultMessage = result.getContent();
```

See [an example in our Spring Boot application](e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java)
See [an example in our Spring Boot application](sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java)

### Chat completion with a model not defined in `OpenAiModel`

Expand Down Expand Up @@ -273,7 +273,7 @@ System.out.println("Tokens: " + tokens);

#### Spring Boot example

Please find [an example in our Spring Boot application](e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java).
Please find [an example in our Spring Boot application](sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java).
It shows the usage of Spring Boot's `ResponseBodyEmitter` to stream the chat completion delta messages to the frontend in real-time.

## Orchestration chat completion
Expand Down Expand Up @@ -309,7 +309,7 @@ It shows the usage of Spring Boot's `ResponseBodyEmitter` to stream the chat com
- Java 17 or higher
- Maven 3.9 or higher
- if Spring Boot is used, then minimum version 3
- [Set the AI Core credentials as an environment variable for local testing](#set-ai-core-credentials-as-environment-variable)
- [Set the AI Core credentials as an environment variable for local testing](#set-credentials-as-dedicated-environment-variable)

### Maven dependencies

Expand All @@ -325,7 +325,7 @@ Add the following dependencies to your `pom.xml` file:
</dependencies>
```

See [an example pom in our Spring Boot application](e2e-test-app/pom.xml)
See [an example pom in our Spring Boot application](sample-code/spring-app/pom.xml)

### Chat completion template

Expand Down Expand Up @@ -355,7 +355,7 @@ final String messageResult =
result.getOrchestrationResult().getChoices().get(0).getMessage().getContent();
```

See [an example in our Spring Boot application](e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java)
See [an example in our Spring Boot application](sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java)

### Messages history

Expand Down Expand Up @@ -390,7 +390,7 @@ final String messageResult =
result.getOrchestrationResult().getChoices().get(0).getMessage().getContent();
```

See [an example in our Spring Boot application](e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java)
See [an example in our Spring Boot application](sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java)

### Chat completion filter

Expand Down Expand Up @@ -454,7 +454,7 @@ final String messageResult =
result.getOrchestrationResult().getChoices().get(0).getMessage().getContent();
```

See [an example in our Spring Boot application](e2e-test-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java)
See [an example in our Spring Boot application](sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java)


### Set model parameters
Expand Down Expand Up @@ -571,7 +571,7 @@ export AICORE_SERVICE_KEY='{ "serviceurls": { "AI_API_URL": ...'
### Run the Spring Boot test application

```shell
cd e2e-test-app
cd sample-code/spring-app
mvn spring-boot:run
```

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<module>core</module>
<module>orchestration</module>
<module>foundation-models/openai</module>
<module>e2e-test-app</module>
<module>sample-code/spring-app</module>
</modules>
<distributionManagement>
<repository>
Expand Down Expand Up @@ -133,7 +133,7 @@
</dependency>
<dependency>
<groupId>com.sap.ai.sdk.app</groupId>
<artifactId>e2e-test-app</artifactId>
<artifactId>spring-app</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Expand Down
20 changes: 20 additions & 0 deletions sample-code/spring-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Sample Code and E2E Test

![e2e-test](https://github.com/SAP/ai-sdk-java/actions/workflows/e2e-test.yaml/badge.svg)

Sample code to demonstrate the usage of the SAP AI SDK.
Also used as basis for running E2E tests.

## Build, Run, Deploy Locally

Build the project with:

1. `mvn compile`
2. [Download a service key for your AI Core service instance](../../README.md#set-credentials-as-dedicated-environment-variable)
3. Create the environment variable `AICORE_SERVICE_KEY`
4. Run the application with `mvn spring-boot:run`
5. [See all available endpoints](localhost:8080)

## Run the E2E Test

Trigger the [GitHub Action](https://github.com/SAP/ai-sdk-java/actions/workflows/e2e-test.yml).
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
applications:
- name: e2e-app-java
random-route: true
path: target/e2e-test-app.jar
path: target/spring-app.jar
env:
JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 21.+ } }'
buildpacks:
Expand Down
3 changes: 2 additions & 1 deletion e2e-test-app/pom.xml → sample-code/spring-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<groupId>com.sap.ai.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>com.sap.ai.sdk.app</groupId>
<artifactId>e2e-test-app</artifactId>
<artifactId>spring-app</artifactId>
<name>End-to-end test application</name>
<description>Spring Boot application that tests AI clients when deployed in BTP.</description>

Expand Down

0 comments on commit cf2b8f3

Please sign in to comment.