66import com .sap .ai .sdk .grounding .api .VectorApi ;
77import javax .annotation .Nonnull ;
88import lombok .AccessLevel ;
9+ import lombok .Getter ;
910import lombok .RequiredArgsConstructor ;
11+ import lombok .experimental .Tolerate ;
1012
1113/**
1214 * Service class for the Grounding APIs.
1315 *
1416 * @since 1.3.0
1517 */
16- @ RequiredArgsConstructor (access = AccessLevel .PROTECTED )
18+ @ RequiredArgsConstructor (access = AccessLevel .PUBLIC )
19+ @ Getter (value = AccessLevel .PROTECTED )
1720public class GroundingClient {
18-
19- final AiCoreService aiCoreService ;
20- final String basePath ;
21+ @ Nonnull private final AiCoreService service ;
22+ @ Nonnull private final String basePath ;
2123
2224 static final String DEFAULT_BASE_PATH = "lm/document-grounding/" ;
2325
24- /**
25- * Create a new instance of the GroundingService.
26- *
27- * @return A new instance of the GroundingService.
28- */
29- @ Nonnull
30- public static GroundingClient create () {
31- return create (new AiCoreService ());
32- }
33-
34- /**
35- * Create a new instance of the GroundingService.
36- *
37- * @param aiCoreService The AiCoreService instance to use.
38- * @return A new instance of the GroundingService.
39- */
40- @ Nonnull
41- public static GroundingClient create (@ Nonnull final AiCoreService aiCoreService ) {
42- return create (aiCoreService , DEFAULT_BASE_PATH );
26+ /** Default constructor. */
27+ @ Tolerate
28+ public GroundingClient () {
29+ this (new AiCoreService ());
4330 }
4431
4532 /**
46- * Create a new instance of the GroundingService .
33+ * Constructor with custom AI Core service instance .
4734 *
48- * @param aiCoreService The AiCoreService instance to use.
49- * @param basePath The base path to use for the API calls.
50- * @return A new instance of the GroundingService.
35+ * @param service The instance of AI Core service
5136 */
52- @ Nonnull
53- public static GroundingClient create (
54- @ Nonnull final AiCoreService aiCoreService , @ Nonnull final String basePath ) {
55- return new GroundingClient (aiCoreService , basePath );
37+ public GroundingClient (final @ Nonnull AiCoreService service ) {
38+ this (service , DEFAULT_BASE_PATH );
5639 }
5740
5841 /**
@@ -62,7 +45,7 @@ public static GroundingClient create(
6245 */
6346 @ Nonnull
6447 public PipelinesApi pipelines () {
65- return new PipelinesApi (aiCoreService .getApiClient ().setBasePath (basePath ));
48+ return new PipelinesApi (getService () .getApiClient ().setBasePath (getBasePath () ));
6649 }
6750
6851 /**
@@ -72,7 +55,7 @@ public PipelinesApi pipelines() {
7255 */
7356 @ Nonnull
7457 public VectorApi vector () {
75- return new VectorApi (aiCoreService .getApiClient ().setBasePath (basePath ));
58+ return new VectorApi (getService () .getApiClient ().setBasePath (getBasePath () ));
7659 }
7760
7861 /**
@@ -82,6 +65,6 @@ public VectorApi vector() {
8265 */
8366 @ Nonnull
8467 public RetrievalApi retrieval () {
85- return new RetrievalApi (aiCoreService .getApiClient ().setBasePath (basePath ));
68+ return new RetrievalApi (getService () .getApiClient ().setBasePath (getBasePath () ));
8669 }
8770}
0 commit comments