Skip to content

Commit 14a461d

Browse files
committed
Refine; Add test code
1 parent f46b313 commit 14a461d

File tree

116 files changed

+423
-19996
lines changed

Some content is hidden

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

116 files changed

+423
-19996
lines changed

.pipeline/checkstyle-suppressions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<suppress files="[/\\]core[/\\]client[/\\]" checks=".*"/>
1010
<suppress files="[/\\]core[/\\]model[/\\]" checks=".*"/>
1111
<suppress files="[/\\]orchestration[/\\]model[/\\]" checks=".*"/>
12+
<suppress files="[/\\]grounding[/\\]api[/\\]" checks=".*"/>
13+
<suppress files="[/\\]grounding[/\\]model[/\\]" checks=".*"/>
1214
<!-- Suppress TODOs -->
1315
<suppress files="OpenAiChatMessage.java" checks="TodoComment" lines="257,7" />
1416
</suppressions>

.pipeline/spotbugs-exclusions.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<Package name="com.sap.ai.sdk.core.client"/>
66
<Package name="com.sap.ai.sdk.core.model"/>
77
<Package name="com.sap.ai.sdk.orchestration.model"/>
8+
<Package name="com.sap.ai.sdk.grounding.api"/>
9+
<Package name="com.sap.ai.sdk.grounding.model"/>
810
</Or>
911
</Match>
1012
</FindBugsFilter>

grounding/pom.xml

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,35 @@
3232
<properties>
3333
<project.rootdir>${project.basedir}/../</project.rootdir>
3434
<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>
35+
<coverage.line>83%</coverage.line>
36+
<coverage.instruction>88%</coverage.instruction>
37+
<coverage.branch>100%</coverage.branch>
38+
<coverage.method>100%</coverage.method>
3939
<coverage.class>100%</coverage.class>
4040
</properties>
4141

4242
<dependencies>
43+
<!-- used by generated API classes -->
44+
<dependency>
45+
<groupId>org.springframework</groupId>
46+
<artifactId>spring-core</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.springframework</groupId>
50+
<artifactId>spring-web</artifactId>
51+
</dependency>
4352
<!-- scope "compile" -->
4453
<dependency>
4554
<groupId>com.sap.ai.sdk</groupId>
4655
<artifactId>core</artifactId>
4756
</dependency>
48-
4957
<dependency>
5058
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
5159
<artifactId>cloudplatform-connectivity</artifactId>
5260
</dependency>
5361
<dependency>
54-
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
55-
<artifactId>connectivity-apache-httpclient5</artifactId>
56-
</dependency>
57-
<dependency>
58-
<groupId>org.apache.httpcomponents.core5</groupId>
59-
<artifactId>httpcore5</artifactId>
60-
</dependency>
61-
<dependency>
62-
<groupId>org.apache.httpcomponents.client5</groupId>
63-
<artifactId>httpclient5</artifactId>
62+
<groupId>com.sap.cloud.sdk.datamodel</groupId>
63+
<artifactId>openapi-core</artifactId>
6464
</dependency>
6565
<dependency>
6666
<groupId>com.google.code.findbugs</groupId>
@@ -70,18 +70,6 @@
7070
<groupId>com.fasterxml.jackson.core</groupId>
7171
<artifactId>jackson-annotations</artifactId>
7272
</dependency>
73-
<dependency>
74-
<groupId>com.fasterxml.jackson.core</groupId>
75-
<artifactId>jackson-core</artifactId>
76-
</dependency>
77-
<dependency>
78-
<groupId>com.fasterxml.jackson.core</groupId>
79-
<artifactId>jackson-databind</artifactId>
80-
</dependency>
81-
<dependency>
82-
<groupId>io.vavr</groupId>
83-
<artifactId>vavr</artifactId>
84-
</dependency>
8573
<dependency>
8674
<groupId>org.slf4j</groupId>
8775
<artifactId>slf4j-api</artifactId>
@@ -112,16 +100,6 @@
112100
<artifactId>assertj-core</artifactId>
113101
<scope>test</scope>
114102
</dependency>
115-
<dependency>
116-
<groupId>org.mockito</groupId>
117-
<artifactId>mockito-core</artifactId>
118-
<scope>test</scope>
119-
</dependency>
120-
<dependency>
121-
<groupId>org.junit.jupiter</groupId>
122-
<artifactId>junit-jupiter-params</artifactId>
123-
<scope>test</scope>
124-
</dependency>
125103
</dependencies>
126104

