From 48d1913ace98f708253cc6b2b5ce876a1bd188c7 Mon Sep 17 00:00:00 2001 From: neutrino2211 Date: Thu, 9 Oct 2025 02:58:21 +0000 Subject: [PATCH] Add kernel.js --- kernel.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 kernel.js diff --git a/kernel.js b/kernel.js new file mode 100644 index 0000000..c682ed8 --- /dev/null +++ b/kernel.js @@ -0,0 +1,30 @@ +console.log(Package.search); + +module.exports = { + on_prompt: function (prompt) { + try { + let results = Package.get_systems(); + console.log(JSON.stringify({ ...results })); + } catch (error) { + console.error(error); + } + return "Hi! " + prompt; + }, + generate_thought_prompt: function (prompt) { + let data = []; + console.log("Generating thought prompt...", prompt); + try { + let results = Package.search(prompt, 3, 0.4); + data.push(...results.map((i) => ({ ...i }))); + } catch (error) { + console.error(error); + } + console.log(JSON.stringify(data)); + // return ""; + return data.length > 0 + ? " Here's what I know about the user's query\n" + + data.map((e) => `${e.entry.type}: ${e.entry.content}`).join("\n") + + "\nNow that I have this information, I can use it to generate a response. " + : " I don't know anything about that. If there's relevant information in the system prompt, I'll try to use that. If there isn't, I'll just tell the user I don't know, let me check for a system prompt."; + }, +};