From eb744f0d103e1c35e18025da64b90297dfd800b9 Mon Sep 17 00:00:00 2001 From: Hunter Jackson Date: Tue, 9 Jul 2024 11:30:00 -0400 Subject: [PATCH 1/2] make sure to send the prepoccessed threadstates downstream to the plugin --- src/main/java/com/meta/cp4m/Service.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/meta/cp4m/Service.java b/src/main/java/com/meta/cp4m/Service.java index 03598a1..7762e39 100644 --- a/src/main/java/com/meta/cp4m/Service.java +++ b/src/main/java/com/meta/cp4m/Service.java @@ -17,10 +17,10 @@ import com.meta.cp4m.store.ChatStore; import io.javalin.http.Context; import java.io.IOException; +import java.util.*; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.*; import java.util.concurrent.*; import org.checkerframework.checker.nullness.qual.Nullable; import org.slf4j.Logger; @@ -99,7 +99,7 @@ private void execute(ThreadState thread) { T pluginResponse; try { - pluginResponse = plugin.handle(thread); + pluginResponse = plugin.handle(preproccessed); } catch (IOException e) { LOGGER.error("failed to communicate with LLM", e); return; From 03ff1d0e95874dee57c9df290e77995df19c3c5d Mon Sep 17 00:00:00 2001 From: Hunter Jackson Date: Tue, 9 Jul 2024 11:30:16 -0400 Subject: [PATCH 2/2] user lighter weight threads --- src/main/java/com/meta/cp4m/Service.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/meta/cp4m/Service.java b/src/main/java/com/meta/cp4m/Service.java index 7762e39..1fcea5a 100644 --- a/src/main/java/com/meta/cp4m/Service.java +++ b/src/main/java/com/meta/cp4m/Service.java @@ -29,7 +29,7 @@ public class Service { private static final Logger LOGGER = LoggerFactory.getLogger(Service.class); - private final ExecutorService executorService = Executors.newCachedThreadPool(); + private final ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor(); private final MessageHandler handler; private final ChatStore store; private final Plugin plugin; @@ -101,7 +101,7 @@ private void execute(ThreadState thread) { try { pluginResponse = plugin.handle(preproccessed); } catch (IOException e) { - LOGGER.error("failed to communicate with LLM", e); + LOGGER.error("Plugin failure occurred", e); return; } store.add(pluginResponse);