Skip to content

Commit 59d9eb0

Browse files
authored
Merge pull request #592 from devoxx/issue-588
Fixed regression for streaming response
2 parents 390786c + cefa775 commit 59d9eb0

File tree

7 files changed

+41
-12
lines changed

7 files changed

+41
-12
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = "com.devoxx.genie"
10-
version = "0.5.2"
10+
version = "0.5.3"
1111

1212
repositories {
1313
mavenCentral()

src/main/java/com/devoxx/genie/service/prompt/memory/ChatMemoryManager.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,29 @@ public void removeLastUserMessage(@NotNull ChatMessageContext context) {
139139
}
140140
}
141141

142+
/**
143+
* Adds user message to memory from the provided context
144+
* @param context The chat message context containing the user message
145+
*/
146+
public void addUserMessage(@NotNull ChatMessageContext context) {
147+
try {
148+
if (context.getUserMessage() == null && context.getUserPrompt() != null) {
149+
// Create user message if not already set
150+
context.setUserMessage(UserMessage.from(context.getUserPrompt()));
151+
}
152+
153+
if (context.getUserMessage() != null) {
154+
log.debug("Adding user message to memory for context ID: {}", context.getId());
155+
chatMemoryService.addMessage(context.getProject(), context.getUserMessage());
156+
log.debug("Successfully added user message to memory");
157+
} else {
158+
log.warn("Attempted to add null user message to memory for context ID: {}", context.getId());
159+
}
160+
} catch (Exception e) {
161+
throw new MemoryException("Failed to add user message to memory", e);
162+
}
163+
}
164+
142165
/**
143166
* Removes only the last AI message from memory
144167
* @param context The chat message context containing the AI message to remove

src/main/java/com/devoxx/genie/service/prompt/strategy/AbstractPromptExecutionStrategy.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,14 @@ protected abstract void executeStrategySpecific(
8080
*/
8181
protected abstract String getStrategyName();
8282

83-
// /**
84-
// * Prepares memory with system message if needed and adds the user message.
85-
// *
86-
// * @param context The chat message context
87-
// */
88-
// protected void prepareMemory(@NotNull ChatMessageContext context) {
89-
// chatMemoryManager.prepareMemory(context);
90-
// // chatMemoryManager.addUserMessage(context);
91-
// }
83+
/**
84+
* Prepares memory with system message if needed and adds the user message.
85+
*
86+
* @param context The chat message context
87+
*/
88+
protected void prepareMemory(@NotNull ChatMessageContext context) {
89+
chatMemoryManager.prepareMemory(context);
90+
}
9291

9392
/**
9493
* Standardized error handling for execution exceptions.

src/main/java/com/devoxx/genie/service/prompt/strategy/NonStreamingPromptStrategy.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ protected void executeStrategySpecific(
5959
log.debug("Before memory preparation - context ID: {}", context.getId());
6060
chatMemoryManager.logMemoryState(context.getProject());
6161

62+
// Prepare memory and add user message
63+
prepareMemory(context);
64+
chatMemoryManager.addUserMessage(context);
65+
6266
log.debug("After memory preparation - context ID: {}", context.getId());
6367
chatMemoryManager.logMemoryState(context.getProject());
6468

src/main/java/com/devoxx/genie/service/prompt/strategy/StreamingPromptStrategy.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ protected void executeStrategySpecific(
5555
log.debug("Before memory preparation (streaming) - context ID: {}", context.getId());
5656
chatMemoryManager.logMemoryState(context.getProject());
5757

58-
// prepareMemory(context);
58+
// Prepare memory and add user message
59+
prepareMemory(context);
60+
chatMemoryManager.addUserMessage(context);
5961

6062
log.debug("After memory preparation (streaming) - context ID: {}", context.getId());
6163
chatMemoryManager.logMemoryState(context.getProject());

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<h2>v0.5.3</h2>
3939
<UL>
4040
<Li>Feat #586 : Added Gemini 2.5 Pro model by @stephanj</LI>
41+
<LI>Fix #588 : Fix streaming responses regression by @stephanj</LI>
4142
</UL>
4243
<h2>v0.5.2</h2>
4344
<UL>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.5.2
1+
version=0.5.3

0 commit comments

Comments
 (0)