Skip to content

Commit a73a9c1

Browse files
committed
Merge remote-tracking branch 'origin/main' into html-page-redesign
# Conflicts: # sample-code/spring-app/src/main/resources/static/index.html
2 parents b33d379 + 0d847d7 commit a73a9c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1848
-493
lines changed

.github/workflows/fosstars-report.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,13 @@ jobs:
3131
with:
3232
path: ${{ env.CVE_CACHE_DIR }}
3333
key: ${{ env.CVE_CACHE_KEY }}
34-
fail-on-cache-miss: true
34+
# fail-on-cache-miss: true
3535

3636
- name: "Build SDK"
3737
run: |
3838
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean install -DskipTests -DskipFormatting"
3939
mvn $MVN_ARGS
4040
41-
- name: "Fosstars Rating"
42-
43-
with:
44-
report-branch: fosstars-report
45-
token: ${{ secrets.GITHUB_TOKEN }}
46-
4741
- name: "CVE Scan"
4842
env:
4943
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
@@ -73,6 +67,13 @@ jobs:
7367
path: ${{ env.CVE_CACHE_DIR }}
7468
key: ${{ env.CVE_CACHE_KEY }}
7569

70+
# This action changes the active branch!
71+
- name: "Fosstars Rating"
72+
73+
with:
74+
report-branch: fosstars-report
75+
token: ${{ secrets.GITHUB_TOKEN }}
76+
7677
- name: "Slack Notification"
7778
if: failure()
7879
uses: slackapi/[email protected]

.pipeline/scripts/release_notes_automation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ def count_releases(filename):
6969
return count
7070

7171
def find_target_file(version):
72-
# release-notes-X-to-Y.mdx with every 15 versions the index increases by 15 and stays the same for 15 versions
72+
# release-notes-X-to-Y.md with every 15 versions the index increases by 15 and stays the same for 15 versions
7373
minor_version = int(version.split(".")[1])
7474
index = minor_version // 15 * 15
75-
return "release-notes-" + str(index) + "-to-" + str(index + 14) + ".mdx"
75+
return "release-notes-" + str(index) + "-to-" + str(index + 14) + ".md"
7676

7777
def write_release_notes(folder, target_file):
7878
absolute_target_file = os.path.join(folder, target_file)

.pipeline/scripts/release_notes_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020

2121
### 🐛 Fixed Issues
2222

23-
-
23+
-

README.md

Lines changed: 56 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ The SDK simplifies the setup and interaction with SAP AI Core, allowing you to f
1414
## Table of Contents
1515

