Skip to content

Commit 1d2446a

Browse files
ivicacclaude
andcommitted
2415 Fix PR review comments: Redis chat memory dependency version, output schema, auth validation, shared constant
- Remove pinned Spring AI version, use BOM-managed version - Add output schema to addMessages action - Use CONVERSATION_ID constant instead of string literal in return map - Validate username+password are provided together (fail fast) - Move DEFAULT_KEY_PREFIX to shared constants class Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ced1640 commit 1d2446a

6 files changed

Lines changed: 20 additions & 991 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dependencies {
22
implementation("redis.clients:jedis")
3-
implementation("org.springframework.ai:spring-ai-model-chat-memory-repository-redis:2.0.0-M1")
3+
implementation("org.springframework.ai:spring-ai-model-chat-memory-repository-redis")
44
implementation(project(":server:libs:platform:platform-component:platform-component-service"))
55
}

server/libs/modules/components/ai/agent/chat-memory/chat-memory-redis/src/main/java/com/bytechef/component/ai/agent/chat/memory/redis/RedisChatMemoryComponentHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.bytechef.component.ai.agent.chat.memory.redis;
1818

19+
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.DEFAULT_KEY_PREFIX;
1920
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.HOST;
2021
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.KEY_PREFIX;
2122
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.PASSWORD;
@@ -62,7 +63,7 @@ public class RedisChatMemoryComponentHandler implements ComponentHandler {
6263
string(KEY_PREFIX)
6364
.label("Key Prefix")
6465
.description("The prefix for Redis keys used to store chat messages.")
65-
.defaultValue("bytechef-chat-memory:")
66+
.defaultValue(DEFAULT_KEY_PREFIX)
6667
.required(false),
6768
string(TIME_TO_LIVE)
6869
.label("Time to Live")

server/libs/modules/components/ai/agent/chat-memory/chat-memory-redis/src/main/java/com/bytechef/component/ai/agent/chat/memory/redis/action/RedisChatMemoryAddMessagesAction.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
import static com.bytechef.component.ai.agent.chat.memory.redis.util.RedisChatMemoryUtils.getChatMemoryRepository;
2424
import static com.bytechef.component.definition.ComponentDsl.action;
2525
import static com.bytechef.component.definition.ComponentDsl.array;
26+
import static com.bytechef.component.definition.ComponentDsl.integer;
2627
import static com.bytechef.component.definition.ComponentDsl.object;
2728
import static com.bytechef.component.definition.ComponentDsl.option;
29+
import static com.bytechef.component.definition.ComponentDsl.outputSchema;
2830
import static com.bytechef.component.definition.ComponentDsl.string;
2931

3032
import com.bytechef.component.definition.ActionContext;
@@ -69,6 +71,12 @@ public class RedisChatMemoryAddMessagesAction {
6971
.label("Content")
7072
.description("The content of the message.")
7173
.required(true))))
74+
.output(
75+
outputSchema(
76+
object()
77+
.properties(
78+
string(CONVERSATION_ID),
79+
integer("messageCount"))))
7280
.perform(RedisChatMemoryAddMessagesAction::perform);
7381

7482
private RedisChatMemoryAddMessagesAction() {
@@ -96,7 +104,7 @@ protected static Object perform(
96104
repository.saveAll(conversationId, existingMessages);
97105

98106
return Map.of(
99-
"conversationId", conversationId,
107+
CONVERSATION_ID, conversationId,
100108
"messageCount", existingMessages.size());
101109
}
102110

server/libs/modules/components/ai/agent/chat-memory/chat-memory-redis/src/main/java/com/bytechef/component/ai/agent/chat/memory/redis/constant/RedisChatMemoryConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
public class RedisChatMemoryConstants {
2323

2424
public static final String CONVERSATION_ID = "conversationId";
25+
public static final String DEFAULT_KEY_PREFIX = "bytechef-chat-memory:";
2526
public static final String HOST = "host";
2627
public static final String KEY_PREFIX = "keyPrefix";
2728
public static final String MESSAGES = "messages";

server/libs/modules/components/ai/agent/chat-memory/chat-memory-redis/src/main/java/com/bytechef/component/ai/agent/chat/memory/redis/util/RedisChatMemoryUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.bytechef.component.ai.agent.chat.memory.redis.util;
1818

19+
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.DEFAULT_KEY_PREFIX;
1920
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.HOST;
2021
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.KEY_PREFIX;
2122
import static com.bytechef.component.ai.agent.chat.memory.redis.constant.RedisChatMemoryConstants.PASSWORD;
@@ -34,8 +35,6 @@
3435
*/
3536
public class RedisChatMemoryUtils {
3637

37-
private static final String DEFAULT_KEY_PREFIX = "bytechef-chat-memory:";
38-
3938
public static ChatMemoryRepository getChatMemoryRepository(Parameters connectionParameters) {
4039
JedisPooled jedisClient = getJedisClient(connectionParameters);
4140
String keyPrefix = connectionParameters.getString(KEY_PREFIX, DEFAULT_KEY_PREFIX);
@@ -59,7 +58,11 @@ public static JedisPooled getJedisClient(Parameters connectionParameters) {
5958
String username = connectionParameters.getString(USERNAME);
6059
String password = connectionParameters.getString(PASSWORD);
6160

62-
if (username != null && !username.isBlank() && password != null && !password.isBlank()) {
61+
if (username != null && !username.isBlank()) {
62+
if (password == null || password.isBlank()) {
63+
throw new IllegalArgumentException("Password is required when username is provided");
64+
}
65+
6366
return new JedisPooled(host, port, username, password);
6467
} else if (password != null && !password.isBlank()) {
6568
return new JedisPooled(host, port, null, password);

0 commit comments

Comments
 (0)