Skip to content

Commit 55a8cf1

Browse files
committed
Merge branch 'main' into Using-Prompt-Registry-Templates-in-SpringAi
2 parents 4c88656 + e366acb commit 55a8cf1

18 files changed

+560
-240
lines changed

.github/workflows/continuous-integration.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
continuous-integration:
1717
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
1820
steps:
1921

2022
- name: "Checkout repository"

.github/workflows/dependency-test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env:
1010
jobs:
1111
fetch-dependency-versions:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: none
1315
outputs:
1416
versions: ${{ steps.fetch-versions.outputs.VERSIONS }}
1517

@@ -39,6 +41,8 @@ jobs:
3941
runs-on: ubuntu-latest
4042
outputs:
4143
cache-key: ${{ steps.cache-build.outputs.cache-key }}
44+
permissions:
45+
contents: read
4246
steps:
4347
- name: "Checkout repository"
4448
uses: actions/checkout@v4
@@ -75,6 +79,8 @@ jobs:
7579
matrix:
7680
version: ${{ fromJson(needs.fetch-dependency-versions.outputs.versions) }}
7781
continue-on-error: true
82+
permissions:
83+
contents: read
7884
steps:
7985
- name: "Checkout repository"
8086
uses: actions/checkout@v4

.github/workflows/deploy-snapshot.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ on:
77

88
jobs:
99
deploy-snapshot:
10-
name: Deploy Snapshot
10+
name: "Deploy Snapshot"
1111
runs-on: ubuntu-latest
1212
timeout-minutes: 15
13+
permissions:
14+
contents: read
1315
steps:
1416
- name: "Checkout Repository"
1517
uses: actions/checkout@v4

.github/workflows/e2e-test.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env:
1010

1111
jobs:
1212
end-to-end-tests:
13+
permissions:
14+
contents: read
1315
strategy:
1416
fail-fast: false
1517
matrix:
@@ -41,6 +43,12 @@ jobs:
4143
- name: "Run tests"
4244
id: run_tests
4345
run: |
46+
if [ "${{ matrix.environment }}" = "canary" ]; then
47+
export AICORE_SERVICE_KEY="${{ secrets.AI_CORE_CANARY }}"
48+
else
49+
export AICORE_SERVICE_KEY="${{ secrets.AI_CORE_PRODUCTION }}"
50+
fi
51+
4452
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} surefire:test -pl :spring-app -DskipTests=false"
4553
mvn $MVN_ARGS "-Daicore.landscape=${{ matrix.environment }}" | tee mvn_output.log # tee writes to both the console and a file
4654
@@ -60,10 +68,17 @@ jobs:
6068
fi
6169
env:
6270
# See "End-to-end test application instructions" on the README.md to update the secret
63-
AICORE_SERVICE_KEY: ${{ secrets[matrix.secret-name] }}
71+
AI_CORE_PRODUCTION: ${{ secrets.production }}
72+
AI_CORE_CANARY: ${{ secrets.canary }}
6473

6574
- name: "Start Application Locally"
6675
run: |
76+
if [ "${{ matrix.environment }}" = "canary" ]; then
77+
export AICORE_SERVICE_KEY="${{ secrets.AI_CORE_CANARY }}"
78+
else
79+
export AICORE_SERVICE_KEY="${{ secrets.AI_CORE_PRODUCTION }}"
80+
fi
81+
6782
cd sample-code/spring-app
6883
mvn spring-boot:run &
6984
timeout=15
@@ -77,7 +92,8 @@ jobs:
7792
done
7893
env:
7994
# See "End-to-end test application instructions" on the README.md to update the secret
80-
AICORE_SERVICE_KEY: ${{ secrets[matrix.secret-name] }}
95+
AI_CORE_PRODUCTION: ${{ secrets.production }}
96+
AI_CORE_CANARY: ${{ secrets.canary }}
8197

