Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023-2025 the original author or authors.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>spring-ai-autoconfigure-vector-store-infinispan</artifactId>
<packaging>jar</packaging>
<name>Spring AI Auto Configuration for Infinispan vector store</name>
<description>Spring AI Auto Configuration for Infinispan vector store</description>
<url>https://github.com/spring-projects/spring-ai</url>

<scm>
<url>https://github.com/spring-projects/spring-ai</url>
<connection>git://github.com/spring-projects/spring-ai.git</connection>
<developerConnection>git@github.com:spring-projects/spring-ai.git</developerConnection>
</scm>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-bom</artifactId>
<version>${infinispan.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- production dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-infinispan-store</artifactId>
<version>${project.parent.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-spring-boot4-starter-remote</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-test</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>testcontainers-infinispan</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-transformers</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<!-- Uncomment for mac-->
<!-- <dependency>-->
<!-- <groupId>ai.djl.huggingface</groupId>-->
<!-- <artifactId>tokenizers</artifactId>-->
<!-- <version>0.28.0</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>ai.djl.pytorch</groupId>-->
<!-- <artifactId>pytorch-engine</artifactId>-->
<!-- <version>0.28.0</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.vectorstore.infinispan.autoconfigure;

import io.micrometer.observation.ObservationRegistry;
import org.infinispan.client.hotrod.RemoteCacheManager;

import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes;
import org.springframework.ai.vectorstore.infinispan.InfinispanVectorStore;
import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
* {@link AutoConfiguration Auto-configuration} for Infinispan Vector Store.
*
* @author Katia Aresti
*/
@AutoConfiguration
@ConditionalOnClass({ InfinispanVectorStore.class, EmbeddingModel.class })
@EnableConfigurationProperties(InfinispanVectorStoreProperties.class)
@ConditionalOnProperty(name = SpringAIVectorStoreTypes.TYPE, havingValue = SpringAIVectorStoreTypes.GEMFIRE,
matchIfMissing = true)
public class InfinispanVectorStoreAutoConfiguration {

@Bean
@ConditionalOnMissingBean
public InfinispanVectorStore infinispanVectorStore(EmbeddingModel embeddingModel,
InfinispanVectorStoreProperties properties, RemoteCacheManager infinispanClient,
ObjectProvider<ObservationRegistry> observationRegistry,
ObjectProvider<VectorStoreObservationConvention> customObservationConvention) {

return InfinispanVectorStore.builder(infinispanClient, embeddingModel)
.createStore(properties.isCreateStore())
.registerSchema(properties.isRegisterSchema())
.schemaFileName(properties.getSchemaFileName())
.storeName(properties.getStoreName())
.storeConfig(properties.getStoreConfig())
.observationRegistry(observationRegistry.getIfAvailable())
.customObservationConvention(customObservationConvention.getIfAvailable())
.distance(properties.getDistance())
.similarity(properties.getSimilarity())
.packageName(properties.getPackageName())
.springAiItemName(properties.getItemName())
.metadataItemName(properties.getMetadataItemName())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.vectorstore.infinispan.autoconfigure;

import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

import static org.springframework.ai.vectorstore.infinispan.autoconfigure.InfinispanVectorStoreProperties.CONFIG_PREFIX;

/**
* Configuration properties for Infinispan Vector Store.
*/
@ConfigurationProperties(prefix = CONFIG_PREFIX)
public class InfinispanVectorStoreProperties extends CommonVectorStoreProperties {

/**
* Configuration prefix for Spring AI VectorStore Infinispan.
*/
public static final String CONFIG_PREFIX = "spring.ai.vectorstore.infinispan";

private Boolean registerSchema;

private Boolean createStore;

private String storeName;

private String storeConfig;

private Integer distance;

private String similarity;

private String schemaFileName;

private String packageName;

private String itemName;

private String metadataItemName;

public String getStoreName() {
return storeName;
}

public void setStoreName(String storeName) {
this.storeName = storeName;
}

public String getStoreConfig() {
return storeConfig;
}

public void setStoreConfig(String storeConfig) {
this.storeConfig = storeConfig;
}

public Integer getDistance() {
return distance;
}

public void setDistance(Integer distance) {
this.distance = distance;
}

public String getSimilarity() {
return similarity;
}

public void setSimilarity(String similarity) {
this.similarity = similarity;
}

public String getSchemaFileName() {
return schemaFileName;
}

public void setSchemaFileName(String schemaFileName) {
this.schemaFileName = schemaFileName;
}

public String getPackageName() {
return packageName;
}

public void setPackageName(String packageName) {
this.packageName = packageName;
}

public String getItemName() {
return itemName;
}

public void setItemName(String itemName) {
this.itemName = itemName;
}

public String getMetadataItemName() {
return metadataItemName;
}

public void setMetadataItemName(String metadataItemName) {
this.metadataItemName = metadataItemName;
}

public Boolean isRegisterSchema() {
return registerSchema;
}

public void setRegisterSchema(Boolean registerSchema) {
this.registerSchema = registerSchema;
}

public Boolean isCreateStore() {
return createStore;
}

public void setCreateStore(boolean createStore) {
this.createStore = createStore;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright 2025-2025 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.springframework.ai.vectorstore.infinispan.autoconfigure.InfinispanVectorStoreAutoConfiguration
Loading