From cf6e88648e1f157c33e2e85715b9512f23c5d25e Mon Sep 17 00:00:00 2001 From: Ruthenic Date: Tue, 18 Oct 2022 19:31:32 -0400 Subject: [PATCH] Split on more than `"\n` --- src/ai/huggingface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ai/huggingface.ts b/src/ai/huggingface.ts index 4a3dbdf..db37dc9 100644 --- a/src/ai/huggingface.ts +++ b/src/ai/huggingface.ts @@ -81,7 +81,7 @@ class HuggingFaceAI { const ctx = this.memory.slice(this.memoryLen * -2); const prompt = `${this.prefix}\n${ctx.join("\n")}\n${username}: "${message}"\n${this.name}: "`; const res = await this.#query(prompt); - const botMsg = res[0].generated_text.split('"\n')[0]; + const botMsg = res[0].generated_text.split(/"[.?!\n]?/gm)[0]; this.memory.push(`${username}: "${message}"`); this.memory.push(`${this.name}: "${botMsg}"`); console.log(`${this.name}: "${botMsg}"`);