From 9145b07da7565bf321c3d71ce48760bfd378a2e0 Mon Sep 17 00:00:00 2001 From: matty Date: Mon, 30 Jun 2025 21:09:37 -0400 Subject: [PATCH] trim input data for better results --- src/main.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 608b3b7..86d3c0d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -82,6 +82,13 @@ const storePromptData = async ( } }; +const trimInputData = (input: string) => { + const strippedInput = striptags(input); + const split = strippedInput.split(" "); + const promptStringIndex = split.indexOf("!prompt"); + return split.slice(promptStringIndex + 1).join(" "); // returns everything after the !prompt +}; + const generateOllamaRequest = async ( notification: Notification ): Promise => { @@ -105,7 +112,7 @@ const generateOllamaRequest = async ( const ollamaRequestBody: OllamaRequest = { model: process.env.OLLAMA_MODEL as string, system: process.env.OLLAMA_SYSTEM_PROMPT as string, - prompt: `@${notification.status.account.fqn} says: ${striptags( + prompt: `@${notification.status.account.fqn} says: ${trimInputData( notification.status.content )}`, stream: false,