diff --git a/README.md b/README.md index 286de57..d6cca60 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Check package.json for commands, I can't be bothered. ### Changelog +- 1.5: {{user}} substitution for user persona name - 1.4: Mooth just keeps finding bugs, damn. - 1.3: Mooth found a bug, fixed it. - 1.2: Fix for Janitor having changed their prompt system diff --git a/src/app/api/proxy/route.ts b/src/app/api/proxy/route.ts index 1a754cd..5812610 100644 --- a/src/app/api/proxy/route.ts +++ b/src/app/api/proxy/route.ts @@ -96,8 +96,11 @@ function extractCardData(messages: Message[]): CardData { // Find all persona tags between system and the first optional tag (scenario or example_dialogs) const personas = findTagsBetween(content0, "system"); + + const userPersona = personas[personas.length - 2]; const charPersona = personas[personas.length - 1]; const charName = charPersona?.tag || ""; + const userName = userPersona?.tag || ""; // Initialize card data with the character name let cardData: CardData = { @@ -109,6 +112,16 @@ function extractCardData(messages: Message[]): CardData { first_mes: content1, }; + // Replace user name with placeholder in all fields + for (const field in cardData) { + if (field !== "name") { + const val = cardData[field as keyof CardData]; + if (typeof val === "string") { + cardData[field as keyof CardData] = safeReplace(val, userName, "{{user}}"); + } + } + } + // Replace character name with placeholder in all fields for (const field in cardData) { if (field !== "name") { diff --git a/src/app/page.tsx b/src/app/page.tsx index 6773cbf..6e3f169 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -187,9 +187,9 @@ export default function Home() {
- Mooth's on a bug hunting spree for some reason.👌 + User persona name substitution fixed, let me know how it goes.