mirror of
https://github.com/severian-dev/sucker.severian.dev.git
synced 2025-10-27 20:25:44 +00:00
chore: should handle the char extraction better now
This commit is contained in:
@@ -4,6 +4,7 @@ Check package.json for commands, I can't be bothered.
|
|||||||
|
|
||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
|
- 1.4: Mooth just keeps finding bugs, damn.
|
||||||
- 1.3: Mooth found a bug, fixed it.
|
- 1.3: Mooth found a bug, fixed it.
|
||||||
- 1.2: Fix for Janitor having changed their prompt system
|
- 1.2: Fix for Janitor having changed their prompt system
|
||||||
- 1.1: Fix for R1 handling change, blank user persona bug
|
- 1.1: Fix for R1 handling change, blank user persona bug
|
||||||
|
|||||||
@@ -38,28 +38,27 @@ interface PersonaMatch {
|
|||||||
content: string;
|
content: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findTagsBetween(content: string, startMarker: string, endMarker: string): PersonaMatch[] {
|
function findTagsBetween(content: string, startMarker: string): PersonaMatch[] {
|
||||||
const startMarkerTag = `<${startMarker}>`;
|
const startMarkerTag = `<${startMarker}>`;
|
||||||
const endMarkerTag = `<${endMarker}>`;
|
|
||||||
|
|
||||||
const startIdx = content.indexOf(startMarkerTag);
|
const startIdx = content.indexOf(startMarkerTag);
|
||||||
if (startIdx === -1) return [];
|
if (startIdx === -1) return [];
|
||||||
|
|
||||||
// Look for any XML-style tags after the system tag
|
const scenarioIdx = content.indexOf("<scenario>");
|
||||||
const section = content.slice(startIdx);
|
const exampleIdx = content.indexOf("<example_dialogs>");
|
||||||
|
|
||||||
|
let endIdx = content.length;
|
||||||
|
if (scenarioIdx !== -1) endIdx = Math.min(endIdx, scenarioIdx);
|
||||||
|
if (exampleIdx !== -1) endIdx = Math.min(endIdx, exampleIdx);
|
||||||
|
|
||||||
|
const section = content.slice(startIdx, endIdx);
|
||||||
const matches: PersonaMatch[] = [];
|
const matches: PersonaMatch[] = [];
|
||||||
|
|
||||||
// Match any tag that comes before the scenario tag
|
|
||||||
const tagPattern = /<([^/>\s][^>]*)>([\s\S]*?)<\/\1>/g;
|
const tagPattern = /<([^/>\s][^>]*)>([\s\S]*?)<\/\1>/g;
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while ((match = tagPattern.exec(section)) !== null) {
|
while ((match = tagPattern.exec(section)) !== null) {
|
||||||
// Stop if we hit the scenario tag
|
|
||||||
if (match[1] === endMarker) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip the system tag
|
// Skip the system tag
|
||||||
if (match[1] !== startMarker) {
|
if (match[1] !== startMarker) {
|
||||||
matches.push({
|
matches.push({
|
||||||
@@ -95,8 +94,8 @@ function extractCardData(messages: Message[]): CardData {
|
|||||||
const content0 = messages[0].content;
|
const content0 = messages[0].content;
|
||||||
const content1 = messages[2].content;
|
const content1 = messages[2].content;
|
||||||
|
|
||||||
// Find all persona tags between system and scenario, take the last one as character
|
// Find all persona tags between system and the first optional tag (scenario or example_dialogs)
|
||||||
const personas = findTagsBetween(content0, "system", "scenario");
|
const personas = findTagsBetween(content0, "system");
|
||||||
const charPersona = personas[personas.length - 1];
|
const charPersona = personas[personas.length - 1];
|
||||||
const charName = charPersona?.tag || "";
|
const charName = charPersona?.tag || "";
|
||||||
|
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ export default function Home() {
|
|||||||
<div className="container mx-auto px-4 py-8">
|
<div className="container mx-auto px-4 py-8">
|
||||||
<div className="flex justify-between items-center mb-4">
|
<div className="flex justify-between items-center mb-4">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-3xl font-bold">Sucker v1.3</h1>
|
<h1 className="text-3xl font-bold">Sucker v1.4</h1>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
I still hate making these changes, but Mooth found a bug so I fixed it.
|
Mooth's on a bug hunting spree for some reason.👌
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user