1616
- [General Requirements](#general-requirements)
17-
- [Connecting to SAP AI Core](#connecting-to-sap-ai-core)
18-
- [Option 1: Set Credentials as Environment Variable](#option-1-set-ai-core-credentials)
19-
- [Option 2: Regular Service Binding in SAP BTP Cloud Foundry](#option-2-regular-service-binding-in-sap-btp-cloud-foundry)
20-
- [Option 3: Define and Use a Destination](#option-3-define-and-use-a-destination)
2117
- [Getting Started](#getting-started)
2218
- [What You'll Build](#what-youll-build)
2319
- [Prerequisites](#prerequisites)
24-
- [Write the Code](#write-the-code)
25-
- [Run and Test the Application Locally](#run-and-test-the-application-locally)
26-
- [Deploying to Cloud Foundry (Optional)](#deploying-to-cloud-foundry-optional)
20+
- [Use the Orchestration API](#use-the-orchestration-api)
21+
- [Run the Application Locally](#run-the-application-locally)
22+
- [Explore Further Capabilities](#explore-further-capabilities)
2723
- [Documentation](#documentation)
2824
- [FAQs](#faqs)
2925
- [Contribute, Support and Feedback](#contribute-support-and-feedback)
@@ -35,221 +31,103 @@ The SDK simplifies the setup and interaction with SAP AI Core, allowing you to f
3531

3632
To use the SDK in a Java application, it is necessary to understand the technical prerequisites and required versions for common dependencies.
3733

38-
- **SAP AI Core Service** enabled in your SAP BTP account.
39-
- [How to enable the AI Core service](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/initial-setup)
40-
- **SAP AI Core Credentials** to access the AI Core service.
41-
- [Connecting to SAP AI Core](#connecting-to-sap-ai-core)
34+
- Java 17 or higher.
35+
- Access to an **SAP AI Core Service** instance.
36+
37+
Please refer to [this documentation on **how to connect the SDK to AI Core**](docs/guides/CONNECTING_TO_AICORE.md).
4238

4339
The following table lists the required versions, based on the latest release:
4440

45-
| Dependency | Minimum Version | Recommended Version |
46-
| --- | --- | --- |
47-
| JDK | 17 (LTS) | 21 (LTS) |
48-
| SAP Cloud SDK | 5.6.0 | latest |
49-
| (optional) CAP Java | 3.0.0 | latest |
50-
| (optional) Spring Boot | 3.0 | latest |
41+
| Dependency | Minimum Version | Recommended Version |
42+
|------------------------|-----------------|---------------------|
43+
| JDK | 17 (LTS) | 21 (LTS) |
44+
| SAP Cloud SDK | 5.6.0 | latest |
45+
| (optional) CAP Java | 3.0.0 | latest |
46+
| (optional) Spring Boot | 3.0 | latest |
5147

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

54-
## Connecting to SAP AI Core
55-
56-
To interact with SAP AI Core services, the SAP AI SDK requires credentials available at application runtime.
57-
By default, the SDK automatically extracts these credentials from a service instance of type `aicore` bound to your application.
58-
59-
If running the application locally without this service binding, you may encounter an exception:
60-
61-
```
62-
Could not find any matching service bindings for service identifier 'aicore'
63-
```
64-
65-
There are multiple ways to provide these credentials:
66-
67-
| Option | Description |
68-
|--------|----------------------------------------------------------------------------------------------------------|
69-
| **1** | Create an `.env` file containing an `AICORE_SERVICE_KEY={...}` |
70-
| **2** | Regular service binding in SAP BTP Cloud Foundry (results in `VCAP_SERVICES` environment variable entry) |
71-
| **3** | Define and use a _Destination_ in the SAP BTP Destination Service |
72-
73-
Additional methods (not recommended for production):
74-
75-
- Use the [hybrid testing](https://cap.cloud.sap/docs/advanced/hybrid-testing#services-on-cloud-foundry) approach for
76-
CAP applications (e.g., `cds bind --to aicore --exec mvn spring-boot:run`)
77-
- Leverage a "user-provided" service binding
78-
- Define and use a custom `ServiceBinding` or `ServiceBindingAccessor` in your application
79-
80-
### Option 1: Set AI Core Credentials
81-
82-
<details>
83-
<summary>Click to view detailed steps</summary>
84-
85-
86-
**1. Obtain Service Credentials:**
87-
88-
- Log into the **SAP BTP Cockpit**
89-
- Navigate to **Services** -> **Instances and Subscriptions** -> **Instances** -> **AI Core**
90-
- Click **View Credentials** and copy the JSON content
91-
92-
**2. Create `.env` file:**
50+
## Getting Started
9351

94-
- Create an `.env` file in the root directory of your application
95-
- Add a **one line** entry `AICORE_SERVICE_KEY={...}` with the copied JSON
52+
### What You'll Build
9653

97-
<details>
98-
<summary>Set an environment variable instead of .env</summary>
54+
In this quickstart, you'll use the OpenAI GPT-4o model through the [Orchestration Service of AI Core](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/orchestration) for generating text.
55+
The application will send a prompt to the AI model and display the generated response.
9956

100-
**2. Set an Environment Variable: (alternative)**
57+
### Prerequisites
10158

102-
- In your IDE or terminal, set the environment variable `AICORE_SERVICE_KEY` with the copied JSON content
59+
This quickstart assumes you have a **deployment of the Orchestration service available** in the `default` resource group of your AI Core instance.
60+
If you don't have a deployment yet, please refer to [this guide](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/create-deployment-for-orchestration) on how to create one.
10361

104-
ℹ️ The environment variable has priority over the `.env` file.
62+
### Add the SDK as a Dependency
10563

106-
Example Linux/MacOS:
64+
Add the following dependency to your `pom.xml` file:
10765

108-
```shell
109-
export AICORE_SERVICE_KEY='{ "clientid": "...", "clientsecret": "...", "url": "...", "serviceurls": { "AI_API_URL": "..." } }'
66+
```xml
67+
<dependency>
68+
<groupId>com.sap.ai.sdk</groupId>
69+
<artifactId>orchestration</artifactId>
70+
<!-- Use the latest version here -->
71+
<version>${ai-sdk.version}</version>
72+
</dependency>
11073
```
11174

112-
Example Windows:
113-
114-
```shell
115-
$env:AICORE_SERVICE_KEY='{ "clientid": "...", "clientsecret": "...", "url": "...", "serviceurls": { "AI_API_URL": "..." } }'
116-
```
117-
118-
</details>
119-
</details>
120-
121-
### Option 2: Regular Service Binding in SAP BTP Cloud Foundry
122-
123-
<details>
124-
<summary>Click to view detailed steps</summary>
125-
126-
127-
**1. Bind an existing `aicore` service instance to your application**
75+
### Use the Orchestration API
12876

129-
SAP BTP provides multiple ways to do this:
77+
We'll use a `client` to interact with the Orchestration service:
13078

131-
- Using the web interface
132-
- Using the CLI
133-
- Using MTA or manifest files
134-
135-
[Learn more about binding service instances to applications](https://help.sap.com/docs/btp/sap-business-technology-platform/binding-service-instances-to-applications)
136-
137-
After restarting your application, you should see an "aicore" entry in the `VCAP_SERVICES` environment variable:
138-
139-
```json
140-
{
141-
"aicore": [
142-
{
143-
"clientid": "...",
144-
"clientsecret": "...",
145-
"url": "...",
146-
"serviceurls": {
147-
"AI_API_URL": "..."
148-
}
149-
}
150-
]
151-
}
79+
```java
80+
var client = new OrchestrationClient();
15281
```
15382

154-
</details>
155-
156-
### Option 3: Define and Use a Destination
157-
158-
<details>
159-
<summary>Click to view detailed steps</summary>
160-
161-
**1. Obtain Service Credentials:** (Same as in Option 1)
162-
163-
**2. Create a Destination:**
164-
165-
- In the **SAP BTP Cockpit**, go to **Connectivity** -> **Destinations**
166-
- Click **New Destination** and configure:
167-
168-
- **Name**: `my-aicore`
169-
- **Type**: `HTTP`
170-
- **URL**: `[serviceurls.AI_API_URL]`
171-
- **Proxy Type**: `Internet`
172-
- **Authentication**: `OAuth2ClientCredentials`
173-
- **Client ID**: `[clientid]`
174-
- **Client Secret**: `[clientsecret]`
175-
- **Token Service URL Type**: `Dedicated`
176-
- **Token Service URL**: `[url]`
177-
178-
**3. Use the Destination in Your Application:**
83+
Next, we'll specify the model we want to use:
17984

18085
```java
181-
Destination destination = DestinationAccessor.getDestination("my-aicore");
182-
AiCoreService aiCoreService = new AiCoreService().withDestination(destination);
183-
DeploymentApi client = new DeploymentApi(aiCoreService);
86+
var config = new OrchestrationModuleConfig()
87+
.withLlmConfig(OrchestrationAiModel.GPT_4O);
18488
```
18589

186-
</details>
187-
188-
## Getting Started
189-
190-
### What You'll Build
191-
192-
In this quickstart, you'll build a simple Spring Boot application that uses the OpenAI GPT-3.5 Turbo model for chat completion.
193-
The application will send a prompt to the AI model and display the generated response.
194-
195-
### Prerequisites
90+
Now we can create our first prompt:
19691

197-
Before you begin, ensure you have:
92+
```java
93+
var prompt = new OrchestrationPrompt("Hello world! Why is this phrase so famous?");
19894

199-
- Met the [General Requirements](#general-requirements).
200-
- Met the OpenAI Chat Completion module specific requirements
201-
- Refer to [Prerequisites for OpenAI Chat Completion](docs/guides/OPENAI_CHAT_COMPLETION.md#prerequisites)
202-
- Set up the AI Core credentials
203-
using [(1) Environment variable or env-file](#option-1-set-ai-core-credentials)
204-
or [(2) Regular Service Binding](#option-2-regular-service-binding-in-sap-btp-cloud-foundry).
205-
- Deployed the OpenAI GPT-3.5 Turbo model in SAP AI Core.
206-
- Refer to [Deploying the OpenAI GPT-3.5 Turbo Model](docs/guides/OPENAI_CHAT_COMPLETION.md#usage)
95+
var result = client.chatCompletion(prompt, config).getContent();
96+
```
20797

208-
### Write the Code
98+
The result will be the text generated by the AI model.
20999

210-
Add the following code to the controller or service class in your Spring Boot application:
100+
### Run the Application Locally
211101

212-
```java
213-
// Initialize the client for GPT-3.5 Turbo model
214-
OpenAiClient client = OpenAiClient.forModel(OpenAiModel.GPT_35_TURBO);
215-
216-
// Perform chat completion
217-
OpenAiChatCompletionOutput result =
218-
client
219-
.withSystemPrompt("You are a helpful assistant.")
220-
.chatCompletion("Hello World! Why is this phrase so famous?");
221-
```
102+
In order to run the application locally, you need to provide credentials for your AI Core service instance.
222103

223-
### Run and Test the Application Locally
224-
225-
Then, compile and run your application:
104+
For this example we'll use a **service key** and pass it as an **environment variable** to the application.
226105

227106
```shell
228107
cd your-spring-app/
229108

230-
mvn compile
109+
# assuming a bash, for other shells (e.g. PowerShell) see the below documentation
110+
export AICORE_SERVICE_KEY='{ "clientid": "...", "clientsecret": "...", "url": "...", "serviceurls": { "AI_API_URL": "..." } }'
111+
112+
# assuming Maven and a Spring Boot application
231113
mvn spring-boot:run
232114
```
233115

234-
### Deploying to Cloud Foundry (Optional)
235-
236-
When deploying your productive application to Cloud Foundry, it is recommended to use **service binding** to provide the AI Core credentials as per [Option 2](#option-2-regular-service-binding-in-sap-btp-cloud-foundry).
116+
Please find **detailed instructions** and more examples [in this documentation](docs/guides/CONNECTING_TO_AICORE.md#using-the-aicore_service_key-environment-variable).
237117

238-
Build your application using Maven and deploy it to Cloud Foundry:
118+
### Explore Further Capabilities
239119

240-
```shell
241-
cf push
242-
```
243-
244-
That's it!
245-
Your application should now be running on Cloud Foundry, and the AI Core credentials are provided securely via service binding.
120+
Check out the options available for the `OrchestrationPrompt` and `OrchestrationModuleConfig` classes.
121+
You can use templating, content filtering, data masking and more.
122+
Please refer to [this documentation](docs/guides/ORCHESTRATION_CHAT_COMPLETION.md) for more information.
246123

247124
## Documentation
248125

249126
For more detailed information and advanced usage, please refer to the following:
250127

251-
- [OpenAI Chat Completion](docs/guides/OPENAI_CHAT_COMPLETION.md)
128+
- [Connecting to AI Core](docs/guides/CONNECTING_TO_AICORE.md)
252129
- [Orchestration Chat Completion](docs/guides/ORCHESTRATION_CHAT_COMPLETION.md)
130+
- [OpenAI Chat Completion](docs/guides/OPENAI_CHAT_COMPLETION.md)
253131
- [AI Core Deployment](docs/guides/AI_CORE_DEPLOYMENT.md)
254132

255133
## FAQs

0 commit comments

Comments
 (0)