Skip to content

Commit ad691e5

Browse files
quaffericbottard
authored andcommitted
Polish ChromaApi
Signed-off-by: Yanming Zhou <[email protected]>
1 parent 0ee96f1 commit ad691e5

File tree

1 file changed

+8
-16
lines changed
  • vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore

1 file changed

+8
-16
lines changed

vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaApi.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ public Tenant getTenant(String tenantName) {
132132
.uri("/api/v2/tenants/{tenant_name}", tenantName)
133133
.headers(this::httpHeaders)
134134
.retrieve()
135-
.toEntity(Tenant.class)
136-
.getBody();
135+
.body(Tenant.class);
137136
}
138137
catch (HttpServerErrorException | HttpClientErrorException e) {
139138
String msg = this.getErrorMessage(e);
@@ -162,8 +161,7 @@ public Database getDatabase(String tenantName, String databaseName) {
162161
.uri("/api/v2/tenants/{tenant_name}/databases/{database_name}", tenantName, databaseName)
163162
.headers(this::httpHeaders)
164163
.retrieve()
165-
.toEntity(Database.class)
166-
.getBody();
164+
.body(Database.class);
167165
}
168166
catch (HttpServerErrorException | HttpClientErrorException e) {
169167
String msg = this.getErrorMessage(e);
@@ -197,8 +195,7 @@ public Collection createCollection(String tenantName, String databaseName,
197195
.headers(this::httpHeaders)
198196
.body(createCollectionRequest)
199197
.retrieve()
200-
.toEntity(Collection.class)
201-
.getBody();
198+
.body(Collection.class);
202199
}
203200

204201
/**
@@ -225,8 +222,7 @@ public Collection getCollection(String tenantName, String databaseName, String c
225222
tenantName, databaseName, collectionName)
226223
.headers(this::httpHeaders)
227224
.retrieve()
228-
.toEntity(Collection.class)
229-
.getBody();
225+
.body(Collection.class);
230226
}
231227
catch (HttpServerErrorException | HttpClientErrorException e) {
232228
String msg = this.getErrorMessage(e);
@@ -244,8 +240,7 @@ public List<Collection> listCollections(String tenantName, String databaseName)
244240
.uri("/api/v2/tenants/{tenant_name}/databases/{database_name}/collections", tenantName, databaseName)
245241
.headers(this::httpHeaders)
246242
.retrieve()
247-
.toEntity(CollectionList.class)
248-
.getBody();
243+
.body(CollectionList.class);
249244
}
250245

251246
public void upsertEmbeddings(String tenantName, String databaseName, String collectionId,
@@ -281,8 +276,7 @@ public Long countEmbeddings(String tenantName, String databaseName, String colle
281276
tenantName, databaseName, collectionId)
282277
.headers(this::httpHeaders)
283278
.retrieve()
284-
.toEntity(Long.class)
285-
.getBody();
279+
.body(Long.class);
286280
}
287281

288282
@Nullable
@@ -295,8 +289,7 @@ public QueryResponse queryCollection(String tenantName, String databaseName, Str
295289
.headers(this::httpHeaders)
296290
.body(queryRequest)
297291
.retrieve()
298-
.toEntity(QueryResponse.class)
299-
.getBody();
292+
.body(QueryResponse.class);
300293
}
301294

302295
//
@@ -312,8 +305,7 @@ public GetEmbeddingResponse getEmbeddings(String tenantName, String databaseName
312305
.headers(this::httpHeaders)
313306
.body(getEmbeddingsRequest)
314307
.retrieve()
315-
.toEntity(GetEmbeddingResponse.class)
316-
.getBody();
308+
.body(GetEmbeddingResponse.class);
317309
}
318310

319311
// Utils

0 commit comments

Comments
 (0)