Merge branch 'TavernAI:main' into main

This commit is contained in:
SillyLossy
2023-02-19 12:43:51 +02:00
committed by GitHub
5 changed files with 75 additions and 44 deletions

30
package-lock.json generated
View File

@ -12,6 +12,7 @@
"cors": "^2.8.5", "cors": "^2.8.5",
"csrf-csrf": "^2.2.3", "csrf-csrf": "^2.2.3",
"express": "^4.18.2", "express": "^4.18.2",
"ipaddr.js": "^2.0.1",
"multer": "^1.4.5-lts.1", "multer": "^1.4.5-lts.1",
"node-rest-client": "^3.1.1", "node-rest-client": "^3.1.1",
"open": "^8.4.0", "open": "^8.4.0",
@ -715,11 +716,11 @@
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
}, },
"node_modules/ipaddr.js": { "node_modules/ipaddr.js": {
"version": "1.9.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", "integrity": "sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng==",
"engines": { "engines": {
"node": ">= 0.10" "node": ">= 10"
} }
}, },
"node_modules/is-arrayish": { "node_modules/is-arrayish": {
@ -1065,6 +1066,14 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/proxy-addr/node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/pump": { "node_modules/pump": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz",
@ -2052,9 +2061,9 @@
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
}, },
"ipaddr.js": { "ipaddr.js": {
"version": "1.9.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" "integrity": "sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng=="
}, },
"is-arrayish": { "is-arrayish": {
"version": "0.3.2", "version": "0.3.2",
@ -2307,6 +2316,13 @@
"requires": { "requires": {
"forwarded": "0.2.0", "forwarded": "0.2.0",
"ipaddr.js": "1.9.1" "ipaddr.js": "1.9.1"
},
"dependencies": {
"ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
}
} }
}, },
"pump": { "pump": {

View File

@ -1,6 +1,10 @@
{ {
"dependencies": { "dependencies": {
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"csrf-csrf": "^2.2.3",
"express": "^4.18.2", "express": "^4.18.2",
"ipaddr.js": "^2.0.1",
"multer": "^1.4.5-lts.1", "multer": "^1.4.5-lts.1",
"node-rest-client": "^3.1.1", "node-rest-client": "^3.1.1",
"open": "^8.4.0", "open": "^8.4.0",
@ -8,10 +12,7 @@
"png-chunks-encode": "^1.0.0", "png-chunks-encode": "^1.0.0",
"png-chunks-extract": "^1.0.0", "png-chunks-extract": "^1.0.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sharp": "^0.31.3", "sharp": "^0.31.3"
"csrf-csrf": "^2.2.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5"
}, },
"name": "TavernAI", "name": "TavernAI",
"version": "1.2.8", "version": "1.2.8",
@ -21,7 +22,6 @@
"rules": { "rules": {
"no-path-concat": "off", "no-path-concat": "off",
"no-var": "off" "no-var": "off"
}, },
"pkg": { "pkg": {
"assets": [ "assets": [

View File

@ -18,6 +18,7 @@
<script src="scripts/showdown.min.js"></script> <script src="scripts/showdown.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="css/bg_load.css"> <link rel="stylesheet" href="css/bg_load.css">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script type=module> <script type=module>
//To DO:: //To DO::
@ -1249,7 +1250,7 @@
if(is_pygmalion){ if(is_pygmalion){
if_typing_text = false; if_typing_text = false;
message_already_generated +=getMessage; message_already_generated +=getMessage;
if(message_already_generated.indexOf('You:') === -1 && tokens_already_generated < parseInt(amount_gen) && getMessage.length > 0){ if(message_already_generated.indexOf('You:') === -1 && message_already_generated.indexOf('<|endoftext|>') === -1 && tokens_already_generated < parseInt(amount_gen) && getMessage.length > 0){
runGenerate(getMessage); runGenerate(getMessage);
return; return;
} }
@ -1266,6 +1267,10 @@
if(getMessage.indexOf(name1+":") != -1){ if(getMessage.indexOf(name1+":") != -1){
getMessage = getMessage.substr(0,getMessage.indexOf(name1+":")); getMessage = getMessage.substr(0,getMessage.indexOf(name1+":"));
}
if(getMessage.indexOf('<|endoftext|>') != -1){
getMessage = getMessage.substr(0,getMessage.indexOf('<|endoftext|>'));
} }
let this_mes_is_name = true; let this_mes_is_name = true;
if(getMessage.indexOf(name2+":") === 0){ if(getMessage.indexOf(name2+":") === 0){

View File

@ -2,10 +2,13 @@
Examples of interface and output: 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> ###### Download:
[TavernAI Run Online](https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb)<br><br> * [Win x64 .exe](https://sourceforge.net/projects/tavernaimain/files/TavernAI.rar/download)&nbsp;&nbsp;|&nbsp;&nbsp;[Node.js version](https://github.com/TavernAI/TavernAI/archive/refs/heads/main.zip)<br>
[TavetnAI Boosty](https://boosty.to/tavernai)<br> ###### Run online:
[TavernAI Discord](https://discord.gg/zmK2gmr45t)<br> * [TavernAI Colab](https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb)<br>
###### Links:
* [TavetnAI Boosty](https://boosty.to/tavernai)
* [TavernAI Discord](https://discord.gg/zmK2gmr45t)
## Features ## Features
* Creating characters with personality setup * Creating characters with personality setup
@ -40,10 +43,4 @@ If the message is not finished, you can simply send the request again, TavernAI
https://www.reddit.com/user/Crataco/comments/zuowi9/opensource_chatbot_companions/ https://www.reddit.com/user/Crataco/comments/zuowi9/opensource_chatbot_companions/
## For contacts ## For contacts
* Discord: Humi#5044 * Discord: Humi#5044
## For thanks and support
TavernAI is being developed with love and care on a voluntary basis. If you like the project and want to support it, your donation would make a huge impact!
BTC 1LASziomyYNkZ2zk8Sa4ZLTkvczBMrjyjP<br>
ETH 0x975E5C91042ce8168B3d37b17F99949c5eFB3Dfe<br>
TRX TCiBKCt6xEGrsjpgQA2jDXWJLyUh1KN2Sn
<br><br><br> <br><br><br>

View File

@ -18,14 +18,16 @@ const path = require('path');
const cookieParser = require('cookie-parser'); const cookieParser = require('cookie-parser');
const crypto = require('crypto'); const crypto = require('crypto');
const ipaddr = require('ipaddr.js');
const config = require(path.join(process.cwd(), './config.conf'));
const config = require('./config.conf');
const server_port = config.port; const server_port = config.port;
const whitelist = config.whitelist; const whitelist = config.whitelist;
const whitelistMode = config.whitelistMode; const whitelistMode = config.whitelistMode;
const autorun = config.autorun; const autorun = config.autorun;
var Client = require('node-rest-client').Client; var Client = require('node-rest-client').Client;
var client = new Client(); var client = new Client();
@ -98,7 +100,18 @@ const CORS = cors({
app.use(CORS); app.use(CORS);
app.use(function (req, res, next) { //Security app.use(function (req, res, next) { //Security
const clientIp = req.connection.remoteAddress.split(':').pop(); let clientIp = req.connection.remoteAddress;
let ip = ipaddr.parse(clientIp);
// Check if the IP address is IPv4-mapped IPv6 address
if (ip.kind() === 'ipv6' && ip.isIPv4MappedAddress()) {
const ipv4 = ip.toIPv4Address().toString();
clientIp = ipv4;
} else {
clientIp = ip;
clientIp = clientIp.toString();
}
//clientIp = req.connection.remoteAddress.split(':').pop();
if (whitelistMode === true && !whitelist.includes(clientIp)) { if (whitelistMode === true && !whitelist.includes(clientIp)) {
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.conf in root of TavernAI folder.\n'); 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.conf in root of TavernAI folder.\n');
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.conf in root of TavernAI folder.'); 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.conf in root of TavernAI folder.');
@ -109,7 +122,7 @@ app.use(function (req, res, next) { //Security
app.use((req, res, next) => { app.use((req, res, next) => {
if (req.url.startsWith('/characters/') && is_colab && process.env.googledrive == 2) { if (req.url.startsWith('/characters/') && is_colab && process.env.googledrive == 2) {
const filePath = path.join(charactersPath, req.url.substr('/characters'.length)); const filePath = path.join(charactersPath, decodeURIComponent(req.url.substr('/characters'.length)));
fs.access(filePath, fs.constants.R_OK, (err) => { fs.access(filePath, fs.constants.R_OK, (err) => {
if (!err) { if (!err) {
res.sendFile(filePath); res.sendFile(filePath);
@ -128,7 +141,7 @@ app.use(express.static(__dirname + "/public", { refresh: true }));
app.use('/backgrounds', (req, res) => { app.use('/backgrounds', (req, res) => {
const filePath = path.join(process.cwd(), 'public/backgrounds', req.url); const filePath = decodeURIComponent(path.join(process.cwd(), 'public/backgrounds', req.url.replace(/%20/g, ' ')));
fs.readFile(filePath, (err, data) => { fs.readFile(filePath, (err, data) => {
if (err) { if (err) {
res.status(404).send('File not found'); res.status(404).send('File not found');
@ -139,7 +152,7 @@ app.use('/backgrounds', (req, res) => {
}); });
}); });
app.use('/characters', (req, res) => { app.use('/characters', (req, res) => {
const filePath = path.join(process.cwd(), charactersPath, req.url); const filePath = decodeURIComponent(path.join(process.cwd(), charactersPath, req.url.replace(/%20/g, ' ')));
fs.readFile(filePath, (err, data) => { fs.readFile(filePath, (err, data) => {
if (err) { if (err) {
res.status(404).send('File not found'); res.status(404).send('File not found');