127105
<profiles>
@@ -144,6 +122,7 @@
144122
<enableOneOfAnyOfGeneration>true</enableOneOfAnyOfGeneration>
145123
<compileScope>COMPILE</compileScope>
146124
<deleteOutputDirectory>true</deleteOutputDirectory>
125+
<skip>true</skip>
147126
</configuration>
148127
<executions>
149128
<execution>

grounding/src/main/java/com/sap/ai/sdk/grounding/GroundingClient.java

Lines changed: 0 additions & 82 deletions
This file was deleted.

grounding/src/main/java/com/sap/ai/sdk/grounding/GroundingClientException.java

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.sap.ai.sdk.grounding;
2+
3+
import com.google.common.annotations.Beta;
4+
import com.sap.ai.sdk.core.AiCoreService;
5+
import com.sap.ai.sdk.grounding.api.PipelinesApi;
6+
import com.sap.ai.sdk.grounding.api.RetrievalApi;
7+
import com.sap.ai.sdk.grounding.api.VectorApi;
8+
import javax.annotation.Nonnull;
9+
import lombok.AccessLevel;
10+
import lombok.RequiredArgsConstructor;
11+
12+
/**
13+
* Service class for the Grounding APIs.
14+
*
15+
* @since 1.3.0
16+
*/
17+
@Beta
18+
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
19+
public class GroundingService {
20+
21+
final AiCoreService aiCoreService;
22+
final String basePath;
23+
24+
static final String DEFAULT_BASE_PATH = "lm/document-grounding/";
25+
26+
/**
27+
* Create a new instance of the GroundingService.
28+
*
29+
* @return A new instance of the GroundingService.
30+
*/
31+
@Nonnull
32+
public static GroundingService create() {
33+
return create(new AiCoreService());
34+
}
35+
36+
/**
37+
* Create a new instance of the GroundingService.
38+
*
39+
* @param aiCoreService The AiCoreService instance to use.
40+
* @return A new instance of the GroundingService.
41+
*/
42+
@Nonnull
43+
public static GroundingService create(@Nonnull final AiCoreService aiCoreService) {
44+
return create(aiCoreService, DEFAULT_BASE_PATH);
45+
}
46+
47+
/**
48+
* Create a new instance of the GroundingService.
49+
*
50+
* @param aiCoreService The AiCoreService instance to use.
51+
* @param basePath The base path to use for the API calls.
52+
* @return A new instance of the GroundingService.
53+
*/
54+
@Nonnull
55+
public static GroundingService create(
56+
@Nonnull final AiCoreService aiCoreService, @Nonnull final String basePath) {
57+
return new GroundingService(aiCoreService, basePath);
58+
}
59+
60+
/**
61+
* Get the Pipelines API.
62+
*
63+
* @return The Pipelines API.
64+
*/
65+
@Nonnull
66+
public PipelinesApi pipelines() {
67+
return new PipelinesApi(aiCoreService.getApiClient().setBasePath(basePath));
68+
}
69+
70+
/**
71+
* Get the Vector API.
72+
*
73+
* @return The Vector API.
74+
*/
75+
@Nonnull
76+
public VectorApi vector() {
77+
return new VectorApi(aiCoreService.getApiClient().setBasePath(basePath));
78+
}
79+
80+
/**
81+
* Get the Retrieval API.
82+
*
83+
* @return The Retrieval API.
84+
*/
85+
@Nonnull
86+
public RetrievalApi retrieval() {
87+
return new RetrievalApi(aiCoreService.getApiClient().setBasePath(basePath));
88+
}
89+
}

