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": [
"#@title <b><-- Select your model below and then click this to start KoboldAI</b>\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",
"Provider = \"Localtunnel\" #@param [\"Localtunnel\"]\n",
"ForceInitSteps = [] #@param {allow-input: true}\n",
@ -308,26 +308,19 @@
" !npm install\n",
" !npm install -g localtunnel\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.run()\n",
"\n",
"%env colaburl=$url\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",
"!touch stdout.log stderr.log\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",
"import inspect\n",
"import random\n",
"sig = inspect.signature(start_cloudflared)\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",
"from flask_cloudflared import _run_cloudflared\n",
"cloudflare = _run_cloudflared(5001)\n",
"print(cloudflare)\n",
"!tail -f stdout.log stderr.log"
]
}

View File

@ -36,8 +36,8 @@ def GetModels(Version):
"Skein 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Skein"),
"Janeway 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Janeway"),
"Adventure 6B": mf.NewModelData("KoboldAI/GPT-J-6B-Adventure"),
"Pygmalion 6B": mf.NewModelData("PygmalionAI/pygmalion-6b"),
"Pygmalion 6B Dev": mf.NewModelData("PygmalionAI/pygmalion-6b", revision="dev"),
"Руgmаlіоn 6В": mf.NewModelData("PygmalionAI/pygmalion-6b"),
"Руgmаlіоn 6В Dev": mf.NewModelData("PygmalionAI/pygmalion-6b", revision="dev"),
"Lit V2 6B": mf.NewModelData("hakurei/litv2-6B-rev3"),
"Lit 6B": mf.NewModelData("hakurei/lit-6B"),
"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"),
"OPT 2.7B": mf.NewModelData("facebook/opt-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"),
"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 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"),
"Janin-GPTJ": mf.NewModelData("digitous/Janin-GPTJ"),
"Javelin-GPTJ": mf.NewModelData("digitous/Javelin-GPTJ"),
@ -65,13 +65,13 @@ def GetModels(Version):
"Javalion-R": mf.NewModelData("digitous/Javalion-R"),
"Javalion-GPTJ": mf.NewModelData("digitous/Javalion-GPTJ"),
"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_gpt-j": mf.NewModelData("reciprocate/ppo_hh_gpt-j"),
"Alpaca-7B": mf.NewModelData("chainyo/alpaca-lora-7b"),
"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-Pyg_PPO-6B-Dev-V8p4": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B-Dev-V8p4"),
"GPT-J-Руg_PPO-6B": mf.NewModelData("TehVenom/GPT-J-Pyg_PPO-6B"),
"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_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",
"version": "1.4.8",
"version": "1.4.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sillytavern",
"version": "1.4.8",
"version": "1.4.9",
"dependencies": {
"@dqbd/tiktoken": "^1.0.2",
"axios": "^1.3.4",

View File

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

View File

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

View File

@ -1498,7 +1498,12 @@ async function Generate(type, automatic_trigger, force_name2) {
if (mesExamples.replace(/<START>/gi, '').trim().length === 0) {
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') {
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) {
storyString += appendToStoryString(charPersonality, power_user.disable_personality_formatting ? '' : name2 + "'s personality: ");
}
}
if (power_user.custom_chat_separator && power_user.custom_chat_separator.length) {
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, '');
}
storyString += appendToStoryString(Scenario, power_user.disable_scenario_formatting ? '' : 'Circumstances and context of the dialogue: ');
}
// Pygmalion does that anyway
@ -1645,53 +1636,46 @@ async function Generate(type, automatic_trigger, force_name2) {
chat2.push('');
}
// Collect enough messages to fill the context
let examplesString = '';
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 = [];
for (let item of chat2) {
chatString = item + chatString;
const encodeString = JSON.stringify(
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 (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)
//if (is_pygmalion && i == chat2.length-1) item='<START>\n'+item;
arrMes[arrMes.length] = item;
} else {
break;
}
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;
if (!power_user.pin_examples) {
let mesExmString = '';
for (let i = 0; i < mesExamplesArray.length; i++) {
mesExmString += mesExamplesArray[i];
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`);
}
for (let example of mesExamplesArray) {
examplesString += example;
if (canFitMessages()) {
count_exm_add++;
await delay(1);
} else {
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 = [];
console.log('calling runGenerate');
await runGenerate();
@ -1765,15 +1749,12 @@ async function Generate(type, automatic_trigger, force_name2) {
});
}
let mesSendString = '';
let mesExmString = '';
let mesSendString = '';
function setPromtString() {
mesExmString = pinExmString ?? mesExamplesArray.slice(0, count_exm_add).join('');
mesSendString = '';
mesExmString = '';
for (let j = 0; j < count_exm_add; j++) {
mesExmString += mesExamplesArray[j];
}
for (let j = 0; j < mesSend.length; 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
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
> **This fork can be run natively on Android phones using Termux. Please refer to this guide by ArroganceComplex#2659:**
@ -129,7 +125,7 @@ const whitelistMode = false;
Save the file.
Restart your TAI server.
You will now be able to connect from other devices.
You will now be able to connect from other devices.
### Managing whitelisted IPs
@ -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)
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?
Try enabling the No Blur Effect (Fast UI) mode on the User settings panel.