Выключаемые хуманы и ассистенты для Клода в таверне.

Спустя час крытия гитхаба матом. Представляю уже готовый форк оригинальной таверны с моими изменениями. (Также встроеным /lookaround от XML шизов, но в виде отдельной кнопки из https://rentry.co/LookAroundST/ и много чем еще)

Осторожно, Говнокод, Не забудь сделать бекап!

Работает до версии таверны 1.10 UPD. Советую глянуть https://rentry.org/noass_ext

Первое, Добавляем некоторые изменения в config.conf

А Именно,

const HumAssistOff = true; // (or false)
const SystemFul = false;

И добавляешь в module.exports HumAssistOff и SystemFul

module.exports = {
  port,
  whitelist, 
  whitelistMode,
  basicAuthMode,
  basicAuthUser,
  autorun,
  enableExtensions,
  listen,
  disableThumbnails,
  allowKeysExposure,
  securityOverride,
  skipContentCheck,
  HumAssistOff,
  SystemFul,
};

Для полных чайников, просто вставляйте

const port = 8000;
const whitelist = ['127.0.0.1', '192.168.0.24', '192.168.0.17']; //Example for add several IP in whitelist: ['127.0.0.1', '192.168.0.10']
const whitelistMode = true; //Disabling enabling the ip whitelist mode. true/false
const basicAuthMode = false; //Toggle basic authentication for endpoints.
const basicAuthUser = {username: "user", password: "password"}; //Login credentials when basicAuthMode is true.
const disableThumbnails = false; //Disables the generation of thumbnails, opting to use the raw images instead
const autorun = true; //Autorun in the browser. true/false
const enableExtensions = true; //Enables support for TavernAI-extras project
const listen = true; // If true, Can be access from other device or PC. otherwise can be access only from hosting machine.
const skipContentCheck = false; // If true, no new default content will be delivered to you.
const allowKeysExposure = true; // If true, private API keys could be fetched to the frontend.
const HumAssistOff = true; // (or false)
const SystemFul = false;



// If true, Allows insecure settings for listen, whitelist, and authentication.
// Change this setting only on "trusted networks". Do not change this value unless you are aware of the issues that can arise from changing this setting and configuring a insecure setting.
const securityOverride = false;

module.exports = {
  port,
  whitelist, 
  whitelistMode,
  basicAuthMode,
  basicAuthUser,
  autorun,
  enableExtensions,
  listen,
  disableThumbnails,
  allowKeysExposure,
  securityOverride,
  skipContentCheck,
  HumAssistOff,
  SystemFul,
};

Лезем в public\scripts\openai.js чтобы добавить, а затем найти и изменить

В самом начале вставьте /*

import

"В силу ограничений браузерной части node.js, Я не могу добавить эту переменную в config без массовой переделки кода, Но не думаю что тебе придется менять эту переменную на false, так что просто вставь куда указал,"

Далее, смотри на картинку и замени указанную функцию

Куда вставить

function setOpenAIMessages(chat) {
    let j = 0;
    // clean openai msgs
    openai_msgs = [];
    openai_narrator_messages_count = 0;
    for (let i = chat.length - 1; i >= 0; i--) {
        let role = chat[j]['is_user'] ? 'user' : 'assistant';
        let content = chat[j]['mes'];

        // 100% legal way to send a message as system
        if (chat[j].extra?.type === system_message_types.NARRATOR) {
            role = 'system';
            openai_narrator_messages_count++;
        }

        // for groups or sendas command - prepend a character's name
        if (selected_group || (chat[j].force_avatar && chat[j].name !== name1 && chat[j].extra?.type !== system_message_types.NARRATOR)) {
            content = `${chat[j].name}: ${content}`;
        }

        content = replaceBiasMarkup(content);

        // remove caret return (waste of tokens)
        content = content.replace(/\r/gm, '');

        // Apply the "wrap in quotes" option
        if (role == 'user' && oai_settings.wrap_in_quotes) content = `"${content}"`;
        openai_msgs[i] = { "role": role, "content": content };
        j++;
    }

    // Add chat injections, 100 = maximum depth of injection. (Why would you ever need more?)
    for (let i = 0; i < 100; i++) {
        const anchor = getExtensionPrompt(extension_prompt_types.IN_CHAT, i);

        if (anchor && anchor.length) {
            openai_msgs.splice(i, 0, { "role": 'system', 'content': anchor.trim() })
        }
    }
}

меняем на

function setOpenAIMessages(chat) {
    let j = 0;
    // clean openai msgs
    openai_msgs = [];
    openai_narrator_messages_count = 0;
    for (let i = chat.length - 1; i >= 0; i--) {
        let role = chat[j]['is_user'] ? 'user' : 'assistant';
        let content = chat[j]['mes'];

        // 100% legal way to send a message as system
        if (chat[j].extra?.type === system_message_types.NARRATOR) {
            role = 'system';
            openai_narrator_messages_count++;
        }

        // Check the value of AlwaysCharnames
        switch (AlwaysCharnames) {
            // If it is on, use Anons code
            case true:
                // for groups or sendas command - prepend a character's name
                content = `${chat[j].name}: ${content}`;
                break
            // If it is anything else, use the original code
            default:
                // for groups or sendas command - prepend a character's name
                if (selected_group || (chat[j].force_avatar && chat[j].name !== name1 && chat[j].extra?.type !== system_message_types.NARRATOR)) {
                    content = `${chat[j].name}: ${content}`;
                }

        }
        // remove caret return (waste of tokens)
        content = content.replace(/\r/gm, '');

        // Apply the "wrap in quotes" option
        if (role == 'user' && oai_settings.wrap_in_quotes) content = `"${content}"`;
        openai_msgs[i] = { "role": role, "content": content };
        j++;
    }

    // Add chat injections, 100 = maximum depth of injection. (Why would you ever need more?)
    for (let i = 0; i < 100; i++) {
        const anchor = getExtensionPrompt(extension_prompt_types.IN_CHAT, i);

        if (anchor && anchor.length) {
            openai_msgs.splice(i, 0, { "role": 'system', 'content': anchor.trim() })
        }
    }
}

Теперь у вас всегда добавляются имена персов и чат выглядит не как:

Human: Ah ah mistress
Assistant: На колени, червь

А как:

Human: {{user}}: Ah ah mistress
Assistant: {{char}}: На колени, червь

Обращаю внимание на то, что теперь у тебя и при игре через ГПТ отправляются имена персонажей.

После этого лезем в server.js в корне таверны и меняем функцию:

Image description

// Prompt Conversion script taken from RisuAI by @kwaroran (GPLv3).
function convertClaudePrompt(messages, addHumanPrefix, addAssistantPostfix) {
    // Claude doesn't support message names, so we'll just add them to the message content.
    for (const message of messages) {
        if (message.name && message.role !== "system") {
            message.content = message.name + ": " + message.content;
            delete message.name;
        }
    }

    let requestPrompt = messages.map((v) => {
        let prefix = '';
        switch (v.role) {
            case "assistant":
                prefix = "\n\nAssistant: ";
                break
            case "user":
                prefix = "\n\nHuman: ";
                break
            case "system":
                // According to the Claude docs, H: and A: should be used for example conversations.
                if (v.name === "example_assistant") {
                    prefix = "\n\nA: ";
                } else if (v.name === "example_user") {
                    prefix = "\n\nH: ";
                } else {
                    prefix = "\n\n";
                }
                break
        }
        return prefix + v.content;
    }).join('');

    if (addHumanPrefix) {
        requestPrompt = "\n\nHuman: " + requestPrompt;
    }

    if (addAssistantPostfix) {
        requestPrompt = requestPrompt + '\n\nAssistant: ';
    }

    return requestPrompt;
}

На

// Prompt Conversion script taken from RisuAI by @kwaroran (GPLv3).
function convertClaudePrompt(messages, addHumanPrefix, addAssistantPostfix) {
    // Check the value of HumAssistOff
    const { HumAssistOff } = require('./config.conf');
    const { SystemFul  } = require('./config.conf');
    let requestPrompt;
    switch (HumAssistOff) {
        // If it is true, Now you won't had H and A
        case true:
            requestPrompt = messages.map((v) => {
                return v.content+"\n\n";
            }).join('');

            if (addHumanPrefix) {
                requestPrompt = "\n\nHuman: " + requestPrompt;
            }

            if (addAssistantPostfix) {
                requestPrompt = requestPrompt + '\n\nAssistant: ';
            }

            return requestPrompt;
            break
        // If it is false or anything else, use the RisuAI original code
        default:
            // Claude doesn't support message names, so we'll just add them to the message content.
            for (const message of messages) {
                if (message.name && message.role !== "system") {
                    message.content = message.name + ": " + message.content;
                    delete message.name;
                }
            }

            requestPrompt = messages.map((v) => {
                let prefix = '';
                switch (v.role) {
                    case "assistant":
                        prefix = "\n\nAssistant: ";
                        break
                    case "user":
                        prefix = "\n\nHuman: ";
                        break
                    case "system":
                        // According to the Claude docs, H: and A: should be used for example conversations.
                        if (v.name === "example_assistant") {
                            prefix = "\n\nA: ";
                        } else if (v.name === "example_user") {
                            prefix = "\n\nH: ";
                        } else {
                            switch (SystemFul) {
                                case true:
                                    prefix = "\n\nSystem: ";
                                    break
                                default:
                                    prefix = "\n\n";
                                    break
                            }
                        }
                        break
                }
                return prefix + v.content;
            }).join('');

            if (addHumanPrefix) {
                requestPrompt = "\n\nHuman: " + requestPrompt;
            }

            if (addAssistantPostfix) {
                requestPrompt = requestPrompt + '\n\nAssistant: ';
            }

            return requestPrompt;
    }
}

Готово, теперь лезешь в историю и видишь что у тебя история чата выглядит примерно так:

Image description

Не забудьте, что нужны новые промпты, потому что теперь Клод не считает, что он с нами рпшит. Теперь для Клода абсолютно вся история РП это РП кого-то по имени {{user}} и {{char}}.

Так что, вероятнее всего после модификации тебе придется вернуться на первый этап, и выставить

const HumAssistOff = false; // (or true)

До момента, пока не появится Новый Мейн/Джейлбрейк

1
2
3
4
Также автор изменения добавил удаленную разрабами, но теперь включаемую/выключаемую роль System для Main prompt 
(По умолчанию выключена, чтобы включить установите)

const SystemFul = true;

Автор оригинала https://rentry.co/TavernNoAss

Edit
Pub: 22 Jul 2023 20:53 UTC
Edit: 19 Apr 2024 12:08 UTC
Views: 1828