Skip to content

Commit

Permalink
Fix issue with CosmosDBVectorStore.Builder where the different Assert…
Browse files Browse the repository at this point in the history
….hasText(..., "... must not be empty") evaluates the current value (null) rather than the argument passes to each builder function. Fix issue where partitionKeyPath is required, yet is never configured via CosmosDBVectorStoreAutoConfiguration

Signed-off-by: Jonas Muribø <[email protected]>
  • Loading branch information
jonasmuriboe authored and ilayaperumalg committed Feb 17, 2025
1 parent fd9f388 commit fcc56f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public CosmosDBVectorStore cosmosDBVectorStore(ObservationRegistry observationRe
.metadataFields(List.of(properties.getMetadataFields()))
.vectorStoreThroughput(properties.getVectorStoreThroughput())
.vectorDimensions(properties.getVectorDimensions())
.partitionKeyPath(properties.getPartitionKeyPath())
.build();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ private Builder(CosmosAsyncClient cosmosClient, EmbeddingModel embeddingModel) {
* @throws IllegalArgumentException if containerName is null or empty
*/
public Builder containerName(String containerName) {
Assert.hasText(this.containerName, "Container name must not be empty");
Assert.hasText(containerName, "Container name must not be empty");
this.containerName = containerName;
return this;
}
Expand All @@ -428,7 +428,7 @@ public Builder containerName(String containerName) {
* @throws IllegalArgumentException if databaseName is null or empty
*/
public Builder databaseName(String databaseName) {
Assert.hasText(this.databaseName, "Database name must not be empty");
Assert.hasText(databaseName, "Database name must not be empty");
this.databaseName = databaseName;
return this;
}
Expand All @@ -440,7 +440,7 @@ public Builder databaseName(String databaseName) {
* @throws IllegalArgumentException if partitionKeyPath is null or empty
*/
public Builder partitionKeyPath(String partitionKeyPath) {
Assert.hasText(this.partitionKeyPath, "Partition key path must not be empty");
Assert.hasText(partitionKeyPath, "Partition key path must not be empty");
this.partitionKeyPath = partitionKeyPath;
return this;
}
Expand All @@ -452,7 +452,7 @@ public Builder partitionKeyPath(String partitionKeyPath) {
* @throws IllegalArgumentException if vectorStoreThroughput is not positive
*/
public Builder vectorStoreThroughput(int vectorStoreThroughput) {
Assert.isTrue(this.vectorStoreThroughput > 0, "Vector store throughput must be positive");
Assert.isTrue(vectorStoreThroughput > 0, "Vector store throughput must be positive");
this.vectorStoreThroughput = vectorStoreThroughput;
return this;
}
Expand All @@ -464,7 +464,7 @@ public Builder vectorStoreThroughput(int vectorStoreThroughput) {
* @throws IllegalArgumentException if vectorDimensions is not positive
*/
public Builder vectorDimensions(long vectorDimensions) {
Assert.isTrue(this.vectorDimensions > 0, "Vector dimensions must be positive");
Assert.isTrue(vectorDimensions > 0, "Vector dimensions must be positive");
this.vectorDimensions = vectorDimensions;
return this;
}
Expand Down

0 comments on commit fcc56f4

Please sign in to comment.