Skip to content

Commit a8dda0a

Browse files
committed
fix: Chroma VectorStore auto configuration
- Add null check for the Chroma vector store ObservationConvention - Since the builder enforces non null check, the ChromaVectorStore builder in its autoconfiguration will only set the ObservationConvention if it is not null.
1 parent 2ef4559 commit a8dda0a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/chroma/ChromaVectorStoreAutoConfiguration.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,17 @@ public ChromaVectorStore vectorStore(EmbeddingModel embeddingModel, ChromaApi ch
8686
ChromaVectorStoreProperties storeProperties, ObjectProvider<ObservationRegistry> observationRegistry,
8787
ObjectProvider<VectorStoreObservationConvention> customObservationConvention,
8888
BatchingStrategy chromaBatchingStrategy) {
89-
return ChromaVectorStore.builder(chromaApi)
89+
ChromaVectorStore.ChromaBuilder chromaBuilder = ChromaVectorStore.builder(chromaApi)
9090
.embeddingModel(embeddingModel)
9191
.collectionName(storeProperties.getCollectionName())
9292
.initializeSchema(storeProperties.isInitializeSchema())
9393
.observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP))
94-
.customObservationConvention(customObservationConvention.getIfAvailable(() -> null))
95-
.batchingStrategy(chromaBatchingStrategy)
96-
.build();
94+
.batchingStrategy(chromaBatchingStrategy);
95+
VectorStoreObservationConvention observationConvention = customObservationConvention.getIfAvailable();
96+
if (observationConvention != null) {
97+
chromaBuilder.customObservationConvention(observationConvention);
98+
}
99+
return chromaBuilder.build();
97100
}
98101

99102
static class PropertiesChromaConnectionDetails implements ChromaConnectionDetails {

0 commit comments

Comments
 (0)