Skip to content

Commit 1e63c44

Browse files
committed
Update app
1 parent 67aff8f commit 1e63c44

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/GroundingController.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class GroundingController {
6262
@GetMapping("/pipelines/list")
6363
Object getAllPipelines(
6464
@Nullable @RequestParam(value = "format", required = false) final String format) {
65-
final var pipelines =
66-
CLIENT_PIPELINES.pipelineV1PipelineEndpointsGetAllPipeline(RESOURCE_GROUP, 10, 0, true);
65+
final var pipelines = CLIENT_PIPELINES.getAllPipeline(RESOURCE_GROUP, 10, 0, true);
6766
log.info("Found {} pipelines", pipelines.getResources().size());
6867

6968
if ("json".equals(format)) {
@@ -88,8 +87,7 @@ Object getAllPipelines(
8887
@GetMapping("/retrieval/repositories")
8988
Object getAllRepositories(
9089
@Nullable @RequestParam(value = "format", required = false) final String format) {
91-
final var repositories =
92-
CLIENT_RETRIEVAL.retrievalV1RetrievalEndpointsGetDataRepositories(RESOURCE_GROUP);
90+
final var repositories = CLIENT_RETRIEVAL.getDataRepositories(RESOURCE_GROUP);
9391
log.info("Found {} data repositories", repositories.getResources().size());
9492

9593
if ("json".equals(format)) {
@@ -130,7 +128,7 @@ Object searchInDocuments(
130128
@GetMapping("/vector/collections")
131129
Object getAllCollections(
132130
@Nullable @RequestParam(value = "format", required = false) final String format) {
133-
final var collections = CLIENT_VECTOR.vectorV1VectorEndpointsGetAllCollections(RESOURCE_GROUP);
131+
final var collections = CLIENT_VECTOR.getAllCollections(RESOURCE_GROUP);
134132
if ("json".equals(format)) {
135133
return collections;
136134
}
@@ -144,8 +142,7 @@ Object getAllCollections(
144142
Object getDocumentsByCollectionId(
145143
@Nonnull @PathVariable("id") final UUID collectionId,
146144
@Nullable @RequestParam(value = "format", required = false) final String format) {
147-
final var documents =
148-
CLIENT_VECTOR.vectorV1VectorEndpointsGetAllDocuments(RESOURCE_GROUP, collectionId);
145+
final var documents = CLIENT_VECTOR.getAllDocuments(RESOURCE_GROUP, collectionId);
149146
if ("json".equals(format)) {
150147
return documents;
151148
}
@@ -160,8 +157,7 @@ String createCollection(
160157
final var embeddingConfig = EmbeddingConfig.create().modelName(TEXT_EMBEDDING_3_SMALL.name());
161158
final var request =
162159
CollectionRequest.create().embeddingConfig(embeddingConfig).title(COLLECTION_TITLE);
163-
final var documents =
164-
CLIENT_VECTOR.vectorV1VectorEndpointsCreateCollection(RESOURCE_GROUP, request);
160+
final var documents = CLIENT_VECTOR.createCollection(RESOURCE_GROUP, request);
165161
final Map<String, List<String>> headers = documents.getHeaders();
166162

167163
final var locationHeader = headers.get("Location").get(0);
@@ -181,8 +177,7 @@ Object createDocument(
181177
final var docMeta = DocumentKeyValueListPair.create().key("purpose").value("testing");
182178
final var doc = BaseDocument.create().chunks(chunk).metadata(docMeta);
183179
final var request = DocumentCreateRequest.create().documents(doc);
184-
final var response =
185-
CLIENT_VECTOR.vectorV1VectorEndpointsCreateDocuments(RESOURCE_GROUP, collectionId, request);
180+
final var response = CLIENT_VECTOR.createDocuments(RESOURCE_GROUP, collectionId, request);
186181

187182
if ("json".equals(format)) {
188183
return response;
@@ -204,22 +199,18 @@ Object deleteCollection(
204199
final var doc = BaseDocument.create().chunks(chunk).metadata(docMeta);
205200
final var request = DocumentCreateRequest.create().documents(doc);
206201

207-
final var documents =
208-
CLIENT_VECTOR.vectorV1VectorEndpointsGetAllDocuments(RESOURCE_GROUP, collectionId);
202+
final var documents = CLIENT_VECTOR.getAllDocuments(RESOURCE_GROUP, collectionId);
209203
final var ids = documents.getResources().stream().map(DocumentWithoutChunks::getId).toList();
210204
log.info("Deleting collection {} with {} documents: {}", collectionId, ids.size(), ids);
211205

212206
for (final var documentId : ids) {
213-
final var del =
214-
CLIENT_VECTOR.vectorV1VectorEndpointsDeleteDocument(
215-
RESOURCE_GROUP, collectionId, documentId);
207+
final var del = CLIENT_VECTOR.deleteDocument(RESOURCE_GROUP, collectionId, documentId);
216208
if (del.getStatusCode() >= 400) {
217209
final var msg = "Document {} could not be deleted, status code [{}], headers: {}";
218210
log.error(msg, documentId, del.getStatusCode(), del.getHeaders());
219211
}
220212
}
221-
final var response =
222-
CLIENT_VECTOR.vectorV1VectorEndpointsDeleteCollection(RESOURCE_GROUP, collectionId + "");
213+
final var response = CLIENT_VECTOR.deleteCollection(RESOURCE_GROUP, collectionId + "");
223214

224215
if ("json".equals(format)) {
225216
return response;
@@ -233,9 +224,7 @@ Object getDocumentChunksById(
233224
@Nonnull @PathVariable("collectionId") final UUID collectionId,
234225
@Nonnull @PathVariable("documentId") final UUID documentId,
235226
@Nullable @RequestParam(value = "format", required = false) final String format) {
236-
final var document =
237-
CLIENT_VECTOR.vectorV1VectorEndpointsGetDocumentById(
238-
RESOURCE_GROUP, collectionId, documentId);
227+
final var document = CLIENT_VECTOR.getDocumentById(RESOURCE_GROUP, collectionId, documentId);
239228
if ("json".equals(format)) {
240229
return document;
241230
}

0 commit comments

Comments
 (0)