mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/Cohee1207/SillyTavern into dev
This commit is contained in:
40
package-lock.json
generated
40
package-lock.json
generated
@@ -1,16 +1,15 @@
|
||||
{
|
||||
"name": "sillytavern",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sillytavern",
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"@zeldafan0225/ai_horde": "^4.0.1",
|
||||
"axios": "^1.3.4",
|
||||
"command-exists": "^1.2.9",
|
||||
"compression": "^1",
|
||||
@@ -21,6 +20,7 @@
|
||||
"exifreader": "^4.12.0",
|
||||
"express": "^4.18.2",
|
||||
"gpt3-tokenizer": "^1.1.5",
|
||||
"ip-matching": "^2.1.2",
|
||||
"ipaddr.js": "^2.0.1",
|
||||
"jimp": "^0.22.7",
|
||||
"jquery": "^3.6.4",
|
||||
@@ -419,11 +419,6 @@
|
||||
"regenerator-runtime": "^0.13.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@thunder04/supermap": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@thunder04/supermap/-/supermap-3.0.2.tgz",
|
||||
"integrity": "sha512-SjlUrfe45mwiAgKZHRRhh+oHRwXsjrCg6NI2HJxymTJt+9SwJw422yse/A5lr5WBpTky6qEce+H6Ec1sytm93A=="
|
||||
},
|
||||
"node_modules/@tokenizer/token": {
|
||||
"version": "0.3.0",
|
||||
"license": "MIT"
|
||||
@@ -440,16 +435,6 @@
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@zeldafan0225/ai_horde": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@zeldafan0225/ai_horde/-/ai_horde-4.0.1.tgz",
|
||||
"integrity": "sha512-mf1cknnBYzKCvgH4KAkdVY3J7sLkR2b79W6I9ZEA2aJCyua28bpZzNaCDSHKKyaNj+0wyHViC+L53X32jw9pMg==",
|
||||
"dependencies": {
|
||||
"@thunder04/supermap": "^3.0.2",
|
||||
"centra": "^2.5.0",
|
||||
"esbuild": "^0.12.28"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "1.3.8",
|
||||
"license": "MIT",
|
||||
@@ -637,11 +622,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/centra": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/centra/-/centra-2.6.0.tgz",
|
||||
"integrity": "sha512-dgh+YleemrT8u85QL11Z6tYhegAs3MMxsaWAq/oXeAmYJ7VxL3SI9TZtnfaEvNDMAPolj25FXIb3S+HCI4wQaQ=="
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "8.0.1",
|
||||
"license": "ISC",
|
||||
@@ -893,15 +873,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.12.29",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.12.29.tgz",
|
||||
"integrity": "sha512-w/XuoBCSwepyiZtIRsKsetiLDUVGPVw1E/R3VTFSecIy8UR7Cq3SOtwKHJMFoVqqVG36aGkzh4e8BvpO1Fdc7g==",
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
}
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.1.1",
|
||||
"license": "MIT",
|
||||
@@ -1220,6 +1191,11 @@
|
||||
"version": "2.0.4",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ip-matching": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ip-matching/-/ip-matching-2.1.2.tgz",
|
||||
"integrity": "sha512-/ok+VhKMasgR5gvTRViwRFQfc0qYt9Vdowg6TO4/pFlDCob5ZjGPkwuOoQVCd5OrMm20zqh+1vA8KLJZTeWudg=="
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
"version": "2.0.1",
|
||||
"license": "MIT",
|
||||
|
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"@zeldafan0225/ai_horde": "^4.0.1",
|
||||
"axios": "^1.3.4",
|
||||
"command-exists": "^1.2.9",
|
||||
"compression": "^1",
|
||||
@@ -12,6 +11,7 @@
|
||||
"exifreader": "^4.12.0",
|
||||
"express": "^4.18.2",
|
||||
"gpt3-tokenizer": "^1.1.5",
|
||||
"ip-matching": "^2.1.2",
|
||||
"ipaddr.js": "^2.0.1",
|
||||
"jimp": "^0.22.7",
|
||||
"jquery": "^3.6.4",
|
||||
@@ -42,7 +42,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/Cohee1207/SillyTavern.git"
|
||||
},
|
||||
"version": "1.5.3",
|
||||
"version": "1.5.4",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
|
@@ -748,7 +748,7 @@
|
||||
<div class="range-block-title">
|
||||
Seed
|
||||
</div>
|
||||
<input type="number" id="seed_textgenerationwebui" class="text_pole" maxlength="100" />
|
||||
<input type="number" id="seed_textgenerationwebui" class="text_pole wide100p" maxlength="100" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="openai_settings">
|
||||
@@ -971,7 +971,7 @@
|
||||
</div>
|
||||
<div id="rm_api_block" class="drawer-content closedDrawer">
|
||||
<h3 id="title_api">API</h3>
|
||||
<div class="flex-container">
|
||||
<div class="flex-container flexFlowColumn">
|
||||
<div id="main-API-selector-block">
|
||||
<select id="main_api">
|
||||
<option value="kobold">KoboldAI</option>
|
||||
@@ -1053,7 +1053,7 @@
|
||||
</ol>
|
||||
</span>
|
||||
<div class="flex-container">
|
||||
<input id="api_key_novel" name="api_key_novel" class="text_pole flex1" maxlength="500" size="35" type="text">
|
||||
<input id="api_key_novel" name="api_key_novel" class="text_pole flex1 wide100p" maxlength="500" size="35" type="text">
|
||||
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_novel"></div>
|
||||
</div>
|
||||
<div class="neutral_warning">For privacy reasons, your API key will be hidden after you reload the page.</div>
|
||||
@@ -1075,24 +1075,31 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="textgenerationwebui_api" style="display: none;position: relative;">
|
||||
<div class="oobabooga_logo">
|
||||
<div class="oobabooga_logo flex-container">
|
||||
<a href="https://github.com/oobabooga/text-generation-webui" target="_blank">
|
||||
oobabooga/text-generation-webui
|
||||
</a>
|
||||
<span>
|
||||
Make sure you run it with <tt>--api</tt> flag
|
||||
</span>
|
||||
</div>
|
||||
<span>
|
||||
Make sure you run it with <tt>--api</tt> flag
|
||||
</span>
|
||||
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||
<h4>Blocking API url</h4>
|
||||
<h5>Example: http://127.0.0.1:5000/</h5>
|
||||
<input id="textgenerationwebui_api_url_text" name="textgenerationwebui_api_url" class="text_pole" maxlength="500" value="" autocomplete="off">
|
||||
<div>
|
||||
<div class="flex-container">
|
||||
<div class="flex1">
|
||||
<h4>Blocking API url</h4>
|
||||
<h5>Example: http://127.0.0.1:5000/</h5>
|
||||
<input id="textgenerationwebui_api_url_text" name="textgenerationwebui_api_url" class="text_pole wide100p"
|
||||
maxlength="500" value="">
|
||||
</div>
|
||||
<div class="flex1">
|
||||
<h4>Streaming API url</h4>
|
||||
<h5>Example: ws://127.0.0.1:5005/api/v1/stream</h5>
|
||||
<input id="streaming_url_textgenerationwebui" type="text" class="text_pole wide100p" maxlength="500" value="">
|
||||
</div>
|
||||
</div>
|
||||
<input id="api_button_textgenerationwebui" class="menu_button" type="submit" value="Connect">
|
||||
<h4>Streaming API url</h4>
|
||||
<h5>Example: ws://127.0.0.1:5005/api/v1/stream</h5>
|
||||
<input id="streaming_url_textgenerationwebui" type="text" class="text_pole" maxlength="500" value="" autocomplete="off">
|
||||
<div id="api_loading_textgenerationwebui" class="api-load-icon fa-solid fa-hourglass fa-spin"></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="online_status4">
|
||||
<div class="online_status_indicator4"></div>
|
||||
<div class="online_status_text4">Not connected</div>
|
||||
@@ -1266,7 +1273,7 @@
|
||||
Input Sequence
|
||||
</label>
|
||||
<div>
|
||||
<input id="instruct_input_sequence" class="text_pole textarea_compact" type="text" maxlength="100" />
|
||||
<input id="instruct_input_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex1">
|
||||
@@ -1274,7 +1281,7 @@
|
||||
Output Sequence
|
||||
</label>
|
||||
<div>
|
||||
<input id="instruct_output_sequence" class="text_pole textarea_compact" type="text" maxlength="100" />
|
||||
<input id="instruct_output_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1284,7 +1291,7 @@
|
||||
System Sequence
|
||||
</label>
|
||||
<div>
|
||||
<input id="instruct_system_sequence" class="text_pole textarea_compact" type="text" maxlength="100" />
|
||||
<input id="instruct_system_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex1">
|
||||
@@ -1292,7 +1299,7 @@
|
||||
Stop Sequence
|
||||
</label>
|
||||
<div>
|
||||
<input id="instruct_stop_sequence" class="text_pole textarea_compact" type="text" maxlength="100" />
|
||||
<input id="instruct_stop_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1777,7 +1784,7 @@
|
||||
<div name="NameChanger">
|
||||
<h4>Name</h4>
|
||||
<div class="change_name">
|
||||
<input id="your_name" name="your_name" placeholder="Enter your name" class="text_pole" maxlength="50" value="" autocomplete="off">
|
||||
<input id="your_name" name="your_name" placeholder="Enter your name" class="text_pole wide100p" maxlength="50" value="" autocomplete="off">
|
||||
<div id="your_name_button" class="menu_button fa-solid fa-check" title="Click to set a new User Name">
|
||||
</div>
|
||||
</div>
|
||||
@@ -1912,7 +1919,7 @@
|
||||
|
||||
<div id="tags_div">
|
||||
<div class="tag_controls">
|
||||
<input id="tagInput" class="text_pole tag_input" placeholder="Search / Create tags" maxlength="25" />
|
||||
<input id="tagInput" class="text_pole tag_input wide100p margin0" placeholder="Search / Create tags" maxlength="25" />
|
||||
<div class="tags_view menu_button fa-solid fa-tags" title="View all tags"></div>
|
||||
</div>
|
||||
<div id="tagList" class="tags"></div>
|
||||
@@ -1965,15 +1972,15 @@
|
||||
</div>
|
||||
<div class="inline-drawer-content">
|
||||
<div name="group-metadata-controls" class="marginTopBot5">
|
||||
<input id="rm_group_chat_name" class="text_pole" type="text" name="chat_name" placeholder="Chat Name (Optional)" maxlength="100" />
|
||||
<input id="rm_group_chat_name" class="text_pole wide100p" type="text" name="chat_name" placeholder="Chat Name (Optional)" maxlength="100" />
|
||||
<div id="group_tags_div" class="wide100p">
|
||||
<div class="tag_controls">
|
||||
<input id="groupTagInput" class="text_pole tag_input flex1" placeholder="Search / Create tags" maxlength="25" />
|
||||
<div class="tags_view menu_button fa-solid fa-tags" title="View all tags"></div>
|
||||
<input id="groupTagInput" class="text_pole tag_input flex1 margin0" placeholder="Search / Create tags" maxlength="25" />
|
||||
<div class="tags_view menu_button fa-solid fa-tags margin0" title="View all tags"></div>
|
||||
</div>
|
||||
<div id="groupTagList" class="tags paddingTopBot5"></div>
|
||||
</div>
|
||||
<div id="rm_group_top_bar" class="flex-container spaceEvenly width100p">
|
||||
<div id="rm_group_top_bar" class="flex-container spaceBetween width100p">
|
||||
<div name="GroupStragegyAndOrder" id="rm_group_buttons" class="fontsize80p flex-container paddingLeftRight5">
|
||||
<div class="">
|
||||
<div class="flex-container flexnowrap width100p whitespacenowrap">
|
||||
@@ -2034,8 +2041,8 @@
|
||||
<div class="inline-drawer-content">
|
||||
<div name="Unadded Char List" class="flex-container flexFlowColumn overflowYAuto flex1">
|
||||
<div id="rm_group_add_members_header">
|
||||
<input id="rm_group_filter" class="text_pole" type="search" placeholder="Filter..." maxlength="100" />
|
||||
<div id="group_fav_filter" class="menu_button fa-solid fa-ranking-star" title="Show only favorites"></div>
|
||||
<input id="rm_group_filter" class="text_pole margin0" type="search" placeholder="Filter..." maxlength="100" />
|
||||
<div id="group_fav_filter" class="menu_button fa-solid fa-ranking-star margin0" title="Show only favorites"></div>
|
||||
</div>
|
||||
<div id="rm_group_add_members" class="overflowYAuto flex-container"></div>
|
||||
</div>
|
||||
@@ -2057,7 +2064,7 @@
|
||||
<div id="rm_button_create" title="Create New Character" class="menu_button fa-solid fa-user-plus "></div>
|
||||
<div id="character_import_button" title="Import Character from File" class="menu_button fa-solid fa-file-arrow-up "></div>
|
||||
<div id="rm_button_group_chats" title="Create New Chat Group" class="menu_button fa-solid fa-users-gear "></div>
|
||||
<input id="character_search_bar" class="text_pole" type="search" placeholder="Search..." maxlength="50" />
|
||||
<input id="character_search_bar" class="text_pole width100p" type="search" placeholder="Search..." maxlength="50" />
|
||||
<select id="character_sort_order" title="Characters sorting order">
|
||||
<option data-field="name" data-order="asc">A-Z</option>
|
||||
<option data-field="name" data-order="desc">Z-A</option>
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { chat_metadata, saveSettingsDebounced } from "../../../script.js";
|
||||
import { extension_settings, getContext } from "../../extensions.js";
|
||||
import { registerSlashCommand } from "../../slash-commands.js";
|
||||
import { debounce } from "../../utils.js";
|
||||
export { MODULE_NAME };
|
||||
|
||||
@@ -19,6 +20,10 @@ const metadata_keys = {
|
||||
position: 'note_position',
|
||||
}
|
||||
|
||||
function setNoteCommand(_, text) {
|
||||
$('#extension_floating_prompt').val(text).trigger('input');
|
||||
}
|
||||
|
||||
async function onExtensionFloatingPromptInput() {
|
||||
chat_metadata[metadata_keys.prompt] = $(this).val();
|
||||
saveMetadataDebounced();
|
||||
@@ -180,4 +185,5 @@ async function moduleWorker() {
|
||||
|
||||
addExtensionsSettings();
|
||||
setInterval(moduleWorkerWrapper, UPDATE_INTERVAL);
|
||||
registerSlashCommand('note', setNoteCommand, [], " – sets an author's note for the currently selected chat", true, true);
|
||||
})();
|
@@ -97,7 +97,9 @@ function executeSlashCommands(text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lines = text.split('\n');
|
||||
// Hack to allow multi-line slash commands
|
||||
// All slash command messages should begin with a slash
|
||||
const lines = [text];
|
||||
const linesToRemove = [];
|
||||
|
||||
let interrupt = false;
|
||||
|
@@ -1080,15 +1080,10 @@ select option:not(:checked) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#api_url_text,
|
||||
#textgenerationwebui_api_url_text {
|
||||
#api_url_text {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#textgenerationwebui_api pre {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#api_button:hover,
|
||||
#api_button_novel:hover,
|
||||
#api_button_textgenerationwebui:hover,
|
||||
@@ -2838,7 +2833,6 @@ body .ui-widget-content li:hover {
|
||||
#rm_group_add_members_header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
column-gap: 10px;
|
||||
}
|
||||
|
@@ -282,5 +282,6 @@ GNU Affero General Public License for more details.**
|
||||
* KoboldAI Presets from KAI Lite: <https://lite.koboldai.net/>
|
||||
* Noto Sans font by Google (OFL license)
|
||||
* Icon theme by Font Awesome <https://fontawesome.com> (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* AI Horde client library by ZeldaFan0225: https://github.com/ZeldaFan0225/ai_horde
|
||||
* Linux startup script by AlpinDale
|
||||
* Thanks paniphons for providing a FAQ document
|
||||
|
10
server.js
10
server.js
@@ -82,10 +82,11 @@ const allowKeysExposure = config.allowKeysExposure;
|
||||
const axios = require('axios');
|
||||
const tiktoken = require('@dqbd/tiktoken');
|
||||
const WebSocket = require('ws');
|
||||
const AIHorde = require("@zeldafan0225/ai_horde");
|
||||
const AIHorde = require("./src/horde");
|
||||
const ai_horde = new AIHorde({
|
||||
client_agent: getVersion()?.agent || 'SillyTavern:UNKNOWN:Cohee#1207',
|
||||
});
|
||||
const ipMatching = require('ip-matching');
|
||||
|
||||
var Client = require('node-rest-client').Client;
|
||||
var client = new Client();
|
||||
@@ -243,7 +244,7 @@ app.use(function (req, res, next) { //Security
|
||||
}
|
||||
|
||||
//clientIp = req.connection.remoteAddress.split(':').pop();
|
||||
if (whitelistMode === true && !whitelist.includes(clientIp)) {
|
||||
if (whitelistMode === true && !whitelist.some(x => ipMatching.matches(clientIp, ipMatching.getMatch(x)))) {
|
||||
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 SillyTavern 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 SillyTavern folder.');
|
||||
}
|
||||
@@ -2562,7 +2563,8 @@ app.post("/generate_openai", jsonParser, function (request, response_generate_op
|
||||
response_generate_openai.send({ error: true });
|
||||
} else if (response.status == 429) {
|
||||
console.log('Out of quota');
|
||||
response_generate_openai.send({ error: true, quota_error: true, });
|
||||
const quota_error = response?.data?.type === 'insufficient_quota';
|
||||
response_generate_openai.send({ error: true, quota_error, });
|
||||
} else if (response.status == 500 || response.status == 409 || response.status == 504) {
|
||||
if (request.body.stream) {
|
||||
response.data.on('data', chunk => {
|
||||
@@ -2585,7 +2587,7 @@ app.post("/generate_openai", jsonParser, function (request, response_generate_op
|
||||
}
|
||||
}
|
||||
try {
|
||||
const quota_error = error?.response?.status === 429;
|
||||
const quota_error = error?.response?.status === 429 && error?.response?.data?.error?.type === 'insufficient_quota';
|
||||
if (!response_generate_openai.headersSent) {
|
||||
response_generate_openai.send({ error: true, quota_error });
|
||||
}
|
||||
|
21
src/horde/LICENSE.md
Normal file
21
src/horde/LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 ZeldaFan0225
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
2189
src/horde/index.d.ts
vendored
Normal file
2189
src/horde/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
src/horde/index.js
Normal file
1
src/horde/index.js
Normal file
File diff suppressed because one or more lines are too long
3
src/horde/index.mjs
Normal file
3
src/horde/index.mjs
Normal file
@@ -0,0 +1,3 @@
|
||||
import AIHorde from './index.js'
|
||||
export default AIHorde
|
||||
export { AIHorde }
|
Reference in New Issue
Block a user