8298
- name: "Health Check"
8399
# print response body with headers to stdout. q:body only O:print -:stdout S:headers

.github/workflows/fosstars-report.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ env:
1313

1414
jobs:
1515
create_fosstars_report:
16-
runs-on: ubuntu-latest
1716
name: "Security rating"
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
actions: write
1821
steps:
1922
- name: "Checkout repository"
2023
uses: actions/checkout@v4

.github/workflows/prepare-release.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
release-commit: ${{ steps.prepare-release.outputs.RELEASE_COMMIT_ID }}
2929
release-tag: ${{ steps.prepare-release.outputs.TAG_NAME }}
3030
runs-on: ubuntu-latest
31+
permissions:
32+
contents: write
3133
steps:
3234
- name: "Checkout Repository"
3335
uses: actions/checkout@v4
@@ -155,6 +157,9 @@ jobs:
155157
outputs:
156158
pr-url: ${{ steps.create-release-notes-pr.outputs.PR_URL }}
157159
runs-on: ubuntu-latest
160+
permissions:
161+
contents: write
162+
pull-requests: write
158163
steps:
159164
- name: "Checkout Code Repository"
160165
uses: actions/checkout@v4
@@ -233,6 +238,9 @@ jobs:
233238
outputs:
234239
pr-url: ${{ steps.create-code-pr.outputs.PR_URL }}
235240
runs-on: ubuntu-latest
241+
permissions:
242+
contents: write
243+
pull-requests: write
236244
steps:
237245
- name: "Checkout Repository"
238246
uses: actions/checkout@v4

.github/workflows/weekly-spec-update.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
jobs:
88
update-all-specs:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
pull-requests: write
1013

1114
strategy:
1215
matrix:

orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.sap.ai.sdk.orchestration.model.InputFilteringConfig;
77
import com.sap.ai.sdk.orchestration.model.LLMModelDetails;
88
import com.sap.ai.sdk.orchestration.model.MaskingModuleConfig;
9+
import com.sap.ai.sdk.orchestration.model.MaskingModuleConfigProviders;
910
import com.sap.ai.sdk.orchestration.model.OutputFilteringConfig;
1011
import com.sap.ai.sdk.orchestration.model.PromptTemplatingModuleConfigPrompt;
1112
import com.sap.ai.sdk.orchestration.model.SAPDocumentTranslation;
@@ -130,9 +131,9 @@ public OrchestrationModuleConfig withMaskingConfig(
130131
@Nonnull final MaskingProvider maskingProvider,
131132
@Nonnull final MaskingProvider... maskingProviders) {
132133
val newMaskingConfig =
133-
MaskingModuleConfig.create().maskingProviders(maskingProvider.createConfig());
134+
MaskingModuleConfigProviders.create().providers(maskingProvider.createConfig());
134135
Arrays.stream(maskingProviders)
135-
.forEach(it -> newMaskingConfig.addMaskingProvidersItem(it.createConfig()));
136+
.forEach(it -> newMaskingConfig.addProvidersItem(it.createConfig()));
136137

137138
return withMaskingConfig(newMaskingConfig);
138139
}

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModelDetails.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
import javax.annotation.Nonnull;
2525
import javax.annotation.Nullable;
2626

27-
/** LLMModelDetails */
27+
/**
28+
* The model and parameters to be used for the prompt templating. This is the model that will be
29+
* used to generate the response.
30+
*/
2831
// CHECKSTYLE:OFF
2932
public class LLMModelDetails
3033
// CHECKSTYLE:ON

orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/MaskingModuleConfig.java

Lines changed: 8 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -11,205 +11,13 @@
1111

1212
package com.sap.ai.sdk.orchestration.model;
1313

