chore: Update version to 2.4.1 in pom.xml and refactor conversation handling in BaseAgent

This commit is contained in:
extio-de
2026-03-21 15:41:47 +01:00
parent 117eeabc9c
commit 531fd88588
2 changed files with 9 additions and 8 deletions

View File

@@ -4,7 +4,7 @@
<artifactId>lm-lib</artifactId>
<groupId>de.extio</groupId>
<name>lm-lib</name>
<version>2.4</version>
<version>2.4.1</version>
<properties>
<java.version>25</java.version>

View File

@@ -22,6 +22,7 @@ import de.extio.lmlib.client.Chunk;
import de.extio.lmlib.client.Client;
import de.extio.lmlib.client.Completion;
import de.extio.lmlib.client.Conversation;
import de.extio.lmlib.client.Conversation.Turn;
import de.extio.lmlib.client.Conversation.TurnType;
import de.extio.lmlib.profile.ModelCategory;
import de.extio.lmlib.profile.ModelProfile;
@@ -344,13 +345,13 @@ public interface BaseAgent {
split.context().setConversation(newConversation);
conversation = newConversation;
}
if (conversation.getConversation().get(conversation.getConversation().size() - 1).type() == TurnType.ASSISTANT) {
if (this.systemPrompt() == null || this.systemPrompt().isEmpty() ||conversation.getConversation().size() > 1) {
if (conversation.getConversation().getLast().type() != TurnType.USER) {
conversation.addTurn(new Conversation.Turn(TurnType.USER, split.text()));
}
else {
conversation.addTurn(new Conversation.Turn(TurnType.USER, String.join("\n", this.systemPrompt(), split.text())));
}
final var lastUserTurn = conversation.getConversation().getLast();
conversation.replaceTurn(new Turn(TurnType.USER, lastUserTurn.text() + "\n" + split.text()));
}
}
return conversation;