Refactor Cassandra ChatMemory Autoconfiguration

- Move Cassandra ChatMemory autoconfiguration into dedicated autoconfiguration

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
This commit is contained in:
Ilayaperumal Gopinathan
2025-03-26 20:02:43 +00:00
parent 1d4bde80e5
commit 00b0aab828
8 changed files with 17 additions and 46 deletions

View File

@@ -9,10 +9,10 @@
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../../../../pom.xml</relativePath>
</parent>
<artifactId>spring-ai-autoconfigure-model-chat-memory</artifactId>
<artifactId>spring-ai-autoconfigure-model-chat-memory-cassandra</artifactId>
<packaging>jar</packaging>
<name>Spring AI Chat Memory Auto Configuration</name>
<description>Spring AI Chat Memory Auto Configuration</description>
<name>Spring AI Cassandra Chat Memory Auto Configuration</name>
<description>Spring AI Cassandra Chat Memory Auto Configuration</description>
<url>https://github.com/spring-projects/spring-ai</url>
<scm>

View File

@@ -21,7 +21,6 @@ import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.model.chat.memory.autoconfigure.CommonChatMemoryProperties;
import org.springframework.ai.chat.memory.cassandra.CassandraChatMemoryConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.lang.Nullable;
@@ -34,7 +33,7 @@ import org.springframework.lang.Nullable;
* @since 1.0.0
*/
@ConfigurationProperties(CassandraChatMemoryProperties.CONFIG_PREFIX)
public class CassandraChatMemoryProperties extends CommonChatMemoryProperties {
public class CassandraChatMemoryProperties {
public static final String CONFIG_PREFIX = "spring.ai.chat.memory.cassandra";
@@ -48,6 +47,16 @@ public class CassandraChatMemoryProperties extends CommonChatMemoryProperties {
private String userColumn = CassandraChatMemoryConfig.DEFAULT_USER_COLUMN_NAME;
private boolean initializeSchema = true;
public boolean isInitializeSchema() {
return this.initializeSchema;
}
public void setInitializeSchema(boolean initializeSchema) {
this.initializeSchema = initializeSchema;
}
private Duration timeToLive = null;
public String getKeyspace() {

View File

@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
cassandra.org.springframework.ai.model.chat.memory.autoconfigure.CassandraChatMemoryAutoConfiguration
org.springframework.ai.model.chat.memory.cassandra.autoconfigure.CassandraChatMemoryAutoConfiguration

View File

@@ -14,13 +14,12 @@
* limitations under the License.
*/
package org.springframework.ai.model.chat.memory.autoconfigure;
package org.springframework.ai.model.chat.memory.cassandra.autoconfigure;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.springframework.ai.model.chat.memory.cassandra.autoconfigure.CassandraChatMemoryProperties;
import org.springframework.ai.chat.memory.cassandra.CassandraChatMemoryConfig;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2023-2024 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.model.chat.memory.autoconfigure;
/**
* Configuration properties for the common chat memory.
*
* @author Mick Semb Wever
* @since 1.0.0
*/
public class CommonChatMemoryProperties {
private boolean initializeSchema = true;
public boolean isInitializeSchema() {
return this.initializeSchema;
}
public void setInitializeSchema(boolean initializeSchema) {
this.initializeSchema = initializeSchema;
}
}

View File

@@ -41,7 +41,7 @@
<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-neo4j</module>
<module>auto-configurations/models/chat/observation/spring-ai-autoconfigure-model-chat-observation</module>