Skip to content

Commit 2dea10a

Browse files
authored
Merge branch 'main' into spec-update/orchestration/v0.48.2
2 parents 6321f00 + 98facc1 commit 2dea10a

32 files changed

+1471
-101
lines changed

.github/workflows/pr-lint.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: lint pr
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
permissions:
11+
pull-requests: read
12+
13+
jobs:
14+
lint-pr:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: amannn/action-semantic-pull-request@v5
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
scopes: |
22+
Core
23+
OpenAI
24+
Orchestration
25+
DevOps
26+
headerPattern: '^(\w.+): (?:\[(\w.+)\] )?(.+)$'
27+
headerPatternCorrespondence: type, scope, subject
28+
# for available types, check:
29+
# https://github.com/commitizen/conventional-commit-types/blob/master/index.json
30+
subjectPatternError: |
31+
The subject "{subject}" found in the pull request title "{title}"
32+
didn't match the configured pattern. Please ensure that the subject
33+
starts with an uppercase character, e.g. "feat: New Feature".

.github/workflows/prepare-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
run: |
145145
COMMIT_URL=${{ github.event.repository.html_url }}/commit/${{ needs.bump-version.outputs.release-commit }}
146146
147-
PR_URL=$(gh pr create --title "Release ${{ needs.bump-version.outputs.release-version }}" --body "## TODOs
147+
PR_URL=$(gh pr create --title "feat: Release ${{ needs.bump-version.outputs.release-version }}" --body "## TODOs
148148
- [ ] Review the changes in [the release commit]($COMMIT_URL)
149149
- [ ] Review the [Draft Release](${{ needs.create-release.outputs.release-url }})
150150
- [ ] Review **and approve** this PR

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ Please refer to [this documentation](docs/guides/ORCHESTRATION_CHAT_COMPLETION.m
131131

132132
For more detailed information and advanced usage, please refer to the following:
133133

134-
- [Connecting to AI Core](docs/guides/CONNECTING_TO_AICORE.md)
135-
- [Orchestration Chat Completion](docs/guides/ORCHESTRATION_CHAT_COMPLETION.md)
136-
- [OpenAI Chat Completion](docs/guides/OPENAI_CHAT_COMPLETION.md)
137-
- [AI Core Deployment](docs/guides/AI_CORE_DEPLOYMENT.md)
134+
- [<img src="sample-code/spring-app/src/main/resources/static/BTP-Cockpit-Logo.png"/> Connecting to AI Core](docs/guides/CONNECTING_TO_AICORE.md)
135+
- [<img src="sample-code/spring-app/src/main/resources/static/Orchestration-Logo.png" width="16"/> Orchestration Chat Completion](docs/guides/ORCHESTRATION_CHAT_COMPLETION.md)
136+
- [<img src="sample-code/spring-app/src/main/resources/static/Open-AI-Logo.svg" width="16"/> OpenAI Chat Completion](docs/guides/OPENAI_CHAT_COMPLETION.md)
137+
- [<img src="https://spring.io/favicon-32x32.png" width="16"/> Spring AI Integration](docs/guides/SPRING_AI_INTEGRATION.md)
138+
- [🧰 AI Core Deployment](docs/guides/AI_CORE_DEPLOYMENT.md)
138139

139140
For updating versions, please refer to the [**Release Notes**](docs/release-notes/release-notes-0-to-14.md).
140141

docs/guides/AI_CORE_DEPLOYMENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ In addition to the prerequisites above, we assume you have already set up the fo
6666
```
6767
</details>
6868

69-
### Create a Deployment
69+
## Create a Deployment
7070

7171
Use the following code snippet to create a deployment in SAP AI Core:
7272

@@ -84,7 +84,7 @@ AiExecutionStatus status = deployment.getStatus();
8484

8585
Refer to the [DeploymentController.java](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/DeploymentController.java) in our Spring Boot application for a complete example.
8686

87-
### Delete a Deployment
87+
## Delete a Deployment
8888

8989
```java
9090
AiDeploymentCreationResponse deployment; // provided

docs/guides/OPENAI_CHAT_COMPLETION.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ In addition to the prerequisites above, we assume you have already set up the fo
8787

8888
</details>
8989

90-
### Simple chat completion
90+
## Simple chat completion
9191

9292
```java
9393
var result =
@@ -98,7 +98,7 @@ var result =
9898
String resultMessage = result.getContent();
9999
```
100100

101-
### Using a Custom Resource Group
101+
## Using a Custom Resource Group
102102

103103
```java
104104
var destination = new AiCoreService()
@@ -107,7 +107,7 @@ var destination = new AiCoreService()
107107
OpenAiClient.withCustomDestination(destination);
108108
```
109109

110-
### Message history
110+
## Message history
111111

112112
```java
113113
var systemMessage =
@@ -124,7 +124,7 @@ String resultMessage = result.getContent();
124124

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

127-
### Chat Completion with Specific Model Version
127+
## Chat Completion with Specific Model Version
128128

129129
By default, when no version is specified, the system selects one of the available deployments of the specified model, regardless of its version.
130130
To target a specific version, you can specify the model version along with the model.
@@ -134,7 +134,7 @@ OpenAiChatCompletionOutput result =
134134
OpenAiClient.forModel(GPT_35_TURBO.withVersion("1106")).chatCompletion(request);
135135
```
136136

137-
### Chat completion with Custom Model
137+
## Chat completion with Custom Model
138138

139139
You can also use a custom OpenAI model for chat completion by creating an `OpenAiModel` object.
140140

@@ -145,11 +145,11 @@ OpenAiChatCompletionOutput result =
145145

146146
Ensure that the custom model is deployed in SAP AI Core.
147147

148-
### Stream chat completion
148+
## Stream chat completion
149149

150150
It's possible to pass a stream of chat completion delta elements, e.g. from the application backend to the frontend in real-time.
151151

152-
#### Asynchronous Streaming
152+
### Asynchronous Streaming
153153

154154
This is a blocking example for streaming and printing directly to the console:
155155

@@ -168,7 +168,7 @@ try (Stream<String> stream = client.streamChatCompletion(msg)) {
168168
}
169169
```
170170

171-
#### Aggregating Total Output
171+
### Aggregating Total Output
172172

173173
The following example is non-blocking and demonstrates how to aggregate the complete response.
174174
Any asynchronous library can be used, such as the classic Thread API.
@@ -205,12 +205,10 @@ Integer tokensUsed = totalOutput.getUsage().getCompletionTokens();
205205
System.out.println("Tokens used: " + tokensUsed);
206206
```
207207

208-
#### Spring Boot example
209-
210208
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
211209
Boot's `ResponseBodyEmitter` to stream the chat completion delta messages to the frontend in real-time.
212210

213-
### Embedding
211+
## Embedding
214212

215213
Get the embeddings of a text input in list of float values:
216214

docs/guides/ORCHESTRATION_CHAT_COMPLETION.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var config = new OrchestrationModuleConfig()
8585

8686
Please also refer to [our sample code](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java) for this and all following code examples.
8787

88-
### Chat Completion
88+
## Chat Completion
8989

9090
Use the Orchestration service to generate a response to a user message:
9191

@@ -100,7 +100,7 @@ String messageResult = result.getContent();
100100
In this example, the Orchestration service generates a response to the user message "Hello world! Why is this phrase so famous?".
101101
The LLM response is available as the first choice under the `result.getOrchestrationResult()` object.
102102

103-
### Chat completion with Templates
103+
## Chat completion with Templates
104104

105105
Use a prepared template and execute requests with by passing only the input parameters:
106106

@@ -117,7 +117,7 @@ var result = client.chatCompletion(prompt, configWithTemplate);
117117

118118
In this case the template is defined with the placeholder `{{?language}}` which is replaced by the value `German` in the input parameters.
119119

120-
### Message history
120+
## Message history
121121

122122
Include a message history to maintain context in the conversation:
123123

@@ -134,7 +134,7 @@ var prompt = new OrchestrationPrompt(message).messageHistory(messagesHistory);
134134
var result = new OrchestrationClient().chatCompletion(prompt, config);
135135
```
136136

137-
### Chat completion filter
137+
## Chat completion filter
138138

139139
Apply content filtering to the chat completion:
140140

@@ -165,7 +165,7 @@ var configWithFilter = config.withInputFiltering(filterStrict).withOutputFilteri
165165
var result =
166166
new OrchestrationClient().chatCompletion(prompt, configWithFilter);
167167
```
168-
#### Behavior of Input and Output Filters
168+
### Behavior of Input and Output Filters
169169

170170
- **Input Filter**:
171171
If the input message violates the filter policy, a `400 (Bad Request)` response will be received during the `chatCompletion` call.
@@ -178,7 +178,7 @@ var result =
178178

179179
You will find [some examples](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java) in our Spring Boot application demonstrating response handling with filters.
180180

181-
### Data masking
181+
## Data masking
182182

183183
Use the data masking module to anonymize personal information in the input:
184184

@@ -201,7 +201,7 @@ var result =
201201

202202
In this example, the input will be masked before the call to the LLM and will remain masked in the output.
203203

204-
### Grounding
204+
## Grounding
205205

206206
Use the grounding module to provide additional context to the AI model.
207207

@@ -232,11 +232,11 @@ Use the grounding module to provide additional context to the AI model.
232232

233233
In this example, the AI model is provided with additional context in the form of grounding information. Note, that it is necessary to provide the grounding input via one or more input variables.
234234

235-
### Stream chat completion
235+
## Stream chat completion
236236

237237
It's possible to pass a stream of chat completion delta elements, e.g. from the application backend to the frontend in real-time.
238238

239-
#### Asynchronous Streaming
239+
### Asynchronous Streaming
240240

241241
This is a blocking example for streaming and printing directly to the console:
242242

@@ -253,12 +253,10 @@ try (Stream<String> stream = client.streamChatCompletion(prompt, config)) {
253253
}
254254
```
255255

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

261-
### Set model parameters
259+
## Set model parameters
262260

263261
Change your LLM configuration to add model parameters:
264262

@@ -272,7 +270,7 @@ OrchestrationAiModel customGPT4O =
272270
.withVersion("2024-05-13");
273271
```
274272

275-
### Using a Configuration from AI Launchpad
273+
## Using a Configuration from AI Launchpad
276274

277275
In case you have created a configuration in AI Launchpad, you can copy or download the configuration as JSON and use it directly in your code:
278276

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Spring AI Integration
2+
3+
## Table of Contents
4+
5+
- [Introduction](#introduction)
6+
- [Orchestration Chat Completion](#orchestration-chat-completion)
7+
- [Orchestration Masking](#orchestration-masking)
8+
9+
## Introduction
10+
11+
This guide provides examples of how to use our Spring AI integration with our clients in SAP AI Core
12+
for chat completion tasks using the SAP AI SDK for Java.
13+
14+
## Orchestration Chat Completion
15+
16+
The Orchestration client is integrated in Spring AI classes:
17+
18+
```java
19+
ChatModel client = new OrchestrationChatModel();
20+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
21+
OrchestrationChatOptions opts = new OrchestrationChatOptions(config);
22+
23+
Prompt prompt = new Prompt("What is the capital of France?", opts);
24+
ChatResponse response = client.call(prompt);
25+
```
26+
27+
Please
28+
find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/SpringAiOrchestrationController.java).
29+
30+
## Orchestration Masking
31+
32+
Configure Orchestration modules withing Spring AI:
33+
34+
```java
35+
ChatModel client = new OrchestrationChatModel();
36+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
37+
38+
val masking =
39+
DpiMasking.anonymization()
40+
.withEntities(DPIEntities.EMAIL, DPIEntities.ADDRESS, DPIEntities.LOCATION);
41+
42+
val opts = new OrchestrationChatOptions(config.withMaskingConfig(masking));
43+
val prompt =
44+
new Prompt(
45+
"Please write 'Hello World!' to me via email. My email address is [email protected]",
46+
opts);
47+
48+
ChatResponse response = client.call(prompt);
49+
```
50+
51+
Please
52+
find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/SpringAiOrchestrationController.java).

docs/release-notes/release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
### ✨ New Functionality
1616

1717
- New Orchestration features:
18+
- [Spring AI integration](../guides/ORCHESTRATION_CHAT_COMPLETION.md#spring-ai-integration)
1819
- Images are now supported as input in newly introduced `MultiChatMessage`.
1920
- `MultiChatMessage` also allows for multiple content items (text or image) in one object.
2021
- Grounding input can be masked with `DPIConfig`.

foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
/**
88
* OpenAI models that are available in AI Core.
99
*
10+
* <p>Please note that the template of models provided in this class might be outdated. To check the
11+
* latest availability of OpenAI models in AI Core, please refer to <a
12+
* href="https://me.sap.com/notes/3437766">SAP Availability of Generative AI Models </a>.
13+
*
1014
* @param name The name of the model.
1115
* @param version The version of the model (optional).
1216
*/

orchestration/pom.xml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
</developers>
3232
<properties>
3333
<project.rootdir>${project.basedir}/../</project.rootdir>
34-
<coverage.complexity>70%</coverage.complexity>
35-
<coverage.line>87%</coverage.line>
36-
<coverage.instruction>88%</coverage.instruction>
37-
<coverage.branch>65%</coverage.branch>
38-
<coverage.method>65%</coverage.method>
34+
<coverage.complexity>76%</coverage.complexity>
35+
<coverage.line>90%</coverage.line>
36+
<coverage.instruction>91%</coverage.instruction>
37+
<coverage.branch>69%</coverage.branch>
38+
<coverage.method>70%</coverage.method>
3939
<coverage.class>100%</coverage.class>
4040
</properties>
4141

@@ -54,7 +54,11 @@
5454
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
5555
<artifactId>connectivity-apache-httpclient5</artifactId>
5656
</dependency>
57-
57+
<dependency>
58+
<groupId>org.springframework.ai</groupId>
59+
<artifactId>spring-ai-core</artifactId>
60+
<optional>true</optional>
61+
</dependency>
5862
<dependency>
5963
<groupId>org.apache.httpcomponents.core5</groupId>
6064
<artifactId>httpcore5</artifactId>

0 commit comments

Comments
 (0)