Scripts / Mid-Gen Lorebook Injector

Mid-Gen Lorebook Injector

Monitors generation for Lorebook keywords (including complex A & B logic) and restarts generation immediately to force context injection.

Both Scope
MIT
Automation & Hooks
UI & UX
Writing & Generation
4 watchers
127 downloads

Description

Normally, the AI only recognizes your Lorebook entries that are already activated/in-context BEFORE you hit Send.

IF the AI Model happens to mention an activation key word to a currently inactivated/not-in-context Lorebook during text generation, it will not activate said Lorebook until AFTER text generation stops/finishes. Therefore in these situations, it hasn't actually read/seen that specific entry yet, so it might start making up random/inaccurate details about it!

This script monitors the token stream for inactive Lorebook keywords (including complex Advanced Condition Regex A & B logic). When a new key is detected mid-generation, it interrupts the process, to allow the triggered Lorebook to activate & enter the AI's visible context aka it injects the relevant Lorebook info, and then continues streaming. In short it enables mid-generation Lorebook context injection, eliminating the one-turn latency usually required for Lorebook activation.

Note: It comes with a toggle and supports existing entries with Advanced Conditions.
I'm not 100% sure if it only works when you want it to or not aka false triggers. I believe I worked out all the kinks.

Scope Information

Supported:
Both
Recommended:
Both
Notes:

You can use either. If not all your stories are Lorebook heavy, just use on a Per Story basis.

License & Attribution

License:
MIT
Credits:
This is based off eliminable's "Improved Lorebook Context injector".