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 recordAdd embeddings to the chroma data store.static final classstatic final recordChroma embedding collection.static final recordRequest to create a new collection with the given name and metadata.static final recordRequest to create a new databasestatic final recordRequest to create a new tenantstatic final recordChroma database.static final recordRequest to delete embedding from a collection.static final recordSingle query embedding response.static final recordObject containing the get embedding results.static final recordGet embeddings from a collection.static final recordRequest to get the nResults nearest neighbor embeddings for provided queryEmbeddings.static final recordA QueryResponse object containing the query results.static final recordChroma tenant. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ChromaApi.Builderbuilder()@Nullable LongcountEmbeddings(String tenantName, String databaseName, String collectionId) @Nullable ChromaApi.CollectioncreateCollection(String tenantName, String databaseName, ChromaApi.CreateCollectionRequest createCollectionRequest) voidcreateDatabase(String tenantName, String databaseName) voidcreateTenant(String tenantName) voiddeleteCollection(String tenantName, String databaseName, String collectionName) Delete a collection with the given name.voiddeleteDatabase(String tenantName, String databaseName) Delete a database with the given name.intdeleteEmbeddings(String tenantName, String databaseName, String collectionId, ChromaApi.DeleteEmbeddingsRequest deleteRequest) @Nullable ChromaApi.CollectiongetCollection(String tenantName, String databaseName, String collectionName) @Nullable ChromaApi.DatabasegetDatabase(String tenantName, String databaseName) @Nullable ChromaApi.GetEmbeddingResponsegetEmbeddings(String tenantName, String databaseName, String collectionId, ChromaApi.GetEmbeddingsRequest getEmbeddingsRequest) @Nullable ChromaApi.Tenant@Nullable List<ChromaApi.Collection> listCollections(String tenantName, String databaseName) @Nullable ChromaApi.QueryResponsequeryCollection(String tenantName, String databaseName, String collectionId, ChromaApi.QueryRequest queryRequest) toEmbeddingResponseList(@Nullable ChromaApi.QueryResponse queryResponse) voidupsertEmbeddings(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, tools.jackson.databind.json.JsonMapper jsonMapper)
-
-
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
public @Nullable 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
public @Nullable 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
public @Nullable ChromaApi.QueryResponse queryCollection(String tenantName, String databaseName, String collectionId, ChromaApi.QueryRequest queryRequest) -
getEmbeddings
public @Nullable ChromaApi.GetEmbeddingResponse getEmbeddings(String tenantName, String databaseName, String collectionId, ChromaApi.GetEmbeddingsRequest getEmbeddingsRequest) -
where
-