SillyTavern / SillyTavern

LLM Frontend for Power Users.
https://sillytavern.app
GNU Affero General Public License v3.0
8.04k stars 2.38k forks source link

[BUG] Inclusion Groups aren't working #1649

Closed tarcs999 closed 9 months ago

tarcs999 commented 9 months ago

Environment

Self-Hosted (Bare Metal)

System

Firefox 121

Version

SillyTavern 1.11.1 'release' (37d6f13b)

Desktop Information

No response

Describe the problem

When setting inclusion groups for lorebook entries, no mutually exclusive insertion is respected.

In both cases I would expect only a single entry (or zero entries if rolling low) to be included in the prompt, competing with weighted probability to be the winner.

Additional info

filterByInclusionGroups() seems to do its job correctly but somewhere else (in checkWorldInfo()?) seems to ignore the effect. Console logs filtered for "inclusion" look like this for the 100% trigger keyword-dependent magic test, with "fire" and "water" in the user's message:

-- INCLUSION GROUP CHECKS BEGIN -- [world-info.js:1956:13](http://127.0.0.1:8000/scripts/world-info.js)
Checking inclusion group 'magic' with 3 entries 
Array(3) [ {…}, {…}, {…} ]
[world-info.js:1971:17](http://127.0.0.1:8000/scripts/world-info.js)
Activated inclusion group 'magic' with entry '2' 
Object { uid: 2, key: (1) […], keysecondary: [], comment: "", content: "NOTE: Earth magic is mighty. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
[world-info.js:1993:25](http://127.0.0.1:8000/scripts/world-info.js)
Removing loser from inclusion group 'magic' entry '0' 
Object { uid: 0, key: (1) […], keysecondary: [], comment: "", content: "NOTE: Water magic is powerful yet serene. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
[world-info.js:2010:21](http://127.0.0.1:8000/scripts/world-info.js)
Removing loser from inclusion group 'magic' entry '1' 
Object { uid: 1, key: (1) […], keysecondary: [], comment: "", content: "NOTE: Fire magic is fearsome and violent. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
[world-info.js:2010:21](http://127.0.0.1:8000/scripts/world-info.js)
-- PROBABILITY CHECKS BEGIN -- [world-info.js:1839:17](http://127.0.0.1:8000/scripts/world-info.js)
uid:2 passed probability check, inserting to prompt [world-info.js:1847:30](http://127.0.0.1:8000/scripts/world-info.js)
WI entry activated: 
Object { uid: 2, key: (1) […], keysecondary: [], comment: "", content: "NOTE: Earth magic is mighty. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
[world-info.js:1863:21](http://127.0.0.1:8000/scripts/world-info.js)
0: water [world-info.js:1778:29](http://127.0.0.1:8000/scripts/world-info.js)
WI UID 0 found by primary match: water. [world-info.js:1781:33](http://127.0.0.1:8000/scripts/world-info.js)
WI UID 0: Activated without filter logic. [world-info.js:1821:37](http://127.0.0.1:8000/scripts/world-info.js)
1: fire [world-info.js:1778:29](http://127.0.0.1:8000/scripts/world-info.js)
WI UID 1 found by primary match: fire. [world-info.js:1781:33](http://127.0.0.1:8000/scripts/world-info.js)
WI UID 1: Activated without filter logic. [world-info.js:1821:37](http://127.0.0.1:8000/scripts/world-info.js)
-- INCLUSION GROUP CHECKS BEGIN -- [world-info.js:1956:13](http://127.0.0.1:8000/scripts/world-info.js)
Checking inclusion group 'magic' with 2 entries 
Array [ {…}, {…} ]
[world-info.js:1971:17](http://127.0.0.1:8000/scripts/world-info.js)
Skipping inclusion group check, group already activated 'magic' [world-info.js:1979:21](http://127.0.0.1:8000/scripts/world-info.js)
-- PROBABILITY CHECKS BEGIN -- [world-info.js:1839:17](http://127.0.0.1:8000/scripts/world-info.js)
uid:0 passed probability check, inserting to prompt [world-info.js:1847:30](http://127.0.0.1:8000/scripts/world-info.js)
WI entry activated: 
Object { uid: 0, key: (1) […], keysecondary: [], comment: "", content: "NOTE: Water magic is powerful yet serene. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
[world-info.js:1863:21](http://127.0.0.1:8000/scripts/world-info.js)
uid:1 passed probability check, inserting to prompt [world-info.js:1847:30](http://127.0.0.1:8000/scripts/world-info.js)
WI entry activated: 
Object { uid: 1, key: (1) […], keysecondary: [], comment: "", content: "NOTE: Fire magic is fearsome and violent. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
[world-info.js:1863:21](http://127.0.0.1:8000/scripts/world-info.js)
-- INCLUSION GROUP CHECKS BEGIN -- [world-info.js:1956:13](http://127.0.0.1:8000/scripts/world-info.js)
No inclusion groups found [world-info.js:1966:17](http://127.0.0.1:8000/scripts/world-info.js)
-- PROBABILITY CHECKS BEGIN -- [world-info.js:1839:17](http://127.0.0.1:8000/scripts/world-info.js)
WI probability checks failed for all activated entries, stopping [world-info.js:1869:21](http://127.0.0.1:8000/scripts/world-info.js)
skipWIAN not active, adding WIAN [script.js:3232:21](http://127.0.0.1:8000/script.js)
calling runGenerate [script.js:3358:17](http://127.0.0.1:8000/script.js)
generating prompt

World info message. also capable of having more than two conflicting entries:

role: 'system',
      content: 'Further scenario details:\n' +
        'NOTE: Fire magic is fearsome and violent. Be sure to comment on it.\n' +
        'NOTE: Water magic is powerful yet serene. Be sure to comment on it.\n'
    },

Please tick the boxes

Cohee1207 commented 9 months ago

I wasn't able to reproduce. Can you share your WI file?

tarcs999 commented 9 months ago

archivist lorebook.json

I would have assumed the issue was some legacy setting in my install if it wasn't reproducing, but I tested again by freshly cloning, importing this lorebook to a fresh basic character, and sending "teach me fire and water magic" to it on a random Horde model. The issue persisted with the fire+water entries both appearing in the "further scenario details" section of the prompt

Cohee1207 commented 9 months ago

Thanks, I was able to identify and fix the issue. The problem was with checking for the already activated groups during recursion check not deactivating the group entries. It's available in the staging branch.

tarcs999 commented 9 months ago

Thank you. Unfortunately I still seem to have the same problem on SillyTavern 1.11.2 'staging' (ead0aa65)

It seems like this snippet of filterByInclusionGroups() is activating when it probably shouldn't be:

        if (!Array.isArray(group) || group.length <= 1) {
            console.debug('Skipping inclusion group check, only one entry');
            continue;
        }

Logs:

Character The Archivist lore (archivist lorebook) has 3 world info entries world-info.js:1612:13
WI using char first world-info.js:1667:25
Sorted 3 world lore entries using strategy 1 world-info.js:1683:17
0: water world-info.js:1795:29
WI UID 0 found by primary match: water. world-info.js:1798:33
WI UID 0: Activated without filter logic. world-info.js:1849:37
1: fire world-info.js:1795:29
WI UID 1 found by primary match: fire. world-info.js:1798:33
WI UID 1: Activated without filter logic. world-info.js:1849:37
2: earth world-info.js:1795:29
No active entries for logic checks for word: earth. world-info.js:1853:38
2: rock world-info.js:1795:29
No active entries for logic checks for word: rock. world-info.js:1853:38
-- INCLUSION GROUP CHECKS BEGIN -- world-info.js:1990:13
Checking inclusion group 'magic' with 2 entries 
Array [ {…}, {…} ]
world-info.js:2005:17
Activated inclusion group 'magic' with entry '0' 
Object { uid: 0, key: (1) […], keysecondary: [], comment: "water", content: "NOTE: Water magic is powerful yet serene. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
world-info.js:2031:25
Removing loser from inclusion group 'magic' entry '1' 
Object { uid: 1, key: (1) […], keysecondary: [], comment: "fire", content: "NOTE: Fire magic is fearsome and violent. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
world-info.js:2048:21
-- PROBABILITY CHECKS BEGIN -- world-info.js:1867:17
uid:0 passed probability check, inserting to prompt world-info.js:1875:30
WI entry activated: 
Object { uid: 0, key: (1) […], keysecondary: [], comment: "water", content: "NOTE: Water magic is powerful yet serene. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
world-info.js:1891:21
1: fire world-info.js:1795:29
WI UID 1 found by primary match: fire. world-info.js:1798:33
WI UID 1: Activated without filter logic. world-info.js:1849:37
2: earth world-info.js:1795:29
No active entries for logic checks for word: earth. world-info.js:1853:38
2: rock world-info.js:1795:29
No active entries for logic checks for word: rock. world-info.js:1853:38
-- INCLUSION GROUP CHECKS BEGIN -- world-info.js:1990:13
Checking inclusion group 'magic' with 1 entries 
Array [ {…} ]
world-info.js:2005:17
Skipping inclusion group check, only one entry world-info.js:2008:21
-- PROBABILITY CHECKS BEGIN -- world-info.js:1867:17
uid:1 passed probability check, inserting to prompt world-info.js:1875:30
WI entry activated: 
Object { uid: 1, key: (1) […], keysecondary: [], comment: "fire", content: "NOTE: Fire magic is fearsome and violent. Be sure to comment on it.", constant: false, selective: true, selectiveLogic: 0, addMemo: true, order: 100, … }
world-info.js:1891:21
2: earth world-info.js:1795:29
No active entries for logic checks for word: earth. world-info.js:1853:38
2: rock world-info.js:1795:29
No active entries for logic checks for word: rock. world-info.js:1853:38
-- INCLUSION GROUP CHECKS BEGIN -- world-info.js:1990:13
No inclusion groups found world-info.js:2000:17
-- PROBABILITY CHECKS BEGIN -- world-info.js:1867:17
WI probability checks failed for all activated entries, stopping world-info.js:1897:21
No new entries activated, stopping
Cohee1207 commented 9 months ago

It seems like this snippet of filterByInclusionGroups() is activating when it probably shouldn't be:

Thanks. Looks like it.

tarcs999 commented 9 months ago

Thanks, that seems to work!