-
Notifications
You must be signed in to change notification settings - Fork 2k
Cassandra vector store builder refactoring #1912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,8 +25,7 @@ | |
| import org.springframework.ai.embedding.BatchingStrategy; | ||
| import org.springframework.ai.embedding.EmbeddingModel; | ||
| import org.springframework.ai.embedding.TokenCountBatchingStrategy; | ||
| import org.springframework.ai.vectorstore.CassandraVectorStore; | ||
| import org.springframework.ai.vectorstore.CassandraVectorStoreConfig; | ||
| import org.springframework.ai.vectorstore.cassandra.CassandraVectorStore; | ||
| import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; | ||
| import org.springframework.beans.factory.ObjectProvider; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
|
|
@@ -63,25 +62,21 @@ public CassandraVectorStore vectorStore(EmbeddingModel embeddingModel, Cassandra | |
| ObjectProvider<VectorStoreObservationConvention> customObservationConvention, | ||
| BatchingStrategy batchingStrategy) { | ||
|
|
||
| var builder = CassandraVectorStoreConfig.builder().withCqlSession(cqlSession); | ||
|
|
||
| builder = builder.withKeyspaceName(properties.getKeyspace()) | ||
| .withTableName(properties.getTable()) | ||
| .withContentColumnName(properties.getContentColumnName()) | ||
| .withEmbeddingColumnName(properties.getEmbeddingColumnName()) | ||
| .withIndexName(properties.getIndexName()) | ||
| .withFixedThreadPoolExecutorSize(properties.getFixedThreadPoolExecutorSize()); | ||
|
|
||
| if (!properties.isInitializeSchema()) { | ||
| builder = builder.disallowSchemaChanges(); | ||
| } | ||
| if (properties.getReturnEmbeddings()) { | ||
| builder = builder.returnEmbeddings(); | ||
| } | ||
|
|
||
| return new CassandraVectorStore(builder.build(), embeddingModel, | ||
| observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP), | ||
| customObservationConvention.getIfAvailable(() -> null), batchingStrategy); | ||
| return CassandraVectorStore.builder() | ||
| .session(cqlSession) | ||
| .keyspace(properties.getKeyspace()) | ||
| .table(properties.getTable()) | ||
| .contentColumnName(properties.getContentColumnName()) | ||
| .embeddingColumnName(properties.getEmbeddingColumnName()) | ||
| .indexName(properties.getIndexName()) | ||
| .fixedThreadPoolExecutorSize(properties.getFixedThreadPoolExecutorSize()) | ||
| .disallowSchemaChanges(!properties.isInitializeSchema()) | ||
| .returnEmbeddings(properties.getReturnEmbeddings()) | ||
|
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a behaviour change here, in that we're no longer respecting the builder's default, imposing the autoConfiguration's default over it. (the builder's default should be canonical) i'm not sure how important this is… 🤷 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, we should be consistent. I'll create a new issue to capture this and discuss. |
||
| .embeddingModel(embeddingModel) | ||
| .observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP)) | ||
| .customObservationConvention(customObservationConvention.getIfAvailable(() -> null)) | ||
| .batchingStrategy(batchingStrategy) | ||
| .build(); | ||
| } | ||
|
|
||
| @Bean | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are all vectorstore modules moving their classes to subpackages ? (i don't see that yet with pgvector. has there been some discussion/agreement to this somewhere we can link to ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we are in the process of moving the vector store classes under that structure - in this case -
org.springframework.ai.chat.memory.cassandraandspringframework.ai.vectorstore.cassandra. The issue was that the vector store classes currently use the same package name in all the different modules -springframework.ai.vectorstore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was hoping that there was some link you could provide to where the discussion had been had and landed on that conclusion and action. but it's ok, i trust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next time we will reach out to you, i wish we had a more centralized way to communicate changes to frequent contributors. we are working on this.