From: Svjatoslav Agejenko Date: Sun, 1 Jun 2025 20:55:23 +0000 (+0300) Subject: Better way to prevent AI input from leaking into the AI result. X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=afb858a2a9c9a5fe0eef9b7690a74d5655e33352;p=alyverkko-cli.git Better way to prevent AI input from leaking into the AI result. --- diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/AiTask.java b/src/main/java/eu/svjatoslav/alyverkko_cli/AiTask.java index 1ce9a92..99f68a8 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/AiTask.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/AiTask.java @@ -138,7 +138,7 @@ public class AiTask { // Build input prompt initializeInputFile(buildAiQuery()); - // Prepare process builder + // Prepare a process builder ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command(getCliCommand().split("\\s+")); // Splitting the command string into tokens @@ -148,7 +148,7 @@ public class AiTask { // Handle process's error stream handleErrorThread(process); - // Handle process's output stream + // Handle the process's output stream StringBuilder result = new StringBuilder(); Thread outputThread = handleResultThread(process, result); @@ -196,13 +196,8 @@ public class AiTask { * @return the cleaned AI response. */ private String cleanupAiResponse(String result) { - // remove text before AI response marker - int aIResponseIndex = result.lastIndexOf(AI_RESPONSE_MARKER); - if (aIResponseIndex != -1) { - result = result.substring(aIResponseIndex + AI_RESPONSE_MARKER.length()); - } - // remove text after end of text marker, if it exists + // remove text after the end of text marker if it exists if (mailQuery.model.endOfTextMarker != null) { int endOfTextMarkerIndex = result.indexOf(mailQuery.model.endOfTextMarker); if (endOfTextMarkerIndex != -1) { @@ -232,6 +227,7 @@ public class AiTask { "--flash-attn", "--cache-type-k q8_0", "--cache-type-v q8_0", + "--no-display-prompt", "--no-warmup", "--temp " + temperature, "--ctx-size " + mailQuery.model.contextSizeTokens,