Refactor chat memory repository autoconfigurations and Spring Boot starters for clarity
- Rename chat memory repository autoconfiguration modules to include the "repository" suffix:
- spring-ai-autoconfigure-model-chat-memory-cassandra -> spring-ai-autoconfigure-model-chat-memory-repository-cassandra
- spring-ai-autoconfigure-model-chat-memory-jdbc -> spring-ai-autoconfigure-model-chat-memory-repository-jdbc
- spring-ai-autoconfigure-model-chat-memory-neo4j -> spring-ai-autoconfigure-model-chat-memory-repository-neo4j
- Update Spring Boot starter modules to match the new naming convention.
- Rename packages to include `.repository.` for improved clarity and consistency.
- Rename configuration and related classes to use the `ChatMemoryRepository` suffix.
- Update Spring AI BOM and parent POM files to reference the new artifact names.
- Update all imports, references, and configuration to use the new package and class names.
BREAKING CHANGE:
These changes require users to update their dependencies, imports, and configuration to use the new artifact, package, and class names. See the upgrade notes for migration instructions.
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
This commit is contained in:
committed by
Mark Pollack
parent
ca843e8588
commit
f6dba1bf08
@@ -7,12 +7,12 @@
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../../../../pom.xml</relativePath>
|
||||
<relativePath>../../../../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-cassandra</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-cassandra</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring AI Apache Cassandra Chat Memory Auto Configuration</name>
|
||||
<description>Spring AI Apache Cassandra Chat Memory Auto Configuration</description>
|
||||
<name>Spring AI Apache Cassandra Chat Memory Repository Auto Configuration</name>
|
||||
<description>Spring AI Apache Cassandra Chat Memory Repository Auto Configuration</description>
|
||||
<url>https://github.com/spring-projects/spring-ai</url>
|
||||
|
||||
<scm>
|
||||
@@ -29,7 +29,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* {@link AutoConfiguration Auto-configuration} for {@link CassandraChatMemory}.
|
||||
* {@link AutoConfiguration Auto-configuration} for {@link CassandraChatMemoryRepository}.
|
||||
*
|
||||
* @author Mick Semb Wever
|
||||
* @author Jihoon Kim
|
||||
@@ -37,12 +37,13 @@ import org.springframework.context.annotation.Bean;
|
||||
*/
|
||||
@AutoConfiguration(after = CassandraAutoConfiguration.class, before = ChatMemoryAutoConfiguration.class)
|
||||
@ConditionalOnClass({ CassandraChatMemoryRepository.class, CqlSession.class })
|
||||
@EnableConfigurationProperties(CassandraChatMemoryProperties.class)
|
||||
public class CassandraChatMemoryAutoConfiguration {
|
||||
@EnableConfigurationProperties(CassandraChatMemoryRepositoryProperties.class)
|
||||
public class CassandraChatMemoryRepositoryAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CassandraChatMemoryRepository chatMemory(CassandraChatMemoryProperties properties, CqlSession cqlSession) {
|
||||
public CassandraChatMemoryRepository cassandraChatMemoryRepository(
|
||||
CassandraChatMemoryRepositoryProperties properties, CqlSession cqlSession) {
|
||||
|
||||
var builder = CassandraChatMemoryConfig.builder().withCqlSession(cqlSession);
|
||||
|
||||
@@ -32,12 +32,12 @@ import org.springframework.lang.Nullable;
|
||||
* @author Jihoon Kim
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ConfigurationProperties(CassandraChatMemoryProperties.CONFIG_PREFIX)
|
||||
public class CassandraChatMemoryProperties {
|
||||
@ConfigurationProperties(CassandraChatMemoryRepositoryProperties.CONFIG_PREFIX)
|
||||
public class CassandraChatMemoryRepositoryProperties {
|
||||
|
||||
public static final String CONFIG_PREFIX = "spring.ai.chat.memory.repository.cassandra";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CassandraChatMemoryProperties.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(CassandraChatMemoryRepositoryProperties.class);
|
||||
|
||||
private String keyspace = CassandraChatMemoryConfig.DEFAULT_KEYSPACE_NAME;
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
org.springframework.ai.model.chat.memory.repository.cassandra.autoconfigure.CassandraChatMemoryAutoConfiguration
|
||||
org.springframework.ai.model.chat.memory.repository.cassandra.autoconfigure.CassandraChatMemoryRepositoryAutoConfiguration
|
||||
@@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Testcontainers
|
||||
class CassandraChatMemoryAutoConfigurationIT {
|
||||
class CassandraChatMemoryRepositoryAutoConfigurationIT {
|
||||
|
||||
static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("cassandra");
|
||||
|
||||
@@ -50,8 +50,8 @@ class CassandraChatMemoryAutoConfigurationIT {
|
||||
static CassandraContainer cassandraContainer = new CassandraContainer(DEFAULT_IMAGE_NAME.withTag("5.0"));
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(CassandraChatMemoryAutoConfiguration.class, CassandraAutoConfiguration.class))
|
||||
.withConfiguration(AutoConfigurations.of(CassandraChatMemoryRepositoryAutoConfiguration.class,
|
||||
CassandraAutoConfiguration.class))
|
||||
.withPropertyValues("spring.ai.chat.memory.cassandra.keyspace=test_autoconfigure");
|
||||
|
||||
@Test
|
||||
@@ -85,7 +85,8 @@ class CassandraChatMemoryAutoConfigurationIT {
|
||||
assertThat(memory.findByConversationId(sessionId).get(0).getMessageType()).isEqualTo(MessageType.USER);
|
||||
assertThat(memory.findByConversationId(sessionId).get(0).getText()).isEqualTo("test question");
|
||||
|
||||
CassandraChatMemoryProperties properties = context.getBean(CassandraChatMemoryProperties.class);
|
||||
CassandraChatMemoryRepositoryProperties properties = context
|
||||
.getBean(CassandraChatMemoryRepositoryProperties.class);
|
||||
assertThat(properties.getTimeToLive()).isEqualTo(getTimeToLive());
|
||||
});
|
||||
}
|
||||
@@ -97,7 +98,8 @@ class CassandraChatMemoryAutoConfigurationIT {
|
||||
.withPropertyValues("spring.cassandra.localDatacenter=" + cassandraContainer.getLocalDatacenter())
|
||||
.withPropertyValues("spring.ai.chat.memory.repository.cassandra.time-to-live=" + getTimeToLiveString())
|
||||
.run(context -> {
|
||||
CassandraChatMemoryProperties properties = context.getBean(CassandraChatMemoryProperties.class);
|
||||
CassandraChatMemoryRepositoryProperties properties = context
|
||||
.getBean(CassandraChatMemoryRepositoryProperties.class);
|
||||
assertThat(properties.getTimeToLive()).isEqualTo(Duration.parse(getTimeToLiveString()));
|
||||
});
|
||||
}
|
||||
@@ -29,11 +29,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Jihoon Kim
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class CassandraChatMemoryPropertiesTest {
|
||||
class CassandraChatMemoryRepositoryPropertiesTest {
|
||||
|
||||
@Test
|
||||
void defaultValues() {
|
||||
var props = new CassandraChatMemoryProperties();
|
||||
var props = new CassandraChatMemoryRepositoryProperties();
|
||||
assertThat(props.getKeyspace()).isEqualTo(CassandraChatMemoryConfig.DEFAULT_KEYSPACE_NAME);
|
||||
assertThat(props.getTable()).isEqualTo(CassandraChatMemoryConfig.DEFAULT_TABLE_NAME);
|
||||
assertThat(props.getAssistantColumn()).isEqualTo(CassandraChatMemoryConfig.DEFAULT_ASSISTANT_COLUMN_NAME);
|
||||
@@ -44,7 +44,7 @@ class CassandraChatMemoryPropertiesTest {
|
||||
|
||||
@Test
|
||||
void customValues() {
|
||||
var props = new CassandraChatMemoryProperties();
|
||||
var props = new CassandraChatMemoryRepositoryProperties();
|
||||
props.setKeyspace("my_keyspace");
|
||||
props.setTable("my_table");
|
||||
props.setAssistantColumn("my_assistant_column");
|
||||
@@ -7,12 +7,12 @@
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../../../../pom.xml</relativePath>
|
||||
<relativePath>../../../../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-jdbc</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-jdbc</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring AI JDBC Chat Memory Auto Configuration</name>
|
||||
<description>Spring JDBC AI Chat Memory Auto Configuration</description>
|
||||
<name>Spring AI JDBC Chat Memory Repository Auto Configuration</name>
|
||||
<description>Spring JDBC AI Chat Memory Repository Auto Configuration</description>
|
||||
<url>https://github.com/spring-projects/spring-ai</url>
|
||||
|
||||
<scm>
|
||||
@@ -42,11 +42,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@EnableConfigurationProperties(JdbcChatMemoryRepositoryProperties.class)
|
||||
public class JdbcChatMemoryRepositoryAutoConfiguration {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JdbcChatMemoryRepositoryAutoConfiguration.class);
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
JdbcChatMemoryRepository chatMemoryRepository(JdbcTemplate jdbcTemplate, DataSource dataSource) {
|
||||
JdbcChatMemoryRepository jdbcChatMemoryRepository(JdbcTemplate jdbcTemplate, DataSource dataSource) {
|
||||
JdbcChatMemoryDialect dialect = JdbcChatMemoryDialect.from(dataSource);
|
||||
return JdbcChatMemoryRepository.builder().jdbcTemplate(jdbcTemplate).dialect(dialect).build();
|
||||
}
|
||||
@@ -7,12 +7,12 @@
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../../../../pom.xml</relativePath>
|
||||
<relativePath>../../../../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-neo4j</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-neo4j</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring AI Neo4j Chat Memory Auto Configuration</name>
|
||||
<description>Spring Neo4j AI Chat Memory Auto Configuration</description>
|
||||
<name>Spring AI Neo4j Chat Memory Repository Auto Configuration</name>
|
||||
<description>Spring Neo4j AI Chat Memory Repository Auto Configuration</description>
|
||||
<url>https://github.com/spring-projects/spring-ai</url>
|
||||
|
||||
<scm>
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.model.chat.memory.neo4j.autoconfigure;
|
||||
package org.springframework.ai.model.chat.memory.repository.neo4j.autoconfigure;
|
||||
|
||||
import org.neo4j.driver.Driver;
|
||||
|
||||
@@ -36,12 +36,13 @@ import org.springframework.context.annotation.Bean;
|
||||
*/
|
||||
@AutoConfiguration(after = Neo4jAutoConfiguration.class, before = ChatMemoryAutoConfiguration.class)
|
||||
@ConditionalOnClass({ Neo4jChatMemoryRepository.class, Driver.class })
|
||||
@EnableConfigurationProperties(Neo4jChatMemoryProperties.class)
|
||||
public class Neo4jChatMemoryAutoConfiguration {
|
||||
@EnableConfigurationProperties(Neo4jChatMemoryRepositoryProperties.class)
|
||||
public class Neo4jChatMemoryRepositoryAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Neo4jChatMemoryRepository chatMemoryRepository(Neo4jChatMemoryProperties properties, Driver driver) {
|
||||
public Neo4jChatMemoryRepository neo4jChatMemoryRepository(Neo4jChatMemoryRepositoryProperties properties,
|
||||
Driver driver) {
|
||||
|
||||
var builder = Neo4jChatMemoryConfig.builder()
|
||||
.withMediaLabel(properties.getMediaLabel())
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.model.chat.memory.neo4j.autoconfigure;
|
||||
package org.springframework.ai.model.chat.memory.repository.neo4j.autoconfigure;
|
||||
|
||||
import org.springframework.ai.chat.memory.neo4j.Neo4jChatMemoryConfig;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -24,8 +24,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
*
|
||||
* @author Enrico Rampazzo
|
||||
*/
|
||||
@ConfigurationProperties(Neo4jChatMemoryProperties.CONFIG_PREFIX)
|
||||
public class Neo4jChatMemoryProperties {
|
||||
@ConfigurationProperties(Neo4jChatMemoryRepositoryProperties.CONFIG_PREFIX)
|
||||
public class Neo4jChatMemoryRepositoryProperties {
|
||||
|
||||
public static final String CONFIG_PREFIX = "spring.ai.chat.memory.neo4j";
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
org.springframework.ai.model.chat.memory.neo4j.autoconfigure.Neo4jChatMemoryAutoConfiguration
|
||||
org.springframework.ai.model.chat.memory.repository.neo4j.autoconfigure.Neo4jChatMemoryRepositoryAutoConfiguration
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.model.chat.memory.neo4j.autoconfigure;
|
||||
package org.springframework.ai.model.chat.memory.repository.neo4j.autoconfigure;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -26,11 +26,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Enrico Rampazzo
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Neo4jChatMemoryPropertiesTest {
|
||||
class Neo4JChatMemoryRepositoryPropertiesTest {
|
||||
|
||||
@Test
|
||||
void defaultValues() {
|
||||
var props = new Neo4jChatMemoryProperties();
|
||||
var props = new Neo4jChatMemoryRepositoryProperties();
|
||||
assertThat(props.getMediaLabel()).isEqualTo(Neo4jChatMemoryConfig.DEFAULT_MEDIA_LABEL);
|
||||
assertThat(props.getMessageLabel()).isEqualTo(Neo4jChatMemoryConfig.DEFAULT_MESSAGE_LABEL);
|
||||
assertThat(props.getMetadataLabel()).isEqualTo(Neo4jChatMemoryConfig.DEFAULT_METADATA_LABEL);
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.model.chat.memory.neo4j.autoconfigure;
|
||||
package org.springframework.ai.model.chat.memory.repository.neo4j.autoconfigure;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -23,7 +23,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.ai.chat.memory.ChatMemory;
|
||||
|
||||
import org.springframework.ai.chat.memory.ChatMemoryRepository;
|
||||
import org.springframework.ai.chat.memory.neo4j.Neo4jChatMemoryRepository;
|
||||
import org.testcontainers.containers.Neo4jContainer;
|
||||
@@ -63,8 +63,8 @@ class Neo4jChatMemoryRepositoryAutoConfigurationIT {
|
||||
.withoutAuthentication()
|
||||
.withExposedPorts(7474, 7687);
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(Neo4jChatMemoryAutoConfiguration.class, Neo4jAutoConfiguration.class));
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(
|
||||
AutoConfigurations.of(Neo4jChatMemoryRepositoryAutoConfiguration.class, Neo4jAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void addAndGet() {
|
||||
13
pom.xml
13
pom.xml
@@ -87,9 +87,9 @@
|
||||
<module>auto-configurations/models/chat/client/spring-ai-autoconfigure-model-chat-client</module>
|
||||
|
||||
<module>auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory</module>
|
||||
<module>auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-cassandra</module>
|
||||
<module>auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-jdbc</module>
|
||||
<module>auto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-neo4j</module>
|
||||
<module>auto-configurations/models/chat/memory/repository/spring-ai-autoconfigure-model-chat-memory-repository-cassandra</module>
|
||||
<module>auto-configurations/models/chat/memory/repository/spring-ai-autoconfigure-model-chat-memory-repository-jdbc</module>
|
||||
<module>auto-configurations/models/chat/memory/repository/spring-ai-autoconfigure-model-chat-memory-repository-neo4j</module>
|
||||
|
||||
<module>auto-configurations/models/chat/observation/spring-ai-autoconfigure-model-chat-observation</module>
|
||||
|
||||
@@ -180,9 +180,6 @@
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-azure-openai</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-bedrock</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-bedrock-converse</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-chat-memory-cassandra</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-chat-memory-jdbc</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-chat-memory-neo4j</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-huggingface</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-minimax</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-mistral-ai</module>
|
||||
@@ -197,6 +194,10 @@
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-zhipuai</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-deepseek</module>
|
||||
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-chat-memory-repository-cassandra</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-chat-memory-repository-jdbc</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-model-chat-memory-repository-neo4j</module>
|
||||
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-mcp-client</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-mcp-server</module>
|
||||
<module>spring-ai-spring-boot-starters/spring-ai-starter-mcp-client-webflux</module>
|
||||
|
||||
@@ -481,21 +481,23 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring AI Chat memory Repository auto-configurations -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-cassandra</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-cassandra</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-jdbc</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-jdbc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-neo4j</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-neo4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -1017,23 +1019,23 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring AI Spring Boot starters for Chat Memory -->
|
||||
<!-- Spring AI Spring Boot starters for Chat Memory Repository -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-cassandra</artifactId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-repository-cassandra</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-jdbc</artifactId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-repository-jdbc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-neo4j</artifactId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-repository-neo4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -528,43 +528,15 @@ This allows you to tailor the logged information to your specific needs.
|
||||
|
||||
TIP: Be cautious about logging sensitive information in production environments.
|
||||
|
||||
== Chat Memory (Deprecated)
|
||||
|
||||
IMPORTANT: Refer to the new xref:api/chat-memory.adoc[Chat Memory] documentation for the current features and capabilities.
|
||||
== Chat Memory
|
||||
|
||||
The interface `ChatMemory` represents a storage for chat conversation history. It provides methods to add messages to a conversation, retrieve messages from a conversation, and clear the conversation history.
|
||||
|
||||
There are currently four implementations: `CassandraChatMemory`, `Neo4jChatMemory`, and `JdbcChatMemory`, which provide storage for chat conversation history in-memory, persisted with `time-to-live` in Cassandra, and persisted without `time-to-live` in Neo4j and Jdbc, respectively.
|
||||
There is currently one implementation: `MessageWindowChatMemory`.
|
||||
|
||||
=== CassandraChatMemory
|
||||
`MessageWindowChatMemory` is a chat memory implementation that maintains a window of messages up to a specified maximum size (default: 20 messages). When the number of messages exceeds this limit, older messages are evicted, but system messages are preserved. If a new system message is added, all previous system messages are removed from memory. This ensures that the most recent context is always available for the conversation while keeping memory usage bounded.
|
||||
|
||||
To create a `CassandraChatMemory` with `time-to-live`:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
CassandraChatMemory.create(CassandraChatMemoryConfig.builder().withTimeToLive(Duration.ofDays(1)).build());
|
||||
----
|
||||
The `MessageWindowChatMemory` is backed by the `ChatMemoryRepository` abstraction which provides storage implementations for the chat conversation history. There are several implementations available, including the `InMemoryChatMemoryRepository`, `JdbcChatMemoryRepository`, `CassandraChatMemoryRepository` and `Neo4jChatMemoryRepository`.
|
||||
|
||||
IMPORTANT: Refer to the new xref:api/chat-memory.adoc#_cassandra_repository[Cassandra Chat Memory Repository] documentation for the current features and capabilities.
|
||||
|
||||
=== Neo4jChatMemory
|
||||
|
||||
The Neo4j chat memory supports the following configuration parameters:
|
||||
|
||||
[cols="2,5,1",stripes=even]
|
||||
|===
|
||||
|Property | Description | Default Value
|
||||
|
||||
| `spring.ai.chat.memory.neo4j.messageLabel` | The label for the nodes that store messages | `Message`
|
||||
| `spring.ai.chat.memory.neo4j.sessionLabel` | The label for the nodes that store conversation sessions | `Session`
|
||||
| `spring.ai.chat.memory.neo4j.toolCallLabel` | The label for nodes that store tool calls, for example
|
||||
in Assistant Messages | `ToolCall`
|
||||
| `spring.ai.chat.memory.neo4j.metadataLabel` | The label for the node that store a message metadata | `Metadata`
|
||||
| `spring.ai.chat.memory.neo4j.toolResponseLabel` | The label for the nodes that store tool responses | `ToolResponse`
|
||||
| `spring.ai.chat.memory.neo4j.mediaLabel` | The label for the nodes that store the media associated to a message | `ToolResponse`
|
||||
|
||||
|===
|
||||
|
||||
=== JdbcChatMemory
|
||||
|
||||
IMPORTANT: Refer to the new xref:api/chat-memory.adoc#_jdbc_repository[JDBC Chat Memory Repository] documentation for the current features and capabilities.
|
||||
This implementation is the default for conversation history management in Spring AI. For more details and usage examples, see the xref:api/chat-memory.adoc[Chat Memory] section.
|
||||
|
||||
@@ -55,6 +55,19 @@ If you were providing custom templates for the following advisors, you'll need t
|
||||
The Watson AI model was removed as it was based on the older text generation that is considered outdated as there is a new chat generation model available.
|
||||
Hopefully Watson will reappear in a future version of Spring AI
|
||||
|
||||
==== Chat Memory Repository Module and Autoconfiguration Renaming
|
||||
|
||||
In 1.0.0-RC1, the chat memory modules, starters, and autoconfiguration classes for Cassandra, JDBC, and Neo4j have been renamed to include the `repository` suffix for clarity. This impacts artifact IDs, Java package names, and class names. For example:
|
||||
|
||||
- Artifact IDs:
|
||||
- `spring-ai-autoconfigure-model-chat-memory-jdbc` → `spring-ai-autoconfigure-model-chat-memory-repository-jdbc`
|
||||
- `spring-ai-starter-model-chat-memory-jdbc` → `spring-ai-starter-model-chat-memory-repository-jdbc`
|
||||
- Java packages now use `.repository.` (e.g., `org.springframework.ai.model.chat.memory.repository.jdbc.autoconfigure`).
|
||||
- Main autoconfiguration classes are now named `JdbcChatMemoryRepositoryAutoConfiguration`, `CassandraChatMemoryRepositoryAutoConfiguration`, etc.
|
||||
|
||||
**Migration Required:**
|
||||
- Update your Maven/Gradle dependencies to use the new artifact IDs.
|
||||
- Update any imports, class references, or configuration that used the old package or class names.
|
||||
|
||||
|
||||
[[upgrading-to-1-0-0-m8]]
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-cassandra</artifactId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-repository-cassandra</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring AI Starter - Cassandra Chat Memory</name>
|
||||
<description>Spring AI Cassandra Chat Memory Starter</description>
|
||||
<name>Spring AI Starter - Cassandra Chat Memory Repository</name>
|
||||
<description>Spring AI Cassandra Chat Memory Repository Starter</description>
|
||||
<url>https://github.com/spring-projects/spring-ai</url>
|
||||
|
||||
<scm>
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-cassandra</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-cassandra</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-jdbc</artifactId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-repository-jdbc</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring AI Starter - JDBC Chat Memory</name>
|
||||
<description>Spring AI JDBC Chat Memory Starter</description>
|
||||
<name>Spring AI Starter - JDBC Chat Memory Repository</name>
|
||||
<description>Spring AI JDBC Chat Memory Repository Starter</description>
|
||||
<url>https://github.com/spring-projects/spring-ai</url>
|
||||
|
||||
<scm>
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-jdbc</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-jdbc</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-neo4j</artifactId>
|
||||
<artifactId>spring-ai-starter-model-chat-memory-repository-neo4j</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring AI Starter - Neo4j Chat Memory</name>
|
||||
<description>Spring AI Neo4j Chat Memory Starter</description>
|
||||
<name>Spring AI Starter - Neo4j Chat Memory Repository</name>
|
||||
<description>Spring AI Neo4j Chat Memory Repository Starter</description>
|
||||
<url>https://github.com/spring-projects/spring-ai</url>
|
||||
|
||||
<scm>
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-neo4j</artifactId>
|
||||
<artifactId>spring-ai-autoconfigure-model-chat-memory-repository-neo4j</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
Reference in New Issue
Block a user