Skip to content

Commit c772c5a

Browse files
authored
Merge branch 'main' into docs/adr-logging
2 parents 261e93d + e94b1bc commit c772c5a

File tree

12 files changed

+115
-55
lines changed

12 files changed

+115
-55
lines changed

.github/dependabot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ updates:
66
directory: '/'
77
schedule:
88
interval: weekly
9-
time: '02:00'
9+
time: '23:00'
1010
timezone: 'Europe/Berlin'
1111
open-pull-requests-limit: 5
1212
commit-message:

.github/workflows/dependabot-automerge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "Dependabot Auto-Merge"
33
on:
44
workflow_dispatch:
55
schedule:
6-
- cron: '00 04 * * Mon' # trigger every Monday at 04:00 a.m., as our dependabot is configured to raise PRs every Monday at 2:00 a.m.
6+
- cron: '00 01 * * Tue' # trigger every Tuesday at 01:00 a.m., as our dependabot is configured to raise PRs every Monday at 23:00 p.m.
77

88
env:
99
DEPENDABOT_GROUPS: |

core-services/document-grounding/src/main/java/com/sap/ai/sdk/grounding/model/S3PipelineMinimalResponse.java

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void setType(@Nonnull final TypeEnum type) {
207207
*/
208208
@Nonnull
209209
public S3PipelineMinimalResponse _configuration(
210-
@Nonnull final S3ConfigurationMinimal _configuration) {
210+
@Nullable final S3ConfigurationMinimal _configuration) {
211211
this._configuration = _configuration;
212212
return this;
213213
}
@@ -227,7 +227,7 @@ public S3ConfigurationMinimal getConfiguration() {
227227
*
228228
* @param _configuration The _configuration of this {@link S3PipelineMinimalResponse}
229229
*/
230-
public void setConfiguration(@Nonnull final S3ConfigurationMinimal _configuration) {
230+
public void setConfiguration(@Nullable final S3ConfigurationMinimal _configuration) {
231231
this._configuration = _configuration;
232232
}
233233

@@ -377,14 +377,7 @@ private String toIndentedString(final java.lang.Object o) {
377377
*/
378378
public static Builder create() {
379379
return (id) ->
380-
(status) ->
381-
(type) ->
382-
(_configuration) ->
383-
new S3PipelineMinimalResponse()
384-
.id(id)
385-
.status(status)
386-
.type(type)
387-
._configuration(_configuration);
380+
(status) -> (type) -> new S3PipelineMinimalResponse().id(id).status(status).type(type);
388381
}
389382

390383
/** Builder helper class. */
@@ -415,19 +408,8 @@ public interface Builder2 {
415408
* Set the type of this {@link S3PipelineMinimalResponse} instance.
416409
*
417410
* @param type The type of this {@link S3PipelineMinimalResponse}
418-
* @return The S3PipelineMinimalResponse builder.
419-
*/
420-
Builder3 type(@Nonnull final TypeEnum type);
421-
}
422-
423-
/** Builder helper class. */
424-
public interface Builder3 {
425-
/**
426-
* Set the _configuration of this {@link S3PipelineMinimalResponse} instance.
427-
*
428-
* @param _configuration The _configuration of this {@link S3PipelineMinimalResponse}
429411
* @return The S3PipelineMinimalResponse instance.
430412
*/
431-
S3PipelineMinimalResponse _configuration(@Nonnull final S3ConfigurationMinimal _configuration);
413+
S3PipelineMinimalResponse type(@Nonnull final TypeEnum type);
432414
}
433415
}

core-services/document-grounding/src/main/java/com/sap/ai/sdk/grounding/model/SFTPPipelineMinimalResponse.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void setType(@Nonnull final TypeEnum type) {
208208
*/
209209
@Nonnull
210210
public SFTPPipelineMinimalResponse _configuration(
211-
@Nonnull final SFTPConfigurationMinimal _configuration) {
211+
@Nullable final SFTPConfigurationMinimal _configuration) {
212212
this._configuration = _configuration;
213213
return this;
214214
}
@@ -228,7 +228,7 @@ public SFTPConfigurationMinimal getConfiguration() {
228228
*
229229
* @param _configuration The _configuration of this {@link SFTPPipelineMinimalResponse}
230230
*/
231-
public void setConfiguration(@Nonnull final SFTPConfigurationMinimal _configuration) {
231+
public void setConfiguration(@Nullable final SFTPConfigurationMinimal _configuration) {
232232
this._configuration = _configuration;
233233
}
234234

@@ -380,14 +380,7 @@ private String toIndentedString(final java.lang.Object o) {
380380
*/
381381
public static Builder create() {
382382
return (id) ->
383-
(status) ->
384-
(type) ->
385-
(_configuration) ->
386-
new SFTPPipelineMinimalResponse()
387-
.id(id)
388-
.status(status)
389-
.type(type)
390-
._configuration(_configuration);
383+
(status) -> (type) -> new SFTPPipelineMinimalResponse().id(id).status(status).type(type);
391384
}
392385

393386
/** Builder helper class. */
@@ -418,20 +411,8 @@ public interface Builder2 {
418411
* Set the type of this {@link SFTPPipelineMinimalResponse} instance.
419412
*
420413
* @param type The type of this {@link SFTPPipelineMinimalResponse}
421-
* @return The SFTPPipelineMinimalResponse builder.
422-
*/
423-
Builder3 type(@Nonnull final TypeEnum type);
424-
}
425-
426-
/** Builder helper class. */
427-
public interface Builder3 {
428-
/**
429-
* Set the _configuration of this {@link SFTPPipelineMinimalResponse} instance.
430-
*
431-
* @param _configuration The _configuration of this {@link SFTPPipelineMinimalResponse}
432414
* @return The SFTPPipelineMinimalResponse instance.
433415
*/
434-
SFTPPipelineMinimalResponse _configuration(
435-
@Nonnull final SFTPConfigurationMinimal _configuration);
416+
SFTPPipelineMinimalResponse type(@Nonnull final TypeEnum type);
436417
}
437418
}

core-services/document-grounding/src/main/resources/spec/grounding.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,6 @@ components:
16521652
- type: object
16531653
required:
16541654
- type
1655-
- configuration
16561655
properties:
16571656
type:
16581657
type: string
@@ -1670,7 +1669,6 @@ components:
16701669
- type: object
16711670
required:
16721671
- type
1673-
- configuration
16741672
properties:
16751673
type:
16761674
type: string

docs/release_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
### ✨ New Functionality
1414

15-
-[Orchestration] Added new models for `OrchestrationAiModel`: `SONAR`,`SONAR_PRO`.
15+
- [Orchestration] Added new models for `OrchestrationAiModel`: `SONAR`,`SONAR_PRO`.
16+
- [Orchestration] Convenience for adding the `metadata_params` option to grounding calls.
1617

1718
### 📈 Improvements
1819

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.List;
1212
import java.util.Map;
1313
import javax.annotation.Nonnull;
14+
import javax.annotation.Nullable;
1415
import lombok.Setter;
1516
import lombok.experimental.Accessors;
1617
import lombok.val;
@@ -31,6 +32,8 @@ public class Grounding implements GroundingProvider {
3132
private List<GroundingModuleConfigConfigFiltersInner> filters =
3233
List.of(DocumentGroundingFilter.create().dataRepositoryType(DataRepositoryType.VECTOR));
3334

35+
@Nullable private List<String> metadataParams = null;
36+
3437
@Setter(onMethod_ = {@Nonnull})
3538
private TypeEnum documentGroundingService = TypeEnum.DOCUMENT_GROUNDING_SERVICE;
3639

@@ -60,6 +63,19 @@ public Grounding filters(@Nonnull final GroundingModuleConfigConfigFiltersInner.
6063
return this;
6164
}
6265

66+
/**
67+
* Set which metadataParams are used in the grounding response.
68+
*
69+
* @param metadataParams List of metadataParams to set.
70+
* @return The modified grounding configuration.
71+
* @since 1.13.0
72+
*/
73+
@Nonnull
74+
public Grounding metadataParams(@Nonnull final String... metadataParams) {
75+
this.metadataParams = List.of(metadataParams);
76+
return this;
77+
}
78+
6379
/**
6480
* Create a prompt with grounding parameters included in the message.
6581
*
@@ -86,8 +102,10 @@ public GroundingModuleConfig createConfig() {
86102
GroundingModuleConfigConfigPlaceholders.create()
87103
.input(List.of("userMessage"))
88104
.output("groundingContext"))
89-
.filters(filters);
105+
.filters(filters)
106+
.metadataParams(metadataParams);
90107

108+
// metadata_params field is not allowed for data repository type: `help.sap.com`
91109
if (filters.contains(
92110
DocumentGroundingFilter.create().dataRepositoryType(DataRepositoryType.HELP_SAP_COM))) {
93111
groundingConfigConfig.setMetadataParams(null);

orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,28 @@ void testGrounding() throws IOException {
268268
postRequestedFor(urlPathEqualTo("/v2/completion")).withRequestBody(equalToJson(request)));
269269
}
270270

271+
@Test
272+
void testGroundingWithConvenience() throws IOException {
273+
stubFor(
274+
post(urlPathEqualTo("/v2/completion"))
275+
.willReturn(
276+
aResponse()
277+
.withBodyFile("groundingResponse.json")
278+
.withHeader("Content-Type", "application/json")));
279+
280+
var dbFilters = DocumentGroundingFilter.create().dataRepositoryType(DataRepositoryType.VECTOR);
281+
282+
var groundingConfig = Grounding.create().metadataParams("foo", "bar").filters(dbFilters);
283+
var prompt = groundingConfig.createGroundingPrompt("Hello, what do you know?");
284+
var configWithGrounding = config.withGrounding(groundingConfig);
285+
286+
final var response = client.chatCompletion(prompt, configWithGrounding);
287+
288+
final String request = fileLoaderStr.apply("groundingRequestMetadata.json");
289+
verify(
290+
postRequestedFor(urlPathEqualTo("/v2/completion")).withRequestBody(equalToJson(request)));
291+
}
292+
271293
@Test
272294
void testGroundingWithHelpSapCom() throws IOException {
273295
stubFor(
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"config" : {
3+
"modules" : {
4+
"prompt_templating" : {
5+
"prompt" : {
6+
"template" : [ {
7+
"content" : "{{?userMessage}} Use the following information as additional context: {{?groundingContext}}",
8+
"role" : "user"
9+
} ],
10+
"defaults" : { },
11+
"tools" : [ ]
12+
},
13+
"model" : {
14+
"name" : "gpt-4o",
15+
"version" : "latest",
16+
"params" : {
17+
"max_tokens" : 50,
18+
"temperature" : 0.1,
19+
"frequency_penalty" : 0,
20+
"presence_penalty" : 0,
21+
"top_p" : 1,
22+
"n" : 1
23+
},
24+
"timeout" : 600,
25+
"max_retries" : 2
26+
}
27+
},
28+
"grounding" : {
29+
"type" : "document_grounding_service",
30+
"config" : {
31+
"filters" : [ {
32+
"data_repositories" : [ "*" ],
33+
"data_repository_type" : "vector",
34+
"data_repository_metadata" : [ ],
35+
"document_metadata" : [ ],
36+
"chunk_metadata" : [ ]
37+
} ],
38+
"placeholders" : {
39+
"input" : [ "userMessage" ],
40+
"output" : "groundingContext"
41+
},
42+
"metadata_params" : [ "foo", "bar" ]
43+
}
44+
}
45+
}
46+
},
47+
"placeholder_values" : {
48+
"userMessage" : "Hello, what do you know?"
49+
},
50+
"messages_history" : [ ]
51+
}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<json.version>20250517</json.version>
7878
<snakeyaml.version>2.5</snakeyaml.version>
7979
<!-- Formatting -->
80-
<spotless.version>3.0.0</spotless.version>
80+
<spotless.version>3.1.0</spotless.version>
8181
<spotless.skip>false</spotless.skip>
8282
<!-- Quality assurance -->
8383
<enforcer.skip>false</enforcer.skip>
@@ -753,7 +753,7 @@ https://gitbox.apache.org/repos/asf?p=maven-pmd-plugin.git;a=blob_plain;f=src/ma
753753
<plugin>
754754
<groupId>com.github.spotbugs</groupId>
755755
<artifactId>spotbugs-maven-plugin</artifactId>
756-
<version>4.9.8.1</version>
756+
<version>4.9.8.2</version>
757757
<configuration>
758758
<includeFilterFile>${project.rootdir}/.pipeline/spotbugs.xml</includeFilterFile>
759759
<!-- Exclude generated clients -->

0 commit comments

Comments
 (0)