Apply lorebook entry delimiter
This commit is contained in:
@@ -8,7 +8,7 @@ This node loads SillyTavern-style lorebook JSON files and appends matching lore
|
||||
|
||||
**lorebook_1, lorebook_2, lorebook_3, lorebook_4**: Full paths to lorebook `.json` files. You can use one lorebook or combine up to four.
|
||||
|
||||
**entry_delimiter**: Extra delimiter text intended for separating injected entries. At the moment, the node always appends entries line by line, so this input currently has no visible effect.
|
||||
**entry_delimiter**: Optional prefix added before every injected lorebook entry. This is useful when the enhanced prompt is fed into an LLM and you want each injected entry to start with a recognizable marker.
|
||||
|
||||
**context_history**: Additional context text that is scanned together with the current prompt when looking for matching lorebook entries.
|
||||
|
||||
@@ -16,9 +16,9 @@ This node loads SillyTavern-style lorebook JSON files and appends matching lore
|
||||
|
||||
## Outputs
|
||||
|
||||
**enhanced_prompt**: Your original prompt with the activated lorebook entries appended to the end.
|
||||
**enhanced_prompt**: Your original prompt with the activated lorebook entries appended to the end. If `entry_delimiter` is set, each injected entry is prefixed with it.
|
||||
|
||||
**injected_content**: A readable list of the exact lorebook entries that were injected.
|
||||
**injected_content**: A readable list of the exact lorebook entries that were injected, including the applied delimiter prefix.
|
||||
|
||||
## Purpose
|
||||
|
||||
|
||||
+17
-16
@@ -1786,9 +1786,9 @@ class FunPackLorebookEnhancer:
|
||||
|
||||
return activated
|
||||
|
||||
def enhance(self, prompt,
|
||||
lorebook_1="", lorebook_2="", lorebook_3="", lorebook_4="",
|
||||
context_history="", scan_depth=4, entry_delimiter=""):
|
||||
def enhance(self, prompt,
|
||||
lorebook_1="", lorebook_2="", lorebook_3="", lorebook_4="",
|
||||
context_history="", scan_depth=4, entry_delimiter=""):
|
||||
|
||||
full_text = (context_history + "\n" + prompt).lower()
|
||||
lines = full_text.splitlines()
|
||||
@@ -1807,19 +1807,20 @@ class FunPackLorebookEnhancer:
|
||||
injected = []
|
||||
enhanced = prompt.strip() # clean up any trailing space
|
||||
|
||||
for entry in activated:
|
||||
content = entry.get("content", "").strip()
|
||||
if not content:
|
||||
continue
|
||||
|
||||
# Always append to the end - this is the requested behavior
|
||||
if enhanced:
|
||||
enhanced += "\n" + content
|
||||
else:
|
||||
enhanced = content
|
||||
|
||||
source = entry.get("comment") or entry.get("name") or f"uid:{entry.get('uid','?')}" or "unnamed"
|
||||
injected.append(f"[{source}] {content}")
|
||||
for entry in activated:
|
||||
content = entry.get("content", "").strip()
|
||||
if not content:
|
||||
continue
|
||||
prefixed_content = f"{entry_delimiter}{content}" if entry_delimiter else content
|
||||
|
||||
# Always append to the end - this is the requested behavior
|
||||
if enhanced:
|
||||
enhanced += "\n" + prefixed_content
|
||||
else:
|
||||
enhanced = prefixed_content
|
||||
|
||||
source = entry.get("comment") or entry.get("name") or f"uid:{entry.get('uid','?')}" or "unnamed"
|
||||
injected.append(f"[{source}] {prefixed_content}")
|
||||
|
||||
injected_text = "\n\n".join(injected) if injected else "No content injected"
|
||||
return (enhanced, injected_text)
|
||||
|
||||
Reference in New Issue
Block a user