Add lorebook debug

This commit is contained in:
kwaroran
2024-11-04 16:27:00 +09:00
parent 106ddd61d7
commit 9b3232d5dc
2 changed files with 134 additions and 48 deletions

View File

@@ -17,6 +17,7 @@
import SelectInput from "../UI/GUI/SelectInput.svelte";
import { applyChatTemplate, chatTemplates } from "src/ts/process/templates/chatTemplate";
import OptionInput from "../UI/GUI/OptionInput.svelte";
import { loadLoreBookV3Prompt } from "src/ts/process/lorebook.svelte";
let previewMode = $state('chat')
let previewJoin = $state('yes')
@@ -246,6 +247,40 @@
<Button className="mt-2" onclick={() => {preview()}}>Run</Button>
</Arcodion>
<Arcodion styled name={"Preview Lorebook"}>
<Button className="mt-2" onclick={async () => {
const lorebookResult = await loadLoreBookV3Prompt()
const html = `
${lorebookResult.actives.map((v) => {
return `## ${v.source}\n\n\`\`\`\n${v.prompt}\n\`\`\`\n`
}).join('\n')}
`.trim()
alertMd(html)
}}>Test Lore</Button>
<Button className="mt-2" onclick={async () => {
const lorebookResult = await loadLoreBookV3Prompt()
const html = `
<table>
<thead>
<tr>
<th>Key</th>
<th>Source</th>
</tr>
</thead>
<tbody>
${lorebookResult.matchLog.map((v) => {
return `<tr>
<td><pre>${v.activated.trim()}</pre></td>
<td><pre>${v.source.trim()}</pre></td>
</tr>`
}).join('\n')}
</tbody>
</table>
`.trim()
alertMd(html)
}}>Match Sources</Button>
</Arcodion>
<Button className="mt-2" onclick={() => {
alertMd(getRequestLog())
}}>Request Log</Button>