diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/chroma.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/chroma.adoc index e682aaae5ed..5de26b5665c 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/chroma.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/chroma.adoc @@ -6,7 +6,9 @@ link:https://docs.trychroma.com/[Chroma] is the open-source embedding database. == Prerequisites -1. Access to ChromeDB. The <> appendix shows how to set up a DB locally with a Docker container. +1. Access to ChromaDB. Compatible with link:https://trychroma.com/signup[Chroma Cloud], or <> in the appendix shows how to set up a DB locally with a Docker container. + - For Chroma Cloud: You'll need your API key, tenant name, and database name from your Chroma Cloud dashboard. + - For local ChromaDB: No additional configuration required beyond starting the container. 2. `EmbeddingModel` instance to compute the document embeddings. Several options are available: - If required, an API key for the xref:api/embeddings.adoc#available-implementations[EmbeddingModel] to generate the embeddings stored by the `ChromaVectorStore`. @@ -72,12 +74,16 @@ A simple configuration can either be provided via Spring Boot's _application.pro [source,properties] ---- # Chroma Vector Store connection properties -spring.ai.vectorstore.chroma.client.host= -spring.ai.vectorstore.chroma.client.port= -spring.ai.vectorstore.chroma.client.key-token= +spring.ai.vectorstore.chroma.client.host= // for Chroma Cloud: api.trychroma.com +spring.ai.vectorstore.chroma.client.port= // for Chroma Cloud: 443 +spring.ai.vectorstore.chroma.client.key-token= // for Chroma Cloud: use the API key spring.ai.vectorstore.chroma.client.username= spring.ai.vectorstore.chroma.client.password= +# Chroma Vector Store tenant and database properties (required for Chroma Cloud) +spring.ai.vectorstore.chroma.tenant-name= // default: SpringAiTenant +spring.ai.vectorstore.chroma.database-name= // default: SpringAiDatabase + # Chroma Vector Store collection properties spring.ai.vectorstore.chroma.initialize-schema= spring.ai.vectorstore.chroma.collection-name= @@ -123,8 +129,10 @@ You can use the following properties in your Spring Boot configuration to custom |`spring.ai.vectorstore.chroma.client.key-token`| Access token (if configured) | - |`spring.ai.vectorstore.chroma.client.username`| Access username (if configured) | - |`spring.ai.vectorstore.chroma.client.password`| Access password (if configured) | - +|`spring.ai.vectorstore.chroma.tenant-name`| Tenant (required for Chroma Cloud) | `SpringAiTenant` +|`spring.ai.vectorstore.chroma.database-name`| Database name (required for Chroma Cloud) | `SpringAiDatabase` |`spring.ai.vectorstore.chroma.collection-name`| Collection name | `SpringAiCollection` -|`spring.ai.vectorstore.chroma.initialize-schema`| Whether to initialize the required schema | `false` +|`spring.ai.vectorstore.chroma.initialize-schema`| Whether to initialize the required schema (creates tenant/database/collection if they don't exist) | `false` |=== [NOTE] @@ -134,6 +142,36 @@ For ChromaDB secured with link:https://docs.trychroma.com/usage-guide#static-api For ChromaDB secured with link:https://docs.trychroma.com/usage-guide#basic-authentication[Basic Authentication] use the `ChromaApi#withBasicAuth(, )` method to set your credentials. Check the `BasicAuthChromaWhereIT` for an example. ==== +=== Chroma Cloud Configuration + +For Chroma Cloud, you need to provide the tenant and database names from your Chroma Cloud instance. Here's an example configuration: + +[source,properties] +---- +# Chroma Cloud connection +spring.ai.vectorstore.chroma.client.host=api.trychroma.com +spring.ai.vectorstore.chroma.client.port=443 +spring.ai.vectorstore.chroma.client.key-token= + +# Chroma Cloud tenant and database (required) +spring.ai.vectorstore.chroma.tenant-name= +spring.ai.vectorstore.chroma.database-name= + +# Collection configuration +spring.ai.vectorstore.chroma.collection-name=my-collection +spring.ai.vectorstore.chroma.initialize-schema=true +---- + +[NOTE] +==== +For Chroma Cloud: +- The host should be `api.trychroma.com` +- The port should be `443` (HTTPS) +- You must provide your API key via `key-token` +- The tenant and database names must match your Chroma Cloud configuration +- Set `initialize-schema=true` to automatically create the collection if it doesn't exist (it won't recreate existing tenant/database) +==== + == Metadata filtering You can leverage the generic, portable link:https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_metadata_filters[metadata filters] with ChromaVector store as well. @@ -238,6 +276,8 @@ Integrate with OpenAI's embeddings by adding the Spring Boot OpenAI starter to y @Bean public VectorStore chromaVectorStore(EmbeddingModel embeddingModel, ChromaApi chromaApi) { return ChromaVectorStore.builder(chromaApi, embeddingModel) + .tenantName("your-tenant-name") // default: SpringAiTenant + .databaseName("your-database-name") // default: SpringAiDatabase .collectionName("TestCollection") .initializeSchema(true) .build();