grounding/src/main/java/com/sap/ai/sdk/grounding/model/BaseDocument.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.common.annotations.Beta;
2020
import java.util.ArrayList;
2121
import java.util.Arrays;
22-
import java.util.HashMap;
2322
import java.util.LinkedHashMap;
2423
import java.util.List;
2524
import java.util.Map;
@@ -31,7 +30,7 @@
3130

3231
/** Base class for documents, document requests and responses. */
3332
@Beta // CHECKSTYLE:OFF
34-
public class BaseDocument
33+
public class BaseDocument
3534
// CHECKSTYLE:ON
3635
{
3736
@JsonProperty("chunks")
@@ -189,8 +188,7 @@ public boolean equals(@Nullable final java.lang.Object o) {
189188
final BaseDocument baseDocument = (BaseDocument) o;
190189
return Objects.equals(this.cloudSdkCustomFields, baseDocument.cloudSdkCustomFields)
191190
&& Objects.equals(this.chunks, baseDocument.chunks)
192-
&& Objects.equals(this.metadata, baseDocument.metadata)
193-
&& super.equals(o);
191+
&& Objects.equals(this.metadata, baseDocument.metadata);
194192
}
195193

196194
@Override

grounding/src/main/java/com/sap/ai/sdk/grounding/model/CollectionRequest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.fasterxml.jackson.annotation.JsonProperty;
1919
import com.google.common.annotations.Beta;
2020
import java.util.ArrayList;
21-
import java.util.HashMap;
2221
import java.util.LinkedHashMap;
2322
import java.util.List;
2423
import java.util.Map;
@@ -30,7 +29,7 @@
3029

3130
/** A request for creating a new, single collection. */
3231
@Beta // CHECKSTYLE:OFF
33-
public class CollectionRequest
32+
public class CollectionRequest
3433
// CHECKSTYLE:ON
3534
{
3635
@JsonProperty("title")
@@ -211,8 +210,7 @@ public boolean equals(@Nullable final java.lang.Object o) {
211210
return Objects.equals(this.cloudSdkCustomFields, collectionRequest.cloudSdkCustomFields)
212211
&& Objects.equals(this.title, collectionRequest.title)
213212
&& Objects.equals(this.embeddingConfig, collectionRequest.embeddingConfig)
214-
&& Objects.equals(this.metadata, collectionRequest.metadata)
215-
&& super.equals(o);
213+
&& Objects.equals(this.metadata, collectionRequest.metadata);
216214
}
217215

218216
@Override

grounding/src/main/java/com/sap/ai/sdk/grounding/model/DocumentCreateRequest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.common.annotations.Beta;
2020
import java.util.ArrayList;
2121
import java.util.Arrays;
22-
import java.util.HashMap;
2322
import java.util.LinkedHashMap;
2423
import java.util.List;
2524
import java.util.Map;
@@ -31,7 +30,7 @@
3130

3231
/** A create request containing one or more new documents to create and store in a collection. */
3332
@Beta // CHECKSTYLE:OFF
34-
public class DocumentCreateRequest
33+
public class DocumentCreateRequest
3534
// CHECKSTYLE:ON
3635
{
3736
@JsonProperty("documents")
@@ -140,8 +139,7 @@ public boolean equals(@Nullable final java.lang.Object o) {
140139
}
141140
final DocumentCreateRequest documentCreateRequest = (DocumentCreateRequest) o;
142141
return Objects.equals(this.cloudSdkCustomFields, documentCreateRequest.cloudSdkCustomFields)
143-
&& Objects.equals(this.documents, documentCreateRequest.documents)
144-
&& super.equals(o);
142+
&& Objects.equals(this.documents, documentCreateRequest.documents);
145143
}
146144

147145
@Override

0 commit comments

Comments
 (0)