This commit is contained in:
RossAscends
2023-04-26 21:15:34 +09:00
7 changed files with 68 additions and 89 deletions

View File

@ -81,7 +81,7 @@
"source": [ "source": [
"#@title <b><-- Select your model below and then click this to start KoboldAI</b>\n", "#@title <b><-- Select your model below and then click this to start KoboldAI</b>\n",
"\n", "\n",
"Model = \"Pygmalion 6B\" #@param [\"Nerys V2 6B\", \"Erebus 6B\", \"Skein 6B\", \"Janeway 6B\", \"Adventure 6B\", \"Pygmalion 6B\", \"Pygmalion 6B Dev\", \"Lit V2 6B\", \"Lit 6B\", \"Shinen 6B\", \"Nerys 2.7B\", \"AID 2.7B\", \"Erebus 2.7B\", \"Janeway 2.7B\", \"Picard 2.7B\", \"Horni LN 2.7B\", \"Horni 2.7B\", \"Shinen 2.7B\", \"OPT 2.7B\", \"Fairseq Dense 2.7B\", \"Neo 2.7B\", \"Pygway 6B\", \"Nerybus 6.7B\", \"Pygway v8p4\", \"PPO-Janeway 6B\", \"PPO Shygmalion 6B\", \"LLaMA 7B\", \"Janin-GPTJ\", \"Javelin-GPTJ\", \"Javelin-R\", \"Janin-R\", \"Javalion-R\", \"Javalion-GPTJ\", \"Javelion-6B\", \"GPT-J-Pyg-PPO-6B\", \"ppo_hh_pythia-6B\", \"ppo_hh_gpt-j\", \"GPT-J-Pyg_PPO-6B\", \"GPT-J-Pyg_PPO-6B-Dev-V8p4\", \"Dolly_GPT-J-6b\", \"Dolly_Pyg-6B\"] {allow-input: true}\n", "Model = \"Руgmаlіоn 6В\" #@param [\"Nerys V2 6B\", \"Erebus 6B\", \"Skein 6B\", \"Janeway 6B\", \"Adventure 6B\", \"Руgmаlіоn 6В\", \"Руgmаlіоn 6В Dev\", \"Lit V2 6B\", \"Lit 6B\", \"Shinen 6B\", \"Nerys 2.7B\", \"AID 2.7B\", \"Erebus 2.7B\", \"Janeway 2.7B\", \"Picard 2.7B\", \"Horni LN 2.7B\", \"Horni 2.7B\", \"Shinen 2.7B\", \"OPT 2.7B\", \"Fairseq Dense 2.7B\", \"Neo 2.7B\", \"Руgwау 6B\", \"Nerybus 6.7B\", \"Руgwау v8p4\", \"PPO-Janeway 6B\", \"PPO Shуgmаlіоn 6B\", \"LLaMA 7B\", \"Janin-GPTJ\", \"Javelin-GPTJ\", \"Javelin-R\", \"Janin-R\", \"Javalion-R\", \"Javalion-GPTJ\", \"Javelion-6B\", \"GPT-J-Руg-PPO-6B\", \"ppo_hh_pythia-6B\", \"ppo_hh_gpt-j\", \"GPT-J-Руg_PPO-6B\", \"GPT-J-Руg_PPO-6B-Dev-V8p4\", \"Dolly_GPT-J-6b\", \"Dolly_Руg-6B\"] {allow-input: true}\n",
"Version = \"Official\" #@param [\"Official\", \"United\"] {allow-input: true}\n", "Version = \"Official\" #@param [\"Official\", \"United\"] {allow-input: true}\n",
"Provider = \"Localtunnel\" #@param [\"Localtunnel\"]\n", "Provider = \"Localtunnel\" #@param [\"Localtunnel\"]\n",
"ForceInitSteps = [] #@param {allow-input: true}\n", "ForceInitSteps = [] #@param {allow-input: true}\n",
@ -308,26 +308,19 @@
" !npm install\n", " !npm install\n",
" !npm install -g localtunnel\n", " !npm install -g localtunnel\n",
" !npm install -g forever\n", " !npm install -g forever\n",
" !pip install flask-cloudflared\n", " !pip install flask-cloudflared==0.0.10\n",
"ii.addTask(\"Install Tavern Dependencies\", installTavernDependencies)\n", "ii.addTask(\"Install Tavern Dependencies\", installTavernDependencies)\n",
"ii.run()\n", "ii.run()\n",
"\n", "\n",
"%env colaburl=$url\n", "%env colaburl=$url\n",
"%env SILLY_TAVERN_PORT=5001\n", "%env SILLY_TAVERN_PORT=5001\n",
"from flask_cloudflared import start_cloudflared\n",
"!sed -i 's/listen = true/listen = false/g' config.conf\n", "!sed -i 's/listen = true/listen = false/g' config.conf\n",
"!touch stdout.log stderr.log\n", "!touch stdout.log stderr.log\n",
"!forever start -o stdout.log -e stderr.log server.js\n", "!forever start -o stdout.log -e stderr.log server.js\n",
"print(\"KoboldAI LINK:\", url, '###Extensions API LINK###', globals.extras_url, \"###SillyTavern LINK###\", sep=\"\\n\")\n", "print(\"KoboldAI LINK:\", url, '###Extensions API LINK###', globals.extras_url, \"###SillyTavern LINK###\", sep=\"\\n\")\n",
"import inspect\n", "from flask_cloudflared import _run_cloudflared\n",
"import random\n", "cloudflare = _run_cloudflared(5001)\n",
"sig = inspect.signature(start_cloudflared)\n", "print(cloudflare)\n",
"sum = sum(1 for param in sig.parameters.values() if param.kind == param.POSITIONAL_OR_KEYWORD)\n",
"if sum > 1:\n",
" metrics_port = random.randint(8100, 9000)\n",
" start_cloudflared(5001, metrics_port)\n",
"else:\n",
" start_cloudflared(5001)\n",
"!tail -f stdout.log stderr.log" "!tail -f stdout.log stderr.log"
] ]
} }

