SillyTavern / SillyTavern-Extras

Extensions API for SillyTavern.
GNU Affero General Public License v3.0
549 stars 124 forks source link

add online lorabook api, and en wiki parser #166

Closed donlinglok1 closed 1 year ago

donlinglok1 commented 1 year ago

The pull request of https://github.com/SillyTavern/SillyTavern-Extras/issues/159

donlinglok1 commented 1 year ago

Added fandom parser.

Request

curl --location 'http://localhost:5100/api/online_lorabook' \
--header 'Content-Type: application/json' \
--data '{
    "text": "\"\"Shadowheart\"\" is my favorite character in \"\"Baldur'\''s Gate 3\"\", checkout here \"\"https://forgottenrealms.fandom.com/wiki/Lae%27zel\"\".",
    "params": {
        "search_list_limit": 1,
        "page_paragraph_limit": 2,
        "search_site": "fandom"
    }
}'

Result

{
    "lorebookVersion": 1,
    "entries": [
        {
            "text": "Shadowheart, previously known as Jenevelle Hallowleaf, was a half-elf cleric of Shar who became involved with the machinations of the Absolute during the late 15th century DR.Shadowheart had dark-brown hair left to hang down on the sides and tied up in a ponytail at the back with multiple rings. She wore a circlet over her fringe, leather gloves, and a chain shirt that was emblazoned with symbols of of her faith.A mystic wound that looked like a black dot appeared on the back of Shadowheart's right hand. It inflicted agonizing pain upon her from time to time, especially when she interacted with items associated with Selûne or Shar.",
            "contextConfig": {
                "prefix": "",
                "suffix": "\n^Shadowheart(https://forgottenrealms.fandom.com/wiki/Shadowheart)",
                "tokenBudget": 2048,
                "reservedTokens": 0,
                "budgetPriority": 400,
                "trimDirection": "trimBottom",
                "insertionType": "newline",
                "insertionPosition": -1
            },
            "displayName": "Shadowheart",
            "lastUpdatedAt": 1695282726,
            "keys": [
                "Shadowheart"
            ],
            "searchRange": 1000,
            "enabled": true,
            "forceActivation": false
        },
        {
            "text": "Baldur's Gate III is a computer game released by Larian Studios and is the third main game in the Baldur's Gate series. It is based on a highly modified version of the 5th-edition Dungeons & Dragons rule set and is set after the Baldur's Gate: Descent into Avernus tabletop adventure. It was first released as an early access game, after which other races, classes, features, and the rest of the story was added.\nBaldur's Gate III is a role-playing game with turn-based combat. The non-combat exploration can either be top-down or in third-person view. The player creates their character, including their race and any class from the Player's Handbook. The ranger class is largely modified, and some subclasses are essentially new, such as the Wildheart barbarian subclass that replaces the Totem Warrior. The character also chooses a background from the standard 5th-edition list, their ability scores, and skills they are proficient in. Alternatively, the player can choose an \"Origins\" character, which is pre-created. If an \"Origins\" character is not selected, they may still be available as a party member. The game has a tutorial system to introduce the players to the basic mechanics.\nThe game takes characters from levels 1 to 12. In combat, the player can interact with the environment with standard actions (as well as bonus actions), such as attack, hide, or shoving a creature. Many other Dungeons & Dragons systems are implemented, such as rolling for initiative and death saving throws, imposing advantage or disadvantage, and being in difficult terrain. When combat has taken its toll, the player can make camp, which expands over time as more companions are recruited.\n",
            "contextConfig": {
                "prefix": "",
                "suffix": "\n^Baldur's Gate III(https://forgottenrealms.fandom.com/wiki/Baldur%27s_Gate_III)",
                "tokenBudget": 2048,
                "reservedTokens": 0,
                "budgetPriority": 400,
                "trimDirection": "trimBottom",
                "insertionType": "newline",
                "insertionPosition": -1
            },
            "displayName": "Baldur's Gate III",
            "lastUpdatedAt": 1695282727,
            "keys": [
                "Baldur's Gate III"
            ],
            "searchRange": 1000,
            "enabled": true,
            "forceActivation": false
        },
        {
            "text": "Lae'zel was a githyanki fighter.The githyanki had distinct black facial features, including a thick black underline and several spots. She had pulled-back dark red hair and wore heavy mail. She weighed 45 kg. The warrior fought with a longsword and shortbow. She wore githyanki half plate and leather gloves.",
            "contextConfig": {
                "prefix": "",
                "suffix": "\n^Laezel(https://forgottenrealms.fandom.com/wiki/Lae%27zel)",
                "tokenBudget": 2048,
                "reservedTokens": 0,
                "budgetPriority": 400,
                "trimDirection": "trimBottom",
                "insertionType": "newline",
                "insertionPosition": -1
            },
            "displayName": "Laezel",
            "lastUpdatedAt": 1695280000,
            "keys": [
                "Laezel"
            ],
            "searchRange": 1000,
            "enabled": true,
            "forceActivation": false
        }
    ]
}