Fix null issues with custom observation convention

- Relax null constraints for custom observation convention in AbstractVectorStoreBuilder
This commit is contained in:
Soby Chacko
2024-12-06 18:13:58 -05:00
parent a8dda0a8f1
commit 6307377ef5
2 changed files with 4 additions and 8 deletions

View File

@@ -72,7 +72,6 @@ public abstract class AbstractVectorStoreBuilder<T extends AbstractVectorStoreBu
@Override
public T customObservationConvention(VectorStoreObservationConvention convention) {
Assert.notNull(convention, "VectorStoreObservationConvention must not be null");
this.customObservationConvention = convention;
return self();
}

View File

@@ -86,17 +86,14 @@ public class ChromaVectorStoreAutoConfiguration {
ChromaVectorStoreProperties storeProperties, ObjectProvider<ObservationRegistry> observationRegistry,
ObjectProvider<VectorStoreObservationConvention> customObservationConvention,
BatchingStrategy chromaBatchingStrategy) {
ChromaVectorStore.ChromaBuilder chromaBuilder = ChromaVectorStore.builder(chromaApi)
return ChromaVectorStore.builder(chromaApi)
.embeddingModel(embeddingModel)
.collectionName(storeProperties.getCollectionName())
.initializeSchema(storeProperties.isInitializeSchema())
.observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP))
.batchingStrategy(chromaBatchingStrategy);
VectorStoreObservationConvention observationConvention = customObservationConvention.getIfAvailable();
if (observationConvention != null) {
chromaBuilder.customObservationConvention(observationConvention);
}
return chromaBuilder.build();
.customObservationConvention(customObservationConvention.getIfAvailable(() -> null))
.batchingStrategy(chromaBatchingStrategy)
.build();
}
static class PropertiesChromaConnectionDetails implements ChromaConnectionDetails {