View File

@ -36,8 +36,8 @@ def GetModels(Version):
"Skein 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Skein"), "Skein 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Skein"),
"Janeway 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Janeway"), "Janeway 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Janeway"),
"Adventure 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Adventure"), "Adventure 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Adventure"),
"Pygmalion 6B": mf.NewModelData("PygmalionAI/pygmalion-6b"), "Руgmаlіоn 6В": mf.NewModelData("PygmalionAI/pygmalion-6b"),
"Pygmalion 6B Dev": mf.NewModelData("PygmalionAI/pygmalion-6b", revision="dev"), "Руgmаlіоn 6В Dev": mf.NewModelData("PygmalionAI/pygmalion-6b", revision="dev"),
"Lit V2 6B": mf.NewModelData("hakurei/litv2-6B-rev3"), "Lit V2 6B": mf.NewModelData("hakurei/litv2-6B-rev3"),
"Lit 6B": mf.NewModelData("hakurei/lit-6B"), "Lit 6B": mf.NewModelData("hakurei/lit-6B"),
"Shinen 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Shinen"), "Shinen 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Shinen"),
@ -52,11 +52,11 @@ def GetModels(Version):
"Fairseq Dense 2.7B": mf.NewModelData("KoboldAI/fairseq-dense-2.7B"), "Fairseq Dense 2.7B": mf.NewModelData("KoboldAI/fairseq-dense-2.7B"),
"OPT 2.7B": mf.NewModelData("facebook/opt-2.7b"), "OPT 2.7B": mf.NewModelData("facebook/opt-2.7b"),
"Neo 2.7B": mf.NewModelData("EleutherAI/gpt-neo-2.7B"), "Neo 2.7B": mf.NewModelData("EleutherAI/gpt-neo-2.7B"),
"Pygway 6B": mf.NewModelData("TehVenom/PPO_Pygway-6b"), "Руgwау 6B": mf.NewModelData("TehVenom/PPO_Pygway-6b"),
"Nerybus 6.7B": mf.NewModelData("KoboldAI/OPT-6.7B-Nerybus-Mix"), "Nerybus 6.7B": mf.NewModelData("KoboldAI/OPT-6.7B-Nerybus-Mix"),
"Pygway v8p4": mf.NewModelData("TehVenom/PPO_Pygway-V8p4_Dev-6b"), "Руgwау v8p4": mf.NewModelData("TehVenom/PPO_Pygway-V8p4_Dev-6b"),
"PPO-Janeway 6B": mf.NewModelData("TehVenom/PPO_Janeway-6b"), "PPO-Janeway 6B": mf.NewModelData("TehVenom/PPO_Janeway-6b"),
"PPO Shygmalion 6B": mf.NewModelData("TehVenom/PPO_Shygmalion-6b"), "PPO Shуgmаlіоn 6B": mf.NewModelData("TehVenom/PPO_Shygmalion-6b"),
"LLaMA 7B": mf.NewModelData("decapoda-research/llama-7b-hf"), "LLaMA 7B": mf.NewModelData("decapoda-research/llama-7b-hf"),
"Janin-GPTJ": mf.NewModelData("digitous/Janin-GPTJ"), "Janin-GPTJ": mf.NewModelData("digitous/Janin-GPTJ"),
"Javelin-GPTJ": mf.NewModelData("digitous/Javelin-GPTJ"), "Javelin-GPTJ": mf.NewModelData("digitous/Javelin-GPTJ"),
@ -65,13 +65,13 @@ def GetModels(Version):
"Javalion-R": mf.NewModelData("digitous/Javalion-R"), "Javalion-R": mf.NewModelData("digitous/Javalion-R"),
"Javalion-GPTJ": mf.NewModelData("digitous/Javalion-GPTJ"), "Javalion-GPTJ": mf.NewModelData("digitous/Javalion-GPTJ"),
"Javelion-6B": mf.NewModelData("Cohee/Javelion-6b"), "Javelion-6B": mf.NewModelData("Cohee/Javelion-6b"),
"GPT-J-Pyg-PPO-6B": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B"), "GPT-J-Руg-PPO-6B": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B"),
"ppo_hh_pythia-6B": mf.NewModelData("reciprocate/ppo_hh_pythia-6B"), "ppo_hh_pythia-6B": mf.NewModelData("reciprocate/ppo_hh_pythia-6B"),
"ppo_hh_gpt-j": mf.NewModelData("reciprocate/ppo_hh_gpt-j"), "ppo_hh_gpt-j": mf.NewModelData("reciprocate/ppo_hh_gpt-j"),
"Alpaca-7B": mf.NewModelData("chainyo/alpaca-lora-7b"), "Alpaca-7B": mf.NewModelData("chainyo/alpaca-lora-7b"),
"LLaMA 4-bit": mf.NewModelData("decapoda-research/llama-13b-hf-int4"), "LLaMA 4-bit": mf.NewModelData("decapoda-research/llama-13b-hf-int4"),
"GPT-J-Pyg_PPO-6B": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B"), "GPT-J-Руg_PPO-6B": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B"),
"GPT-J-Pyg_PPO-6B-Dev-V8p4": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B-Dev-V8p4"), "GPT-J-Руg_PPO-6B-Dev-V8p4": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B-Dev-V8p4"),
"Dolly_GPT-J-6b": mf.NewModelData("TehVenom/Dolly_GPT-J-6b"), "Dolly_GPT-J-6b": mf.NewModelData("TehVenom/Dolly_GPT-J-6b"),
"Dolly_Pyg-6B": mf.NewModelData("TehVenom/AvgMerge_Dolly-Pygmalion-6b") "Dolly_Руg-6B": mf.NewModelData("TehVenom/AvgMerge_Dolly-Pygmalion-6b")
} }

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "sillytavern", "name": "sillytavern",
"version": "1.4.8", "version": "1.4.9",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sillytavern", "name": "sillytavern",
"version": "1.4.8", "version": "1.4.9",
"dependencies": { "dependencies": {
"@dqbd/tiktoken": "^1.0.2", "@dqbd/tiktoken": "^1.0.2",
"axios": "^1.3.4", "axios": "^1.3.4",

View File

@ -32,7 +32,7 @@
} }
}, },
"name": "sillytavern", "name": "sillytavern",
"version": "1.4.8", "version": "1.4.9",
"scripts": { "scripts": {
"start": "node server.js" "start": "node server.js"
}, },

