Skip to content

Commit 4fc2591

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 74d5e79 commit 4fc2591

6 files changed

Lines changed: 149 additions & 11 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);

server/libs/modules/components/ai/agent/chat-memory/chat-memory-redis/src/test/resources/definition/redis-chat-memory_v1.json

Lines changed: 130 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,136 @@
99
"help": null,
1010
"metadata": null,
1111
"name": "addMessages",
12-
"outputDefinition": null,
12+
"outputDefinition": {
13+
"output": null,
14+
"outputResponse": {
15+
"outputSchema": {
16+
"additionalProperties": null,
17+
"advancedOption": null,
18+
"controlType": "OBJECT_BUILDER",
19+
"defaultValue": null,
20+
"description": null,
21+
"displayCondition": null,
22+
"exampleValue": null,
23+
"expressionEnabled": null,
24+
"hidden": null,
25+
"label": null,
26+
"metadata": { },
27+
"multipleValues": null,
28+
"name": null,
29+
"options": null,
30+
"optionsDataSource": null,
31+
"placeholder": null,
32+
"properties": [ {
33+
"advancedOption": null,
34+
"controlType": "TEXT",
35+
"defaultValue": null,
36+
"description": null,
37+
"displayCondition": null,
38+
"exampleValue": null,
39+
"expressionEnabled": null,
40+
"hidden": null,
41+
"label": null,
42+
"languageId": null,
43+
"maxLength": null,
44+
"metadata": { },
45+
"minLength": null,
46+
"name": "conversationId",
47+
"options": null,
48+
"optionsDataSource": null,
49+
"placeholder": null,
50+
"regex": null,
51+
"required": null,
52+
"type": "STRING"
53+
}, {
54+
"advancedOption": null,
55+
"controlType": "INTEGER",
56+
"defaultValue": null,
57+
"description": null,
58+
"displayCondition": null,
59+
"exampleValue": null,
60+
"expressionEnabled": null,
61+
"hidden": null,
62+
"label": null,
63+
"maxValue": null,
64+
"metadata": { },
65+
"minValue": null,
66+
"name": "messageCount",
67+
"options": null,
68+
"optionsDataSource": null,
69+
"placeholder": null,
70+
"required": null,
71+
"type": "INTEGER"
72+
} ],
73+
"required": null,
74+
"type": "OBJECT"
75+
},
76+
"placeholder": null,
77+
"sampleOutput": null
78+
},
79+
"outputSchema": {
80+
"additionalProperties": null,
81+
"advancedOption": null,
82+
"controlType": "OBJECT_BUILDER",
83+
"defaultValue": null,
84+
"description": null,
85+
"displayCondition": null,
86+
"exampleValue": null,
87+
"expressionEnabled": null,
88+
"hidden": null,
89+
"label": null,
90+
"metadata": { },
91+
"multipleValues": null,
92+
"name": null,
93+
"options": null,
94+
"optionsDataSource": null,
95+
"placeholder": null,
96+
"properties": [ {
97+
"advancedOption": null,
98+
"controlType": "TEXT",
99+
"defaultValue": null,
100+
"description": null,
101+
"displayCondition": null,
102+
"exampleValue": null,
103+
"expressionEnabled": null,
104+
"hidden": null,
105+
"label": null,
106+
"languageId": null,
107+
"maxLength": null,
108+
"metadata": { },
109+
"minLength": null,
110+
"name": "conversationId",
111+
"options": null,
112+
"optionsDataSource": null,
113+
"placeholder": null,
114+
"regex": null,
115+
"required": null,
116+
"type": "STRING"
117+
}, {
118+
"advancedOption": null,
119+
"controlType": "INTEGER",
120+
"defaultValue": null,
121+
"description": null,
122+
"displayCondition": null,
123+
"exampleValue": null,
124+
"expressionEnabled": null,
125+
"hidden": null,
126+
"label": null,
127+
"maxValue": null,
128+
"metadata": { },
129+
"minValue": null,
130+
"name": "messageCount",
131+
"options": null,
132+
"optionsDataSource": null,
133+
"placeholder": null,
134+
"required": null,
135+
"type": "INTEGER"
136+
} ],
137+
"required": null,
138+
"type": "OBJECT"
139+
},
140+
"sampleOutput": null
141+
},
13142
"perform": { },
14143
"processErrorResponse": null,
15144
"properties": [ {
@@ -126,7 +255,6 @@
126255
"type": "ARRAY"
127256
} ],
128257
"resumePerform": null,
129-
"suspendPerform": null,
130258
"title": "Add Messages",
131259
"workflowNodeDescription": null
132260
}, {
@@ -422,7 +550,6 @@
422550
"type": "STRING"
423551
} ],
424552
"resumePerform": null,
425-
"suspendPerform": null,
426553
"title": "Get Messages",
427554
"workflowNodeDescription": null
428555
}, {
@@ -600,7 +727,6 @@
600727
"type": "STRING"
601728
} ],
602729
"resumePerform": null,
603-
"suspendPerform": null,
604730
"title": "Delete Conversation",
605731
"workflowNodeDescription": null
606732
}, {
@@ -789,7 +915,6 @@
789915
"processErrorResponse": null,
790916
"properties": null,
791917
"resumePerform": null,
792-
"suspendPerform": null,
793918
"title": "List Conversations",
794919
"workflowNodeDescription": null
795920
} ],

0 commit comments

Comments
 (0)