Class ChromaApi
java.lang.Object
org.springframework.ai.chroma.vectorstore.ChromaApi
Single-class Chroma API implementation based on the (unofficial) Chroma REST API.
- Author:
- Christian Tzolov, EddĂș MelĂ©ndez, Jonghoon Park
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Add embeddings to the chroma data store.static class
static final record
Chroma embedding collection.static final record
Request to create a new collection with the given name and metadata.static final record
Request to create a new databasestatic final record
Request to create a new tenantstatic final record
Chroma database.static final record
Request to delete embedding from a collection.static final record
Single query embedding response.static final record
Object containing the get embedding results.static final record
Get embeddings from a collection.static final record
Request to get the nResults nearest neighbor embeddings for provided queryEmbeddings.static final record
A QueryResponse object containing the query results.static final record
Chroma tenant. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ChromaApi.Builder
builder()
countEmbeddings
(String tenantName, String databaseName, String collectionId) createCollection
(String tenantName, String databaseName, ChromaApi.CreateCollectionRequest createCollectionRequest) void
createDatabase
(String tenantName, String databaseName) void
createTenant
(String tenantName) void
deleteCollection
(String tenantName, String databaseName, String collectionName) Delete a collection with the given name.void
deleteDatabase
(String tenantName, String databaseName) Delete a database with the given name.int
deleteEmbeddings
(String tenantName, String databaseName, String collectionId, ChromaApi.DeleteEmbeddingsRequest deleteRequest) getCollection
(String tenantName, String databaseName, String collectionName) getDatabase
(String tenantName, String databaseName) getEmbeddings
(String tenantName, String databaseName, String collectionId, ChromaApi.GetEmbeddingsRequest getEmbeddingsRequest) listCollections
(String tenantName, String databaseName) queryCollection
(String tenantName, String databaseName, String collectionId, ChromaApi.QueryRequest queryRequest) toEmbeddingResponseList
(ChromaApi.QueryResponse queryResponse) void
upsertEmbeddings
(String tenantName, String databaseName, String collectionId, ChromaApi.AddEmbeddingsRequest embedding) withBasicAuthCredentials
(String username, String password) Configure access to ChromaDB secured with Basic Authentication: https://docs.trychroma.com/usage-guide#basic-authenticationwithKeyToken
(String keyToken) Configure access to ChromaDB secured with static API Token Authentication: https://docs.trychroma.com/usage-guide#static-api-token-authentication
-
Constructor Details
-
ChromaApi
public ChromaApi(String baseUrl, org.springframework.web.client.RestClient.Builder restClientBuilder, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
builder
-
withKeyToken
Configure access to ChromaDB secured with static API Token Authentication: https://docs.trychroma.com/usage-guide#static-api-token-authentication- Parameters:
keyToken
- Chroma static API Token Authentication. (Optional)
-
withBasicAuthCredentials
Configure access to ChromaDB secured with Basic Authentication: https://docs.trychroma.com/usage-guide#basic-authentication- Parameters:
username
- Credentials username.password
- Credentials password.
-
toEmbeddingResponseList
public List<ChromaApi.Embedding> toEmbeddingResponseList(@Nullable ChromaApi.QueryResponse queryResponse) -
createTenant
-
getTenant
-
createDatabase
-
getDatabase
-
deleteDatabase
Delete a database with the given name.- Parameters:
tenantName
- the name of the tenant to delete.databaseName
- the name of the database to delete.
-
createCollection
@Nullable public ChromaApi.Collection createCollection(String tenantName, String databaseName, ChromaApi.CreateCollectionRequest createCollectionRequest) -
deleteCollection
Delete a collection with the given name.- Parameters:
collectionName
- the name of the collection to delete.
-
getCollection
@Nullable public ChromaApi.Collection getCollection(String tenantName, String databaseName, String collectionName) -
listCollections
-
upsertEmbeddings
public void upsertEmbeddings(String tenantName, String databaseName, String collectionId, ChromaApi.AddEmbeddingsRequest embedding) -
deleteEmbeddings
public int deleteEmbeddings(String tenantName, String databaseName, String collectionId, ChromaApi.DeleteEmbeddingsRequest deleteRequest) -
countEmbeddings
-
queryCollection
@Nullable public ChromaApi.QueryResponse queryCollection(String tenantName, String databaseName, String collectionId, ChromaApi.QueryRequest queryRequest) -
getEmbeddings
@Nullable public ChromaApi.GetEmbeddingResponse getEmbeddings(String tenantName, String databaseName, String collectionId, ChromaApi.GetEmbeddingsRequest getEmbeddingsRequest) -
where
-