More resilient json parsing; Removed responseAsUserPrompt feature; Better error handling; chooseNextAgent() is called after merger(); apply templates: multiple [[]] branched placeholders are now possible; New AgentType.CONVERSATION_WITH_SYSTEM_PROMPT;

git-svn-id: svn://home0/lm-lib@3644 71dcc7fd-b1f2-4e5d-bb8e-274146e81173
This commit is contained in:
(no author)
2024-12-21 14:45:53 +00:00
parent 1976daf697
commit 63087a1cd6
9 changed files with 156 additions and 94 deletions

View File

@@ -6,13 +6,14 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import de.extio.lmlib.client.Completion;
import de.extio.lmlib.client.Conversation;
public final class AgentContext {
private final Map<String, Agent> agents;
private final Map<String, List<Object>> context;
private final Map<String, List<? extends Object>> context;
private final AgentRequestStatistic requestStatistic;
@@ -22,6 +23,8 @@ public final class AgentContext {
private volatile AgentNext nextAgent;
private volatile Completion lastCompletion;
public AgentContext(final Map<String, Agent> agents) {
this.agents = agents;
this.context = new ConcurrentHashMap<>();
@@ -32,18 +35,19 @@ public final class AgentContext {
this(other, new ConcurrentHashMap<>(other.context));
}
public AgentContext(final AgentContext other, final Map<String, List<Object>> context) {
public AgentContext(final AgentContext other, final Map<String, List<? extends Object>> context) {
this.agents = other.agents;
this.context = context;
this.conversation = Conversation.copy(other.conversation);
this.nextAgent = other.nextAgent;
this.requestStatistic = other.requestStatistic;
this.lastCompletion = other.lastCompletion;
synchronized (other.graph) {
this.graph.addAll(other.graph);
}
}
public Map<String, List<Object>> getContext() {
public Map<String, List<? extends Object>> getContext() {
return this.context;
}
@@ -75,4 +79,12 @@ public final class AgentContext {
return this.graph;
}
public Completion getLastCompletion() {
return this.lastCompletion;
}
public void setLastCompletion(final Completion lastCompletion) {
this.lastCompletion = lastCompletion;
}
}