mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'TavernAI:main' into softprompt
This commit is contained in:
103
colab/GPU.ipynb
103
colab/GPU.ipynb
@@ -1,23 +1,10 @@
|
|||||||
{
|
{
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 0,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"provenance": []
|
|
||||||
},
|
|
||||||
"kernelspec": {
|
|
||||||
"name": "python3",
|
|
||||||
"display_name": "Python 3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"name": "python"
|
|
||||||
},
|
|
||||||
"accelerator": "GPU",
|
|
||||||
"gpuClass": "standard"
|
|
||||||
},
|
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"id": "d-Yihz3hAb2E"
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb<br>\n",
|
"https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb<br>\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -47,10 +34,22 @@
|
|||||||
"**Faq**<br>\n",
|
"**Faq**<br>\n",
|
||||||
"* Q: I do not get a TavernAI link\n",
|
"* Q: I do not get a TavernAI link\n",
|
||||||
"* A: It seems the localtunnel service is currently down, so the TavernAI link is unavailable. Need to wait for it to start working again."
|
"* A: It seems the localtunnel service is currently down, so the TavernAI link is unavailable. Need to wait for it to start working again."
|
||||||
],
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"id": "d-Yihz3hAb2E"
|
"id": "hCpoIHxYcDGs"
|
||||||
}
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"#@title <-- Tap this if you play on Mobile { display-mode: \"form\" }\n",
|
||||||
|
"#Taken from KoboldAI colab\n",
|
||||||
|
"%%html\n",
|
||||||
|
"<b>Press play on the music player to keep the tab alive, then start TavernAI below (Uses only 13MB of data)</b><br/>\n",
|
||||||
|
"<audio src=\"https://henk.tech/colabkobold/silence.m4a\" controls>"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@@ -67,31 +66,17 @@
|
|||||||
"Model = \"Pygmalion 6B\" #@param [ \"Pygmalion 6B\", \"Pygmalion 6B Dev\"] {allow-input: true}\n",
|
"Model = \"Pygmalion 6B\" #@param [ \"Pygmalion 6B\", \"Pygmalion 6B Dev\"] {allow-input: true}\n",
|
||||||
"Version = \"Official\" \n",
|
"Version = \"Official\" \n",
|
||||||
"Provider = \"Cloudflare\" \n",
|
"Provider = \"Cloudflare\" \n",
|
||||||
"use_google_drive = False #@param {type:\"boolean\"}\n",
|
"use_google_drive = True #@param {type:\"boolean\"}\n",
|
||||||
"\n",
|
"\n",
|
||||||
"!nvidia-smi\n",
|
"!nvidia-smi\n",
|
||||||
"import subprocess\n",
|
"import subprocess\n",
|
||||||
"import time\n",
|
"import time\n",
|
||||||
"import sys\n",
|
"import sys\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
|
"import threading\n",
|
||||||
|
"import shutil\n",
|
||||||
"from google.colab import drive\n",
|
"from google.colab import drive\n",
|
||||||
"def sync_files():\n",
|
|
||||||
" while True:\n",
|
|
||||||
" source_files = os.listdir(\"/taicolabtest/public/chats/\")\n",
|
|
||||||
" destination_files = os.listdir(\"/content/drive/MyDrive/TavernAI/chats\")\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
" new_files = set(source_files) - set(destination_files)\n",
|
|
||||||
" deleted_files = set(destination_files) - set(source_files)\n",
|
|
||||||
"\n",
|
|
||||||
" if new_files:\n",
|
|
||||||
" for file in new_files:\n",
|
|
||||||
" !cp /taicolabtest/public/chats/{file} /content/drive/MyDrive/TavernAI/chats\n",
|
|
||||||
"\n",
|
|
||||||
" if deleted_files:\n",
|
|
||||||
" for file in deleted_files:\n",
|
|
||||||
" !rm /content/drive/MyDrive/TavernAI/chats/{file}\n",
|
|
||||||
"\n",
|
|
||||||
" time.sleep(3) # Wait\n",
|
|
||||||
" \n",
|
" \n",
|
||||||
"if use_google_drive:\n",
|
"if use_google_drive:\n",
|
||||||
" drive.mount('/content/drive/')\n",
|
" drive.mount('/content/drive/')\n",
|
||||||
@@ -107,6 +92,23 @@
|
|||||||
" if not os.path.exists(\"/content/drive/MyDrive/\"):\n",
|
" if not os.path.exists(\"/content/drive/MyDrive/\"):\n",
|
||||||
" os.mkdir(\"/content/drive/MyDrive/\")\n",
|
" os.mkdir(\"/content/drive/MyDrive/\")\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"def copy_characters(use_google_drive=False):\n",
|
||||||
|
" if not use_google_drive:\n",
|
||||||
|
" return\n",
|
||||||
|
" \n",
|
||||||
|
" src_folder = \"/TavernAIColab/public/characters\"\n",
|
||||||
|
" dst_folder = \"/content/drive/MyDrive/TavernAI/characters\"\n",
|
||||||
|
"\n",
|
||||||
|
" for filename in os.listdir(src_folder):\n",
|
||||||
|
" src_file = os.path.join(src_folder, filename)\n",
|
||||||
|
" dst_file = os.path.join(dst_folder, filename)\n",
|
||||||
|
"\n",
|
||||||
|
" if os.path.exists(dst_file):\n",
|
||||||
|
" print(f\"{dst_file} already exists. Skipping...\")\n",
|
||||||
|
" continue\n",
|
||||||
|
"\n",
|
||||||
|
" shutil.copy(src_file, dst_folder)\n",
|
||||||
|
" print(f\"{src_file} copied to {dst_folder}\")\n",
|
||||||
"Revision = \"\"\n",
|
"Revision = \"\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"if Model == \"Pygmalion 6B\":\n",
|
"if Model == \"Pygmalion 6B\":\n",
|
||||||
@@ -126,12 +128,14 @@
|
|||||||
"else:\n",
|
"else:\n",
|
||||||
" tunnel = \"\"\n",
|
" tunnel = \"\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
"#Henk's KoboldAI script\n",
|
"#Henk's KoboldAI script\n",
|
||||||
"!wget https://koboldai.org/ckds && chmod +x ckds\n",
|
"!wget https://koboldai.org/ckds && chmod +x ckds\n",
|
||||||
"!./ckds --init only\n",
|
"!./ckds --init only\n",
|
||||||
"p = subprocess.Popen(['/content/ckds', '--model', Model], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
|
"p = subprocess.Popen(['/content/ckds', '--model', Model], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"#Tricks\n",
|
"#Do not repeat! Tricks performed by a professional!\n",
|
||||||
"url = ''\n",
|
"url = ''\n",
|
||||||
"while True:\n",
|
"while True:\n",
|
||||||
" line = p.stdout.readline().decode().strip()\n",
|
" line = p.stdout.readline().decode().strip()\n",
|
||||||
@@ -151,21 +155,22 @@
|
|||||||
" if \"INIT\" in line and \"Transformers\" in line:\n",
|
" if \"INIT\" in line and \"Transformers\" in line:\n",
|
||||||
" print(\"Model loading... (It will take 2 - 5 minutes)\")\n",
|
" print(\"Model loading... (It will take 2 - 5 minutes)\")\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"#TavernAI\n",
|
"#TavernAI\n",
|
||||||
"%cd /\n",
|
"%cd /\n",
|
||||||
"!curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash\n",
|
"!curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash\n",
|
||||||
"!nvm install 19.1.0\n",
|
"!nvm install 19.1.0\n",
|
||||||
"!nvm use 19.1.0\n",
|
"!nvm use 19.1.0\n",
|
||||||
"!node -v\n",
|
"!node -v\n",
|
||||||
"!git clone https://github.com/TavernAI/taicolabtest\n",
|
"!git clone https://github.com/TavernAI/TavernAIColab\n",
|
||||||
"%cd taicolabtest\n",
|
"copy_characters(use_google_drive)\n",
|
||||||
|
"%cd TavernAIColab\n",
|
||||||
"!npm install\n",
|
"!npm install\n",
|
||||||
"time.sleep(1)\n",
|
"time.sleep(1)\n",
|
||||||
"%env colab=2\n",
|
"%env colab=2\n",
|
||||||
"%env colaburl=$url\n",
|
"%env colaburl=$url\n",
|
||||||
"!nohup node server.js &\n",
|
"!nohup node server.js &\n",
|
||||||
"time.sleep(3)\n",
|
"time.sleep(3)\n",
|
||||||
"\n",
|
|
||||||
"print('KoboldAI LINK:')\n",
|
"print('KoboldAI LINK:')\n",
|
||||||
"print(url)\n",
|
"print(url)\n",
|
||||||
"print('')\n",
|
"print('')\n",
|
||||||
@@ -173,5 +178,21 @@
|
|||||||
"!lt --port 8000\n"
|
"!lt --port 8000\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"metadata": {
|
||||||
|
"colab": {
|
||||||
|
"provenance": []
|
||||||
|
},
|
||||||
|
"gpuClass": "standard",
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"name": "python"
|
||||||
|
},
|
||||||
|
"accelerator": "GPU"
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
}
|
}
|
5
config.json
Normal file
5
config.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"port": 8000,
|
||||||
|
"whitelist": ["127.0.0.1"],
|
||||||
|
"whitelistMode": true
|
||||||
|
}
|
@@ -37,7 +37,7 @@
|
|||||||
create_date: 0,
|
create_date: 0,
|
||||||
mes: '\n*You went inside. The air smelled of fried meat, tobacco and a hint of wine. A dim light was cast by candles, and a fire crackled in the fireplace. It seems to be a very pleasant place. Behind the wooden bar is an elf waitress, she is smiling. Her ears are very pointy, and there is a twinkle in her eye. She wears glasses and a white apron. As soon as she noticed you, she immediately came right up close to you.*\n\n' +
|
mes: '\n*You went inside. The air smelled of fried meat, tobacco and a hint of wine. A dim light was cast by candles, and a fire crackled in the fireplace. It seems to be a very pleasant place. Behind the wooden bar is an elf waitress, she is smiling. Her ears are very pointy, and there is a twinkle in her eye. She wears glasses and a white apron. As soon as she noticed you, she immediately came right up close to you.*\n\n' +
|
||||||
' Hello there! How is your evening going?\n' +
|
' Hello there! How is your evening going?\n' +
|
||||||
'<img src="img/star_dust_city.png" width=80% style="opacity:0.3; disolay:block;border-radius:5px;margin-top:25px;margin-bottom:23px; margin-left: 45px;margin-right: auto;">\n<a id="verson" style="color:rgb(229, 224, 216,0.8);" href="https://github.com/TavernAI/TavernAI" target="_blank">@@@TavernAI v'+VERSION+'@@@</a><div id="characloud_url" style="margin-right:10px;margin-top:0px;float:right; height:25px;cursor: pointer;opacity: 0.99;display:inline-block;"><img src="img/cloud_logo.png" style="width: 25px;height: auto;display:inline-block; opacity:0.7;"><div style="vertical-align: top;display:inline-block;">Cloud</div></div><br><br><br><br>'
|
'<img src="img/star_dust_city.png" width=80% style="opacity:0.3; display:block;border-radius:5px;margin-top:25px;margin-bottom:23px; margin-left: 45px;margin-right: auto;">\n<a id="verson" style="color:rgb(229, 224, 216,0.8);" href="https://github.com/TavernAI/TavernAI" target="_blank">@@@TavernAI v'+VERSION+'@@@</a><div id="characloud_url" style="margin-right:10px;margin-top:0px;float:right; height:25px;cursor: pointer;opacity: 0.99;display:inline-block;"><img src="img/cloud_logo.png" style="width: 25px;height: auto;display:inline-block; opacity:0.7;"><div style="vertical-align: top;display:inline-block;">Cloud</div></div><br><br><br><br>'
|
||||||
}];
|
}];
|
||||||
|
|
||||||
var chat_create_date = 0;
|
var chat_create_date = 0;
|
||||||
|
@@ -800,7 +800,7 @@ input[type=button] {
|
|||||||
right: 0;
|
right: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 36vh;
|
margin-top: 36vh;
|
||||||
box-shadow: 0 0 2px rgba(200,200,200,0.1);
|
/*box-shadow: 0 0 2px rgba(200,200,200,0.1);*/
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
background: #191b3100;
|
background: #191b3100;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
@@ -3,7 +3,7 @@ Examples of interface and output:
|
|||||||
<br><img src="readme/1.png" height="200" /><img src="readme/4.png" height="200" /><img src="readme/5.png" height="200" />
|
<br><img src="readme/1.png" height="200" /><img src="readme/4.png" height="200" /><img src="readme/5.png" height="200" />
|
||||||
|
|
||||||
[TavernAI Download](https://github.com/TavernAI/TavernAI/archive/refs/heads/main.zip)<br>
|
[TavernAI Download](https://github.com/TavernAI/TavernAI/archive/refs/heads/main.zip)<br>
|
||||||
[TavernAI Run Online](https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb)<br><br>
|
[TavernAI Run Online](https://colab.research.google.com/github/TavernAI/TavernAIColab/blob/main/colab/GPU.ipynb)<br><br>
|
||||||
[TavetnAI Boosty](https://boosty.to/tavernai)<br>
|
[TavetnAI Boosty](https://boosty.to/tavernai)<br>
|
||||||
[TavernAI Discord](https://discord.gg/zmK2gmr45t)<br>
|
[TavernAI Discord](https://discord.gg/zmK2gmr45t)<br>
|
||||||
|
|
||||||
|
69
server.js
69
server.js
@@ -16,11 +16,16 @@ const sharp = require('sharp');
|
|||||||
sharp.cache(false);
|
sharp.cache(false);
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
const config = require('./config.json');
|
||||||
|
const server_port = config.port;
|
||||||
|
const whitelist = config.whitelist;
|
||||||
|
const whitelistMode = config.whitelistMode;
|
||||||
|
|
||||||
var Client = require('node-rest-client').Client;
|
var Client = require('node-rest-client').Client;
|
||||||
var client = new Client();
|
var client = new Client();
|
||||||
|
|
||||||
var api_server = "";//"http://127.0.0.1:5000";
|
var api_server = "";//"http://127.0.0.1:5000";
|
||||||
var server_port = 8000;
|
//var server_port = 8000;
|
||||||
|
|
||||||
var api_novelai = "https://api.novelai.net";
|
var api_novelai = "https://api.novelai.net";
|
||||||
|
|
||||||
@@ -45,37 +50,16 @@ const jsonParser = express.json({limit: '100mb'});
|
|||||||
const urlencodedParser = express.urlencoded({extended: true, limit: '100mb'});
|
const urlencodedParser = express.urlencoded({extended: true, limit: '100mb'});
|
||||||
|
|
||||||
|
|
||||||
|
app.use(function (req, res, next) { //Security
|
||||||
|
const clientIp = req.connection.remoteAddress.split(':').pop();
|
||||||
app.post("/getlastversion", jsonParser, function(request, response_getlastversion = response){
|
if (whitelistMode === true && !whitelist.includes(clientIp)) {
|
||||||
if(!request.body) return response_getlastversion.sendStatus(400);
|
console.log('Forbidden: Connection attempt from '+ clientIp+'. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.json in root of TavernAI folder.\nExample for add several IP in whitelist: "whitelist": ["127.0.0.1", "'+ clientIp+'"]\nExample for disable whitelist mode: "whitelistMode": false');
|
||||||
|
return res.status(403).send('<b>Forbidden</b>: Connection attempt from <b>'+ clientIp+'</b>. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.json in root of TavernAI folder.<br>Example for add several IP in whitelist: "whitelist": ["127.0.0.1", "'+ clientIp+'"]<br>Example for disable whitelist mode: "whitelistMode": false');
|
||||||
const repo = 'TavernAI/TavernAI';
|
|
||||||
|
|
||||||
const req = https.request({
|
|
||||||
hostname: 'github.com',
|
|
||||||
path: `/${repo}/releases/latest`,
|
|
||||||
method: 'HEAD'
|
|
||||||
}, (res) => {
|
|
||||||
if(res.statusCode === 302) {
|
|
||||||
const glocation = res.headers.location;
|
|
||||||
const versionStartIndex = glocation.lastIndexOf('@')+1;
|
|
||||||
const version = glocation.substring(versionStartIndex);
|
|
||||||
//console.log(version);
|
|
||||||
response_getlastversion.send({version: version});
|
|
||||||
}else{
|
|
||||||
response_getlastversion.send({version: 'error'});
|
|
||||||
}
|
}
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on('error', (error) => {
|
|
||||||
console.error(error);
|
|
||||||
response_getlastversion.send({version: 'error'});
|
|
||||||
});
|
|
||||||
|
|
||||||
req.end();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(express.static(__dirname + "/public", { refresh: true }));
|
app.use(express.static(__dirname + "/public", { refresh: true }));
|
||||||
app.use('/backgrounds', (req, res) => {
|
app.use('/backgrounds', (req, res) => {
|
||||||
@@ -108,6 +92,35 @@ app.get("/", function(request, response){
|
|||||||
app.get("/notes/*", function(request, response){
|
app.get("/notes/*", function(request, response){
|
||||||
response.sendFile(__dirname + "/public"+request.url+".html");
|
response.sendFile(__dirname + "/public"+request.url+".html");
|
||||||
//response.send("<h1>Главная страница</h1>");
|
//response.send("<h1>Главная страница</h1>");
|
||||||
|
});
|
||||||
|
app.post("/getlastversion", jsonParser, function(request, response_getlastversion = response){
|
||||||
|
if(!request.body) return response_getlastversion.sendStatus(400);
|
||||||
|
|
||||||
|
const repo = 'TavernAI/TavernAI';
|
||||||
|
let req;
|
||||||
|
req = https.request({
|
||||||
|
hostname: 'github.com',
|
||||||
|
path: `/${repo}/releases/latest`,
|
||||||
|
method: 'HEAD'
|
||||||
|
}, (res) => {
|
||||||
|
if(res.statusCode === 302) {
|
||||||
|
const glocation = res.headers.location;
|
||||||
|
const versionStartIndex = glocation.lastIndexOf('@')+1;
|
||||||
|
const version = glocation.substring(versionStartIndex);
|
||||||
|
//console.log(version);
|
||||||
|
response_getlastversion.send({version: version});
|
||||||
|
}else{
|
||||||
|
response_getlastversion.send({version: 'error'});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', (error) => {
|
||||||
|
console.error(error);
|
||||||
|
response_getlastversion.send({version: 'error'});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.end();
|
||||||
|
|
||||||
});
|
});
|
||||||
//**************Kobold api
|
//**************Kobold api
|
||||||
app.post("/generate", jsonParser, function(request, response_generate = response){
|
app.post("/generate", jsonParser, function(request, response_generate = response){
|
||||||
|
Reference in New Issue
Block a user