Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.time.Duration;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.ollama.OllamaContainer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import org.springframework.ai.chroma.ChromaApi.QueryRequest.Include;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
Expand Down Expand Up @@ -188,17 +187,16 @@ public void upsertEmbeddings(String collectionId, AddEmbeddingsRequest embedding
.toBodilessEntity();
}

public List<String> deleteEmbeddings(String collectionId, DeleteEmbeddingsRequest deleteRequest) {
public String deleteEmbeddings(String collectionId, DeleteEmbeddingsRequest deleteRequest) {

return this.restClient.post()
return String.valueOf(this.restClient.post()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why return a string instead of the http status code which is an int?

.uri("/api/v1/collections/{collection_id}/delete", collectionId)
.headers(this::httpHeaders)
.body(deleteRequest)
.retrieve()
.toEntity(new ParameterizedTypeReference<List<String>>() {

})
.getBody();
.toEntity(String.class)
.getStatusCode()
.value());
}

public Long countEmbeddings(String collectionId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ public void doAdd(List<Document> documents) {
@Override
public Optional<Boolean> doDelete(List<String> idList) {
Assert.notNull(idList, "Document id list must not be null");
List<String> deletedIds = this.chromaApi.deleteEmbeddings(this.collectionId,
new DeleteEmbeddingsRequest(idList));
return Optional.of(deletedIds.size() == idList.size());
String status = this.chromaApi.deleteEmbeddings(this.collectionId, new DeleteEmbeddingsRequest(idList));
return Optional.of(status.equals("200"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public final class ChromaImage {

public static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse("ghcr.io/chroma-core/chroma:0.5.11");
public static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse("ghcr.io/chroma-core/chroma:0.5.16");

private ChromaImage() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -83,7 +84,8 @@ public void addAndSearch() {
assertThat(resultDoc.getMetadata()).containsKeys("meta2", "distance");

// Remove all documents from the store
vectorStore.delete(this.documents.stream().map(doc -> doc.getId()).toList());
assertThat(vectorStore.delete(this.documents.stream().map(doc -> doc.getId()).toList()))
.isEqualTo(Optional.of(Boolean.TRUE));

List<Document> results2 = vectorStore.similaritySearch(SearchRequest.query("Great").withTopK(1));
assertThat(results2).hasSize(0);
Expand Down