diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..769de89 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target/ +/.classpath +/.project +/.settings/ \ No newline at end of file diff --git a/src/main/java/de/extio/lmlib/agent/Agent.java b/src/main/java/de/extio/lmlib/agent/Agent.java index 21e2d9f..3b22a30 100755 --- a/src/main/java/de/extio/lmlib/agent/Agent.java +++ b/src/main/java/de/extio/lmlib/agent/Agent.java @@ -43,12 +43,17 @@ public record Agent(String name, AgentType agentType, ModelCategory modelCategor for (final var split : splits) { tasks.add(CompletableFuture.runAsync(() -> { try { - if (this.agentType() != AgentType.PROCESSING_ONLY) { + boolean skipCompletion = split.context().isSkipNextCompletion() || this.agentType() == AgentType.PROCESSING_ONLY; + if (skipCompletion) { + split.context().setSkipNextCompletion(false); + split.context().getGraph().add("○"); + } + else { split.context().getGraph().add(this.modelCategory.getShortName()); } split.context().getGraph().add(this.name()); - if (this.agentType != AgentType.PROCESSING_ONLY) { + if (!skipCompletion) { final var conversation = this.setupConversation(split); LOGGER.debug("Conversation: {}", conversation); @@ -270,7 +275,7 @@ public record Agent(String name, AgentType agentType, ModelCategory modelCategor } case final Agent a when a.agentType() == AgentType.PROCESSING_ONLY -> { - context.getGraph().add("○"); + } default -> { diff --git a/src/main/java/de/extio/lmlib/agent/AgentContext.java b/src/main/java/de/extio/lmlib/agent/AgentContext.java index d41a4d3..f3c4a35 100755 --- a/src/main/java/de/extio/lmlib/agent/AgentContext.java +++ b/src/main/java/de/extio/lmlib/agent/AgentContext.java @@ -30,6 +30,8 @@ public final class AgentContext { private volatile boolean error; + private volatile boolean skipNextCompletion; + public AgentContext(final Map agents) { this.agents = agents; this.context = new ConcurrentHashMap<>(); @@ -48,6 +50,7 @@ public final class AgentContext { this.requestStatistic = other.requestStatistic; this.lastCompletion = other.lastCompletion; this.error = other.error; + this.skipNextCompletion = other.skipNextCompletion; synchronized (other.graph) { this.graph.addAll(other.graph); } @@ -125,4 +128,12 @@ public final class AgentContext { this.error = error; } + public boolean isSkipNextCompletion() { + return this.skipNextCompletion; + } + + public void setSkipNextCompletion(final boolean skipNextCompletion) { + this.skipNextCompletion = skipNextCompletion; + } + } diff --git a/src/main/java/de/extio/lmlib/agent/AgentExecutorService.java b/src/main/java/de/extio/lmlib/agent/AgentExecutorService.java index bbd1b5b..f6cc300 100755 --- a/src/main/java/de/extio/lmlib/agent/AgentExecutorService.java +++ b/src/main/java/de/extio/lmlib/agent/AgentExecutorService.java @@ -46,7 +46,7 @@ public class AgentExecutorService implements InitializingBean, DisposableBean { } public List walkGraph(final Agent agent, final AgentContext context) { - LOGGER.info("Agent: {}", agent.name()); + LOGGER.debug("Agent: {}", agent.name()); Client client = null; if (agent.agentType() != AgentType.PROCESSING_ONLY) { diff --git a/src/main/java/de/extio/lmlib/client/cached/CachedClient.java b/src/main/java/de/extio/lmlib/client/cached/CachedClient.java index 641871b..303d21c 100644 --- a/src/main/java/de/extio/lmlib/client/cached/CachedClient.java +++ b/src/main/java/de/extio/lmlib/client/cached/CachedClient.java @@ -69,35 +69,26 @@ public class CachedClient implements Client { throw new IllegalArgumentException("ModelProfile " + modelCategory.getModelProfile()); } - final var key = new StringBuilder(); - key.append(Objects.requireNonNullElse(modelProfile.modelName(), modelCategory.name())); - key.append("_"); - key.append(modelProfile.maxTokens()); - key.append("_"); - key.append(modelProfile.maxContextLength()); - key.append("_"); - key.append(modelProfile.maxContinuations()); - key.append("_"); - key.append(modelProfile.temperature()); - key.append("_"); - key.append(modelProfile.topP()); - key.append("_"); - MessageDigest digest; try { digest = MessageDigest.getInstance("SHA-256"); + digest.update(Objects.requireNonNullElse(modelProfile.modelName(), modelCategory.name()).getBytes()); + digest.update(String.valueOf(modelProfile.modelProvider()).getBytes()); + digest.update(String.valueOf(modelProfile.maxTokens()).getBytes()); + digest.update(String.valueOf(modelProfile.maxContextLength()).getBytes()); + digest.update(String.valueOf(modelProfile.maxContinuations()).getBytes()); + digest.update(String.valueOf(modelProfile.temperature()).getBytes()); + digest.update(String.valueOf(modelProfile.topP()).getBytes()); for (final var k : keys) { if (k != null && !k.isEmpty()) { digest.update(k.getBytes()); } } - key.append(HexFormat.of().formatHex(digest.digest())); + return HexFormat.of().formatHex(digest.digest()); } catch (final NoSuchAlgorithmException e) { throw new RuntimeException("Error calculating hash", e); } - - return key.toString(); } } diff --git a/src/main/java/de/extio/lmlib/profile/ModelCategory.java b/src/main/java/de/extio/lmlib/profile/ModelCategory.java index 0d1da77..ebfae4c 100755 --- a/src/main/java/de/extio/lmlib/profile/ModelCategory.java +++ b/src/main/java/de/extio/lmlib/profile/ModelCategory.java @@ -5,6 +5,7 @@ public enum ModelCategory { SMALL("profile.model.s", "S"), MEDIUM("profile.model.m", "M"), LARGE("profile.model.l", "L"), + XLARGE("profile.model.xl", "XL"), HOT("profile.model.hot", "HOT"), COLD("profile.model.cold", "COLD"); diff --git a/src/main/java/de/extio/lmlib/profile/ModelProfileService.java b/src/main/java/de/extio/lmlib/profile/ModelProfileService.java index 3d8a3dc..c7e8435 100755 --- a/src/main/java/de/extio/lmlib/profile/ModelProfileService.java +++ b/src/main/java/de/extio/lmlib/profile/ModelProfileService.java @@ -94,7 +94,7 @@ public class ModelProfileService { String apiKey = null; synchronized (this.environment) { if (this.environment instanceof ConfigurableEnvironment configurableEnvironment) { - configurableEnvironment.getPropertySources().addLast(resource); + configurableEnvironment.getPropertySources().addFirst(resource); } apiKey = Optional.ofNullable(this.environment.getProperty("apiKey")) .map(Object::toString)