Better way to prevent AI input from leaking into the AI result. master
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 1 Jun 2025 20:55:23 +0000 (23:55 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 1 Jun 2025 20:55:23 +0000 (23:55 +0300)
src/main/java/eu/svjatoslav/alyverkko_cli/AiTask.java

index 1ce9a92..99f68a8 100644 (file)
@@ -138,7 +138,7 @@ public class AiTask {
             // Build input prompt
             initializeInputFile(buildAiQuery());
 
-            // Prepare process builder
+            // Prepare 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,