View File

@ -319,23 +319,28 @@ class Client {
throw new Error('Invalid token.'); throw new Error('Invalid token.');
} }
const botList = viewer.availableBots; const botList = viewer.availableBots;
const retries = 2;
const bots = {}; const bots = {};
for (const bot of botList.filter(x => x.deletionState == 'not_deleted')) { for (const bot of botList.filter(x => x.deletionState == 'not_deleted')) {
const url = `https://poe.com/_next/data/${this.next_data.buildId}/${bot.displayName}.json`; try {
let r; const url = `https://poe.com/_next/data/${this.next_data.buildId}/${bot.displayName}.json`;
let r;
if (this.use_cached_bots && cached_bots[url]) { if (this.use_cached_bots && cached_bots[url]) {
r = cached_bots[url]; r = cached_bots[url];
} }
else { else {
logger.info(`Downloading ${url}`); logger.info(`Downloading ${url}`);
r = await request_with_retries(() => this.session.get(url)); r = await request_with_retries(() => this.session.get(url), retries);
cached_bots[url] = r; cached_bots[url] = r;
} }
const chatData = r.data.pageProps.payload.chatOfBotDisplayName; const chatData = r.data.pageProps.payload.chatOfBotDisplayName;
bots[chatData.defaultBotObject.nickname] = chatData; bots[chatData.defaultBotObject.nickname] = chatData;
}
catch {
console.log(`Could not load bot: ${bot.displayName}`);
}
} }
return bots; return bots;