14-
import com.fasterxml.jackson.annotation.JsonAnyGetter;
15-
import com.fasterxml.jackson.annotation.JsonAnySetter;
16-
import com.fasterxml.jackson.annotation.JsonIgnore;
17-
import com.fasterxml.jackson.annotation.JsonProperty;
18-
import java.util.ArrayList;
19-
import java.util.Arrays;
20-
import java.util.LinkedHashMap;
21-
import java.util.List;
22-
import java.util.Map;
23-
import java.util.NoSuchElementException;
24-
import java.util.Objects;
25-
import java.util.Set;
26-
import javax.annotation.Nonnull;
27-
import javax.annotation.Nullable;
14+
import com.fasterxml.jackson.annotation.JsonSubTypes;
15+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
2816

2917
/** MaskingModuleConfig */
30-
// CHECKSTYLE:OFF
31-
public class MaskingModuleConfig
32-
// CHECKSTYLE:ON
33-
{
34-
@JsonProperty("masking_providers")
35-
private List<DPIConfig> maskingProviders = new ArrayList<>();
36-
37-
@JsonAnySetter @JsonAnyGetter
38-
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();
39-
40-
/** Default constructor for MaskingModuleConfig. */
41-
protected MaskingModuleConfig() {}
42-
43-
/**
44-
* Set the maskingProviders of this {@link MaskingModuleConfig} instance and return the same
45-
* instance.
46-
*
47-
* @param maskingProviders List of masking service providers
48-
* @return The same instance of this {@link MaskingModuleConfig} class
49-
*/
50-
@Nonnull
51-
public MaskingModuleConfig maskingProviders(@Nonnull final List<DPIConfig> maskingProviders) {
52-
this.maskingProviders = maskingProviders;
53-
return this;
54-
}
55-
56-
/**
57-
* Add one maskingProviders instance to this {@link MaskingModuleConfig}.
58-
*
59-
* @param maskingProvidersItem The maskingProviders that should be added
60-
* @return The same instance of type {@link MaskingModuleConfig}
61-
*/
62-
@Nonnull
63-
public MaskingModuleConfig addMaskingProvidersItem(
64-
@Nonnull final DPIConfig maskingProvidersItem) {
65-
if (this.maskingProviders == null) {
66-
this.maskingProviders = new ArrayList<>();
67-
}
68-
this.maskingProviders.add(maskingProvidersItem);
69-
return this;
70-
}
71-
72-
/**
73-
* List of masking service providers
74-
*
75-
* @return maskingProviders The maskingProviders of this {@link MaskingModuleConfig} instance.
76-
*/
77-
@Nonnull
78-
public List<DPIConfig> getMaskingProviders() {
79-
return maskingProviders;
80-
}
81-
82-
/**
83-
* Set the maskingProviders of this {@link MaskingModuleConfig} instance.
84-
*
85-
* @param maskingProviders List of masking service providers
86-
*/
87-
public void setMaskingProviders(@Nonnull final List<DPIConfig> maskingProviders) {
88-
this.maskingProviders = maskingProviders;
89-
}
90-
91-
/**
92-
* Get the names of the unrecognizable properties of the {@link MaskingModuleConfig}.
93-
*
94-
* @return The set of properties names
95-
*/
96-
@JsonIgnore
97-
@Nonnull
98-
public Set<String> getCustomFieldNames() {
99-
return cloudSdkCustomFields.keySet();
100-
}
101-
102-
/**
103-
* Get the value of an unrecognizable property of this {@link MaskingModuleConfig} instance.
104-
*
105-
* @deprecated Use {@link #toMap()} instead.
106-
* @param name The name of the property
107-
* @return The value of the property
108-
* @throws NoSuchElementException If no property with the given name could be found.
109-
*/
110-
@Nullable
111-
@Deprecated
112-
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
113-
if (!cloudSdkCustomFields.containsKey(name)) {
114-
throw new NoSuchElementException(
115-
"MaskingModuleConfig has no field with name '" + name + "'.");
116-
}
117-
return cloudSdkCustomFields.get(name);
118-
}
119-
120-
/**
121-
* Get the value of all properties of this {@link MaskingModuleConfig} instance including
122-
* unrecognized properties.
123-
*
124-
* @return The map of all properties
125-
*/
126-
@JsonIgnore
127-
@Nonnull
128-
public Map<String, Object> toMap() {
129-
final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields);
130-
if (maskingProviders != null) declaredFields.put("maskingProviders", maskingProviders);
131-
return declaredFields;
132-
}
133-
134-
/**
135-
* Set an unrecognizable property of this {@link MaskingModuleConfig} instance. If the map
136-
* previously contained a mapping for the key, the old value is replaced by the specified value.
137-
*
138-
* @param customFieldName The name of the property
139-
* @param customFieldValue The value of the property
140-
*/
141-
@JsonIgnore
142-
public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) {
143-
cloudSdkCustomFields.put(customFieldName, customFieldValue);
144-
}
145-
146-
@Override
147-
public boolean equals(@Nullable final java.lang.Object o) {
148-
if (this == o) {
149-
return true;
150-
}
151-
if (o == null || getClass() != o.getClass()) {
152-
return false;
153-
}
154-
final MaskingModuleConfig maskingModuleConfig = (MaskingModuleConfig) o;
155-
return Objects.equals(this.cloudSdkCustomFields, maskingModuleConfig.cloudSdkCustomFields)
156-
&& Objects.equals(this.maskingProviders, maskingModuleConfig.maskingProviders);
157-
}
158-
159-
@Override
160-
public int hashCode() {
161-
return Objects.hash(maskingProviders, cloudSdkCustomFields);
162-
}
163-
164-
@Override
165-
@Nonnull
166-
public String toString() {
167-
final StringBuilder sb = new StringBuilder();
168-
sb.append("class MaskingModuleConfig {\n");
169-
sb.append(" maskingProviders: ").append(toIndentedString(maskingProviders)).append("\n");
170-
cloudSdkCustomFields.forEach(
171-
(k, v) ->
172-
sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
173-
sb.append("}");
174-
return sb.toString();
175-
}
176-
177-
/**
178-
* Convert the given object to string with each line indented by 4 spaces (except the first line).
179-
*/
180-
private String toIndentedString(final java.lang.Object o) {
181-
if (o == null) {
182-
return "null";
183-
}
184-
return o.toString().replace("\n", "\n ");
185-
}
186-
187-
/**
188-
* Create a type-safe, fluent-api builder object to construct a new {@link MaskingModuleConfig}
189-
* instance with all required arguments.
190-
*/
191-
public static Builder create() {
192-
return (maskingProviders) -> new MaskingModuleConfig().maskingProviders(maskingProviders);
193-
}
194-
195-
/** Builder helper class. */
196-
public interface Builder {
197-
/**
198-
* Set the maskingProviders of this {@link MaskingModuleConfig} instance.
199-
*
200-
* @param maskingProviders List of masking service providers
201-
* @return The MaskingModuleConfig instance.
202-
*/
203-
MaskingModuleConfig maskingProviders(@Nonnull final List<DPIConfig> maskingProviders);
204-
205-
/**
206-
* Set the maskingProviders of this {@link MaskingModuleConfig} instance.
207-
*
208-
* @param maskingProviders List of masking service providers
209-
* @return The MaskingModuleConfig instance.
210-
*/
211-
default MaskingModuleConfig maskingProviders(@Nonnull final DPIConfig... maskingProviders) {
212-
return maskingProviders(Arrays.asList(maskingProviders));
213-
}
214-
}
215-
}
18+
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
19+
@JsonSubTypes({
20+
@JsonSubTypes.Type(value = MaskingModuleConfigMaskingProviders.class),
21+
@JsonSubTypes.Type(value = MaskingModuleConfigProviders.class),
22+
})
23+
public interface MaskingModuleConfig {}

0 commit comments

Comments
 (0)