feat: Implement skipCache functionality across conversation handling
This commit is contained in:
@@ -25,6 +25,8 @@ public final class AgentContext {
|
||||
private volatile boolean error;
|
||||
|
||||
private volatile boolean skipNextCompletion;
|
||||
|
||||
private volatile boolean skipCache;
|
||||
|
||||
private volatile Conversation conversation;
|
||||
|
||||
@@ -74,6 +76,7 @@ public final class AgentContext {
|
||||
this.agentContextUpdateConsumer = other.agentContextUpdateConsumer;
|
||||
this.error = other.error;
|
||||
this.skipNextCompletion = other.skipNextCompletion;
|
||||
this.skipCache = other.skipCache;
|
||||
this.streaming = other.streaming;
|
||||
synchronized (other.graph) {
|
||||
this.graph.addAll(other.graph);
|
||||
@@ -201,6 +204,14 @@ public final class AgentContext {
|
||||
public void setSkipNextCompletion(final boolean skipNextCompletion) {
|
||||
this.skipNextCompletion = skipNextCompletion;
|
||||
}
|
||||
|
||||
public boolean isSkipCache() {
|
||||
return this.skipCache;
|
||||
}
|
||||
|
||||
public void setSkipCache(final boolean skipCache) {
|
||||
this.skipCache = skipCache;
|
||||
}
|
||||
|
||||
Consumer<AgentContext> getAgentContextUpdateConsumer() {
|
||||
return agentContextUpdateConsumer;
|
||||
|
||||
@@ -103,6 +103,8 @@ public interface BaseAgent {
|
||||
split.context().getGraph().add(this.name());
|
||||
|
||||
if (!skipCompletion) {
|
||||
final boolean skipCache = split.context().isSkipCache();
|
||||
split.context().setSkipCache(false);
|
||||
final var conversation = this.setupConversation(split);
|
||||
|
||||
boolean parseable = false;
|
||||
@@ -126,21 +128,21 @@ public interface BaseAgent {
|
||||
};
|
||||
if (modelProfile != null) {
|
||||
requestStart = System.currentTimeMillis();
|
||||
completion = client.streamConversation(modelProfile, conversation, chunkConsumer);
|
||||
completion = client.streamConversation(modelProfile, conversation, chunkConsumer, skipCache);
|
||||
}
|
||||
else {
|
||||
requestStart = System.currentTimeMillis();
|
||||
completion = client.streamConversation(this.modelCategory(split.context()), conversation, chunkConsumer);
|
||||
completion = client.streamConversation(this.modelCategory(split.context()), conversation, chunkConsumer, skipCache);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (modelProfile != null) {
|
||||
requestStart = System.currentTimeMillis();
|
||||
completion = client.conversation(modelProfile, conversation);
|
||||
completion = client.conversation(modelProfile, conversation, skipCache);
|
||||
}
|
||||
else {
|
||||
requestStart = System.currentTimeMillis();
|
||||
completion = client.conversation(this.modelCategory(split.context()), conversation);
|
||||
completion = client.conversation(this.modelCategory(split.context()), conversation, skipCache);
|
||||
}
|
||||
}
|
||||
final var durationMs = System.currentTimeMillis() - requestStart;
|
||||
|
||||
Reference in New Issue
Block a user