Skip to content

Commit ad2b83b

Browse files
Better documentation
1 parent 5f6a163 commit ad2b83b

File tree

4 files changed

+54
-18
lines changed

4 files changed

+54
-18
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ For more detailed information and advanced usage, please refer to the following:
134134
- [Connecting to AI Core](docs/guides/CONNECTING_TO_AICORE.md)
135135
- [Orchestration Chat Completion](docs/guides/ORCHESTRATION_CHAT_COMPLETION.md)
136136
- [OpenAI Chat Completion](docs/guides/OPENAI_CHAT_COMPLETION.md)
137+
- [Spring AI Integration](docs/guides/SPRING_AI_INTEGRATION.md)
137138
- [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).

docs/guides/ORCHESTRATION_CHAT_COMPLETION.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
- [Grounding](#grounding)
1414
- [Stream chat completion](#stream-chat-completion)
1515
- [Set Model Parameters](#set-model-parameters)
16-
- [Spring AI Integration](#spring-ai-integration)
1716
- [Using a Configuration from AI Launchpad](#using-a-configuration-from-ai-launchpad)
1817

1918
## Introduction
@@ -271,22 +270,6 @@ OrchestrationAiModel customGPT4O =
271270
.withVersion("2024-05-13");
272271
```
273272

274-
## Spring AI Integration
275-
276-
The Orchestration client is integrated in Spring AI classes:
277-
278-
```java
279-
ChatModel client = new OrchestrationChatModel();
280-
OrchestrationModuleConfig config =
281-
new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
282-
OrchestrationChatOptions opts = new OrchestrationChatOptions(config);
283-
284-
Prompt prompt = new Prompt("What is the capital of France?", opts);
285-
ChatResponse response = client.call(prompt);
286-
```
287-
288-
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/SpringAiOrchestrationController.java).
289-
290273
## Using a Configuration from AI Launchpad
291274

292275
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:
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 foo.bar@baz.ai",
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).

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/SpringAiOrchestrationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public ChatResponse completion() {
4444
@Nonnull
4545
public ChatResponse template() {
4646
val template = new PromptTemplate("{input}");
47-
val prompt = template.create(Map.of("input", "Hello World!"), defaultOptions);
47+
val prompt = template.create(Map.of("input", "What is the capital of France?"), defaultOptions);
4848

4949
return client.call(prompt);
5050
}

0 commit comments

Comments
 (0)