View File

@ -1498,7 +1498,12 @@ async function Generate(type, automatic_trigger, force_name2) {
if (mesExamples.replace(/<START>/gi, '').trim().length === 0) { if (mesExamples.replace(/<START>/gi, '').trim().length === 0) {
mesExamples = ''; mesExamples = '';
} }
let mesExamplesArray = mesExamples.split(/<START>/gi).slice(1).map(block => `<START>\n${block.trim()}\n`); const blockHeading =
main_api === 'openai' ? '<START>' : // OpenAI handler always expects it
power_user.custom_chat_separator ? power_user.custom_chat_separator :
power_user.disable_examples_formatting ? '' :
is_pygmalion ? '<START>' : `This is how ${name2} should talk`;
let mesExamplesArray = mesExamples.split(/<START>/gi).slice(1).map(block => `${blockHeading}\n${block.trim()}\n`);
if (main_api === 'openai') { if (main_api === 'openai') {
const oai_chat = [...chat].filter(x => !x.is_system); const oai_chat = [...chat].filter(x => !x.is_system);
@ -1523,22 +1528,8 @@ async function Generate(type, automatic_trigger, force_name2) {
if (count_view_mes < topAnchorDepth) { if (count_view_mes < topAnchorDepth) {
storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : name2 + "'s personality: "); storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : name2 + "'s personality: ");
} }
}
if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) { storyString += appendToStoryString(Scenario, power_user.disable_scenario_formatting ? '' : 'Circumstances and context of the dialogue: ');
for (let i = 0; i < mesExamplesArray.length; i++) {
mesExamplesArray[i] = mesExamplesArray[i].replace(/<START>/gi, power_user.custom_chat_separator);
}
}
if (power_user.pin_examples && main_api !== 'openai') {
for (let example of mesExamplesArray) {
if (!is_pygmalion) {
const replaceString = power_user.disable_examples_formatting ? '' : `This is how ${name2} should talk`;
example = example.replace(/<START>/i, replaceString);
}
storyString += appendToStoryString(example, '');
}
} }
// Pygmalion does that anyway // Pygmalion does that anyway
@ -1645,53 +1636,46 @@ async function Generate(type, automatic_trigger, force_name2) {
chat2.push(''); chat2.push('');
} }
// Collect enough messages to fill the context let examplesString = '';
let chatString = ''; let chatString = '';
function canFitMessages() {
const encodeString = JSON.stringify(worldInfoString + storyString + examplesString + chatString + anchorTop + anchorBottom + charPersonality + promptBias + allAnchors);
return getTokenCount(encodeString, padding_tokens) < this_max_context;
}
// Force pinned examples into the context
let pinExmString;
if (power_user.pin_examples) {
pinExmString = examplesString = mesExamplesArray.join('');
}
// Collect enough messages to fill the context
let arrMes = []; let arrMes = [];
for (let item of chat2) { for (let item of chat2) {
chatString = item + chatString; chatString = item + chatString;
const encodeString = JSON.stringify( if (canFitMessages()) { //(The number of tokens in the entire promt) need fix, it must count correctly (added +120, so that the description of the character does not hide)
worldInfoString + storyString + chatString +
anchorTop + anchorBottom +
charPersonality + promptBias + allAnchors
);
const tokenCount = getTokenCount(encodeString, padding_tokens);
if (tokenCount < this_max_context) { //(The number of tokens in the entire promt) need fix, it must count correctly (added +120, so that the description of the character does not hide)
//if (is_pygmalion && i == chat2.length-1) item='<START>\n'+item; //if (is_pygmalion && i == chat2.length-1) item='<START>\n'+item;
arrMes[arrMes.length] = item; arrMes[arrMes.length] = item;
} else { } else {
break; break;
} }
await delay(1); //For disable slow down (encode gpt-2 need fix) await delay(1); //For disable slow down (encode gpt-2 need fix)
} }
// Prepare unpinned example messages // Estimate how many unpinned example messages fit in the context
let count_exm_add = 0; let count_exm_add = 0;
if (!power_user.pin_examples) { if (!power_user.pin_examples) {
let mesExmString = ''; for (let example of mesExamplesArray) {
for (let i = 0; i < mesExamplesArray.length; i++) { examplesString += example;
mesExmString += mesExamplesArray[i]; if (canFitMessages()) {
const prompt = JSON.stringify(worldInfoString + storyString + mesExmString + chatString + anchorTop + anchorBottom + charPersonality + promptBias + allAnchors);
const tokenCount = getTokenCount(prompt, padding_tokens);
if (tokenCount < this_max_context) {
if (power_user.disable_examples_formatting) {
mesExamplesArray[i] = mesExamplesArray[i].replace(/<START>/i, '');
} else if (!is_pygmalion) {
mesExamplesArray[i] = mesExamplesArray[i].replace(/<START>/i, `This is how ${name2} should talk`);
}
count_exm_add++; count_exm_add++;
await delay(1);
} else { } else {
break; break;
} }
await delay(1);
} }
} }
if (!is_pygmalion && Scenario && Scenario.length > 0) {
storyString += !power_user.disable_scenario_formatting ? `Circumstances and context of the dialogue: ${Scenario}\n` : `${Scenario}\n`;
}
let mesSend = []; let mesSend = [];
console.log('calling runGenerate'); console.log('calling runGenerate');
await runGenerate(); await runGenerate();
@ -1765,15 +1749,12 @@ async function Generate(type, automatic_trigger, force_name2) {
}); });
} }
let mesSendString = '';
let mesExmString = ''; let mesExmString = '';
let mesSendString = '';
function setPromtString() { function setPromtString() {
mesExmString = pinExmString ?? mesExamplesArray.slice(0, count_exm_add).join('');
mesSendString = ''; mesSendString = '';
mesExmString = '';
for (let j = 0; j < count_exm_add; j++) {
mesExmString += mesExamplesArray[j];
}
for (let j = 0; j < mesSend.length; j++) { for (let j = 0; j < mesSend.length; j++) {
mesSendString += mesSend[j]; mesSendString += mesSend[j];

View File

@ -23,10 +23,6 @@ Try on Colab (runs KoboldAI backend and TavernAI Extras server alongside): <a t
https://colab.research.google.com/github/Cohee1207/SillyTavern/blob/main/colab/GPU.ipynb https://colab.research.google.com/github/Cohee1207/SillyTavern/blob/main/colab/GPU.ipynb
If that didn't work, try the legacy link:
https://colab.research.google.com/github/Cohee1207/TavernAI-extras/blob/main/colab/GPU.ipynb
## Mobile support ## Mobile support
> **This fork can be run natively on Android phones using Termux. Please refer to this guide by ArroganceComplex#2659:** > **This fork can be run natively on Android phones using Termux. Please refer to this guide by ArroganceComplex#2659:**
@ -148,6 +144,10 @@ To connect over wifi you'll need your PC's local wifi IP address
- (For Windows: windows button > type 'cmd.exe' in the search bar> type 'ipconfig' in the console, hit Enter > "IPv4" listing) - (For Windows: windows button > type 'cmd.exe' in the search bar> type 'ipconfig' in the console, hit Enter > "IPv4" listing)
if you want other people on the internet to connect, check [here](https://whatismyipaddress.com/) for 'IPv4' if you want other people on the internet to connect, check [here](https://whatismyipaddress.com/) for 'IPv4'
### Still Unable To Connect?
- Create an inbound/outbound firewall rule for the port found in `config.conf`. Do NOT mistake this for portforwarding on your router, otherwise someone could find your chat logs and that's a big no-no.
- Enable the Private Network profile type in Settings > Network and Internet > Ethernet. This is VERY important for Windows 11, otherwise you would be unable to connect even with the aforementioned firewall rules.
## Performance issues? ## Performance issues?
Try enabling the No Blur Effect (Fast UI) mode on the User settings panel. Try enabling the No Blur Effect (Fast UI) mode on the User settings panel.