@1.1.0
1)NovelAI support 2)Changing your character name 3)Repetition Penalty has been moved to the main settings 4)Added Pro settings (Anchors Order) 5)Max Context and Amount Gen have been added to the Pro Settings 6)Editing messages 7)New backgrounds
14
public/NovelAI Settings/Classic-Euterpe.settings
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"order": [
|
||||||
|
3,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"temperature": 1.11,
|
||||||
|
"max_length": 90,
|
||||||
|
"min_length": 1,
|
||||||
|
"tail_free_sampling": 0.68,
|
||||||
|
"repetition_penalty": 1.11,
|
||||||
|
"repetition_penalty_range": 320,
|
||||||
|
"repetition_penalty_frequency": 0,
|
||||||
|
"repetition_penalty_presence": 0
|
||||||
|
}
|
14
public/NovelAI Settings/Classic-Krake.settings
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"order": [
|
||||||
|
3,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"temperature": 1.7,
|
||||||
|
"max_length": 90,
|
||||||
|
"min_length": 1,
|
||||||
|
"tail_free_sampling": 0.6602,
|
||||||
|
"repetition_penalty": 1.0565,
|
||||||
|
"repetition_penalty_range": 340,
|
||||||
|
"repetition_penalty_frequency": 0,
|
||||||
|
"repetition_penalty_presence": 0
|
||||||
|
}
|
BIN
public/backgrounds/flasks.png
Normal file
After Width: | Height: | Size: 1.2 MiB |
BIN
public/backgrounds/kingdom.png
Normal file
After Width: | Height: | Size: 831 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
BIN
public/backgrounds/noble1.png
Normal file
After Width: | Height: | Size: 2.3 MiB |
BIN
public/backgrounds/noble2.png
Normal file
After Width: | Height: | Size: 2.5 MiB |
BIN
public/backgrounds/ruins.png
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
public/backgrounds/smokycity.png
Normal file
After Width: | Height: | Size: 872 KiB |
BIN
public/backgrounds/warmtown.png
Normal file
After Width: | Height: | Size: 2.3 MiB |
BIN
public/backgrounds/whitesnow.png
Normal file
After Width: | Height: | Size: 2.1 MiB |
BIN
public/img/cancel.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
public/img/done.png
Normal file
After Width: | Height: | Size: 884 B |
BIN
public/img/kobold.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
public/img/love.png
Normal file
After Width: | Height: | Size: 861 B |
BIN
public/img/novelai.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
public/img/scroll.png
Normal file
After Width: | Height: | Size: 688 B |
BIN
public/notes/1.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
public/notes/2.png
Normal file
After Width: | Height: | Size: 25 KiB |
@ -1,6 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Preset settings</title>
|
<title>KoboldAI Settings</title>
|
||||||
<link rel="stylesheet" href="/css/notes.css">
|
<link rel="stylesheet" href="/css/notes.css">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
@ -8,16 +8,21 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<h2>Preset settings</h2>
|
<h2>KoboldAI Settings</h2>
|
||||||
<p>Standard KoboldAI settings files are used here. To add your own settings, simply add the file .settings in TavernAI\public\KoboldAI Settings
|
<p>Standard KoboldAI settings files are used here. To add your own settings, simply add the file .settings in TavernAI\public\KoboldAI Settings
|
||||||
<br><br>Important: Temporarily, at the moment, the context will always be 2048 tokens, regardless of any settings.
|
|
||||||
</p>
|
</p>
|
||||||
<h3>Temperature</h3>
|
<h3>Temperature</h3>
|
||||||
<p>Value from 0.1 to 2.0. Lower value - the answers are more logical, but less creative. Higher value - the answers are more creative, but less logical.</p>
|
<p>Value from 0.1 to 2.0. Lower value - the answers are more logical, but less creative. Higher value - the answers are more creative, but less logical.</p>
|
||||||
|
<h3>Repetition penalty</h3>
|
||||||
|
<p>Repetition penalty is responsible for the penalty of repeated words. If the character is fixated on something or repeats the same phrase, then increasing this parameter will fix it. It is not recommended to increase this parameter too much for the chat format, as it may break this format. The standard value for chat is approximately 1.0 - 1.05</p>
|
||||||
|
<h3>Repetition penalty range</h3>
|
||||||
|
<p>The range of influence of Repetition penalty in tokens.</p><br>
|
||||||
|
<h2>Pro settings</h2>
|
||||||
<h3>Amount generation</h3>
|
<h3>Amount generation</h3>
|
||||||
<p>The maximum amount of tokens that a AI will generate to respond. One word is approximately 3-4 tokens. The larger the parameter value, the longer the generation time takes.</p>
|
<p>The maximum amount of tokens that a AI will generate to respond. One word is approximately 3-4 tokens. The larger the parameter value, the longer the generation time takes.</p>
|
||||||
<h3>User Avatar</h3>
|
<h3>Context size</h3>
|
||||||
<p>Images can be added in TavernAI\public\User Avatars</p>
|
<p>How much will the AI remember. Context size also affects the speed of generation.<br><br>
|
||||||
|
<u>Important</u>: The settings of Context size in TavernAI GUI override any other settings for KoboldAI(from KoboldAI GUI and from preset files)</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
28
public/notes/6.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NovelAI api key</title>
|
||||||
|
<link rel="stylesheet" href="/css/notes.css">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main">
|
||||||
|
<div id="content">
|
||||||
|
<h2>Finding your NAI API key</h2>
|
||||||
|
<h4>To get a NovelAI API key, follow these instructions:</h4>
|
||||||
|
|
||||||
|
1. Login to NovelAI through the website.<br><br>
|
||||||
|
|
||||||
|
2. Create a new story, or open an existing story.<br><br>
|
||||||
|
|
||||||
|
3. Open the Network Tools on your web browser. (For Chrome or Firefox, you do this by pressing Ctrl+Shift+I, then switching to the Network tab.)<br><br>
|
||||||
|
|
||||||
|
4. Generate something. You should see two requests to api.novelai.net/ai/generate-stream, which might look something like this:</p>
|
||||||
|
<img src="1.png"><br><br>
|
||||||
|
5. Select the second request, then in the Headers tab of the inspection panel, scroll down to the very bottom. Look for a header called Authorization:<br><br>
|
||||||
|
<img src="2.png"><br><br>
|
||||||
|
The long string (after "Bearer", not including it) is your API key.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
23
public/notes/7.html
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NovelAI settings</title>
|
||||||
|
<link rel="stylesheet" href="/css/notes.css">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main">
|
||||||
|
<div id="content">
|
||||||
|
<h2>NovelAI settings</h2>
|
||||||
|
<p>The files with the settings are here (TavernAI\public\NovelAI Settings) You also can add own settings files.
|
||||||
|
</p>
|
||||||
|
<h3>Temperature</h3>
|
||||||
|
<p>Value from 0.1 to 2.0. Lower value - the answers are more logical, but less creative. Higher value - the answers are more creative, but less logical.</p>
|
||||||
|
<h3>Repetition penalty</h3>
|
||||||
|
<p>Repetition penalty is responsible for the penalty of repeated words. If the character is fixated on something or repeats the same phrase, then increasing this parameter will fix it. It is not recommended to increase this parameter too much for the chat format, as it may break this format. The standard value for chat is approximately 1.0 - 1.05</p>
|
||||||
|
<h3>Repetition penalty range</h3>
|
||||||
|
<p>The range of influence of Repetition penalty in tokens.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
16
public/notes/8.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NovelAI Models</title>
|
||||||
|
<link rel="stylesheet" href="/css/notes.css">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main">
|
||||||
|
<div id="content">
|
||||||
|
<h2>NovelAI Models</h2>
|
||||||
|
<h4>If your subscribe tier is Paper, Tablet or Scroll use only Euterpe model otherwise you can not get an answer from NovelAI api.</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
20
public/notes/9.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Anchors</title>
|
||||||
|
<link rel="stylesheet" href="/css/notes.css">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main">
|
||||||
|
<div id="content">
|
||||||
|
<h2>Anchors</h2>
|
||||||
|
<h4>Anchors are used to increase the length of messages. There are two types of anchors: Character Anchor and Style Anchor</h4>
|
||||||
|
<p><u>Character Anchor</u> - affects the character played by the AI by motivating him to write longer messages. Looks like [Alexa talks a lot with descriptions]</p>
|
||||||
|
<p><u>Style Anchor</u> - affects all AI model, motivating AI to write longer messages. Looks like [Writing style: very long messages]</p>
|
||||||
|
<hr style="opacity: 0.6;"><p>The order of anchors sets the location of anchors in the promt, the first anchor in the order is much higher and has less influence than the one that follows it.</p>
|
||||||
|
<p>To disable anchors, you just need to remove the checkboxes.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1 +1 @@
|
|||||||
{"api_server":"http://localhost:5000/api","preset_settings":"Lancer-OPT-2.7B-Erebus","user_avatar":"you1.png","temp":0.8,"amount_gen":90}
|
{"myname":"You","api_server":"","preset_settings":"gui","preset_settings_novel":"Classic-Euterpe","user_avatar":"legat.png","temp":0.8,"amount_gen":90,"max_context":2048,"anchor_order":0,"style_anchor":true,"character_anchor":true,"main_api":"kobold","api_key_novel":"","rep_pen":1.02,"rep_pen_size":256,"model_novel":"euterpe-v2","temp_novel":1.11,"rep_pen_novel":1.11,"rep_pen_size_novel":320}
|
161
public/style.css
@ -308,7 +308,7 @@ textarea{
|
|||||||
}
|
}
|
||||||
#personality_textarea{
|
#personality_textarea{
|
||||||
width: 92%;
|
width: 92%;
|
||||||
height: 100px;
|
height: 65px;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
}
|
}
|
||||||
#character_name_pole{
|
#character_name_pole{
|
||||||
@ -424,11 +424,21 @@ input[type=submit] {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color:#ffffffaa;
|
color:#ffffffaa;
|
||||||
}
|
}
|
||||||
|
#api_button_novel{
|
||||||
|
cursor: pointer;
|
||||||
|
color:#ffffffaa;
|
||||||
|
}
|
||||||
#api_loading{
|
#api_loading{
|
||||||
width: 25px;
|
width: 25px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
#api_loading_novel{
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
display: none;
|
||||||
|
|
||||||
}
|
}
|
||||||
#rm_characters_block{
|
#rm_characters_block{
|
||||||
display: block;
|
display: block;
|
||||||
@ -821,6 +831,23 @@ input[type=submit] {
|
|||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
#online_status3{
|
||||||
|
opacity: 0.5;
|
||||||
|
margin-top: 2px;
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
#online_status_indicator3{
|
||||||
|
border-radius: 7px;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
background-color: red;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
#online_status_text3{
|
||||||
|
margin-left: 4px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
.del_checkbox{
|
.del_checkbox{
|
||||||
display: none;
|
display: none;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
@ -862,6 +889,15 @@ select {
|
|||||||
box-shadow: 0 0 2px rgba(200,200,200,0.5);
|
box-shadow: 0 0 2px rgba(200,200,200,0.5);
|
||||||
background-color:#13152c;
|
background-color:#13152c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.option_select_right_menu{
|
||||||
|
width:284px;
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-bottom: 35px;
|
||||||
|
color: #ffffff9d;
|
||||||
|
box-shadow: 0 0 2px rgba(200,200,200,0.5);
|
||||||
|
background-color:#13152c;
|
||||||
|
}
|
||||||
#user_avatar_block{
|
#user_avatar_block{
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
display: grid;
|
display: grid;
|
||||||
@ -891,6 +927,21 @@ select {
|
|||||||
#amount_gen_counter{
|
#amount_gen_counter{
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
|
#max_context{
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
#max_context_counter{
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
#range_block input{
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
#range_block_novel input{
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
input[type="range"] {
|
input[type="range"] {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
@ -922,7 +973,7 @@ input[type="range"] {
|
|||||||
#tips_popup{
|
#tips_popup{
|
||||||
|
|
||||||
width:500px;
|
width:500px;
|
||||||
height: 430px;
|
height: 600px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 2060;
|
z-index: 2060;
|
||||||
background-color: blue;
|
background-color: blue;
|
||||||
@ -931,7 +982,7 @@ input[type="range"] {
|
|||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 20vh;
|
margin-top: 15vh;
|
||||||
box-shadow: 5px 5px -5px -5px rgba(200,200,200,0.1);
|
box-shadow: 5px 5px -5px -5px rgba(200,200,200,0.1);
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
background: #191b31EE;
|
background: #191b31EE;
|
||||||
@ -946,4 +997,108 @@ input[type="range"] {
|
|||||||
z-index: 2055;
|
z-index: 2055;
|
||||||
background-color: #00000066;
|
background-color: #00000066;
|
||||||
}
|
}
|
||||||
|
.mes_edit{
|
||||||
|
display: inline-block;
|
||||||
|
float:right;
|
||||||
|
//right:8px;
|
||||||
|
cursor:pointer;
|
||||||
|
margin-right: 4px;
|
||||||
|
opacity:0.07;
|
||||||
|
}
|
||||||
|
.mes_edit_done{
|
||||||
|
display: none;
|
||||||
|
float:right;
|
||||||
|
right:8px;
|
||||||
|
cursor:pointer;
|
||||||
|
margin-right: 15px;
|
||||||
|
opacity:0.5;
|
||||||
|
}
|
||||||
|
.mes_edit_done img{
|
||||||
|
width: 23px;
|
||||||
|
height: 23px;
|
||||||
|
}
|
||||||
|
.mes_edit_cancel{
|
||||||
|
display: none;
|
||||||
|
float:right;
|
||||||
|
//right:8px;
|
||||||
|
margin-right: 4px;
|
||||||
|
cursor:pointer;
|
||||||
|
opacity:0.5;
|
||||||
|
}
|
||||||
|
.mes_edit_cancel img{
|
||||||
|
width: 23px;
|
||||||
|
height: 23px;
|
||||||
|
}
|
||||||
|
.edit_textarea{
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
border: none;
|
||||||
|
border-color: transparent;
|
||||||
|
outline: none;
|
||||||
|
box-shadow: none;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
#your_name{
|
||||||
|
outline: none;
|
||||||
|
//box-shadow: 0 2px 0px rgba(255, 255, 255, 0.1);
|
||||||
|
box-shadow: 0 0px 0px rgba(255, 255, 255, 0.0);
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
|
||||||
|
}
|
||||||
|
#your_name_button {
|
||||||
|
opacity: 0.5;
|
||||||
|
margin-left: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#form_change_name{
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
.checkbox{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
label.checkbox input[type="checkbox"] {display:none;}
|
||||||
|
label.checkbox span {
|
||||||
|
display:inline-block;
|
||||||
|
border:1px solid #BBBBBB33;
|
||||||
|
border-radius:3px;
|
||||||
|
width:20px;
|
||||||
|
height:20px;
|
||||||
|
background:rgba(19,21,44,0.75);
|
||||||
|
vertical-align:middle;
|
||||||
|
margin:0px;
|
||||||
|
position: relative;
|
||||||
|
transition:width 0.1s, height 0.1s, margin 0.1s;
|
||||||
|
|
||||||
|
}
|
||||||
|
label.checkbox :checked + span {
|
||||||
|
background:rgba(19,21,44,0.75);
|
||||||
|
width:20px;
|
||||||
|
height:20px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
label.checkbox :checked + span:after {
|
||||||
|
content: '\2714';
|
||||||
|
font-size: 18px;
|
||||||
|
position: absolute;
|
||||||
|
top: -3px;
|
||||||
|
left: 2px;
|
||||||
|
color: #99a1a7;
|
||||||
|
|
||||||
|
}
|
||||||
|
#anchor_order{
|
||||||
|
width:284px;
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
color: #ffffff9d;
|
||||||
|
box-shadow: 0 0 2px rgba(200,200,200,0.5);
|
||||||
|
background-color:#13152c;
|
||||||
|
}
|
||||||
|
#anchor_checkbox{
|
||||||
|
margin-left: 10px;
|
||||||
|
float: left;
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 30px auto;
|
||||||
|
grid-template-columns: auto auto;
|
||||||
|
}
|
||||||
|
182
server.js
@ -10,8 +10,11 @@ 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 response_get_story;
|
var response_get_story;
|
||||||
var response_generate;
|
var response_generate;
|
||||||
|
var response_generate_novel;
|
||||||
var request_promt;
|
var request_promt;
|
||||||
var response_promt;
|
var response_promt;
|
||||||
var characters = {};
|
var characters = {};
|
||||||
@ -20,6 +23,8 @@ var response_create;
|
|||||||
var response_edit;
|
var response_edit;
|
||||||
var response_dw_bg;
|
var response_dw_bg;
|
||||||
var response_getstatus;
|
var response_getstatus;
|
||||||
|
var response_getstatus_novel;
|
||||||
|
var api_key_novel;
|
||||||
|
|
||||||
const jsonParser = express.json();
|
const jsonParser = express.json();
|
||||||
const urlencodedParser = express.urlencoded({extended: false});
|
const urlencodedParser = express.urlencoded({extended: false});
|
||||||
@ -86,16 +91,16 @@ app.post("/generate", jsonParser, function(request, response_generate = response
|
|||||||
}
|
}
|
||||||
if(response.statusCode == 422){
|
if(response.statusCode == 422){
|
||||||
console.log('Validation error');
|
console.log('Validation error');
|
||||||
response_getstatus.send({error: true});
|
response_generate.send({error: true});
|
||||||
}
|
}
|
||||||
if(response.statusCode == 501 || response.statusCode == 503 || response.statusCode == 507){
|
if(response.statusCode == 501 || response.statusCode == 503 || response.statusCode == 507){
|
||||||
console.log(data);
|
console.log(data);
|
||||||
response_getstatus.send({error: true});
|
response_generate.send({error: true});
|
||||||
}
|
}
|
||||||
}).on('error', function (err) {
|
}).on('error', function (err) {
|
||||||
//console.log('');
|
//console.log('');
|
||||||
//console.log('something went wrong on the request', err.request.options);
|
//console.log('something went wrong on the request', err.request.options);
|
||||||
response_getstatus.send({error: true});
|
response_generate.send({error: true});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.post("/savechat", jsonParser, function(request, response){
|
app.post("/savechat", jsonParser, function(request, response){
|
||||||
@ -396,7 +401,73 @@ app.post("/savesettings", jsonParser, function(request, response){
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
app.post("/getsettings", jsonParser, function(request, response){
|
app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's code
|
||||||
|
const koboldai_settings = [];
|
||||||
|
const koboldai_setting_names = [];
|
||||||
|
const novelai_settings = [];
|
||||||
|
const novelai_setting_names = [];
|
||||||
|
const settings = fs.readFileSync('public/settings.json', 'utf8', (err, data) => {
|
||||||
|
if (err) return response.sendStatus(500);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
//Kobold
|
||||||
|
const files = fs
|
||||||
|
.readdirSync('public/KoboldAI Settings')
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(fs.statSync(`public/KoboldAI Settings/${b}`).mtime) -
|
||||||
|
new Date(fs.statSync(`public/KoboldAI Settings/${a}`).mtime)
|
||||||
|
);
|
||||||
|
|
||||||
|
files.forEach(item => {
|
||||||
|
const file = fs.readFileSync(
|
||||||
|
`public/KoboldAI Settings/${item}`,
|
||||||
|
'utf8',
|
||||||
|
(err, data) => {
|
||||||
|
if (err) return response.sendStatus(500)
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
koboldai_settings.push(file);
|
||||||
|
koboldai_setting_names.push(item.replace(/\.[^/.]+$/, ''));
|
||||||
|
});
|
||||||
|
|
||||||
|
//Novel
|
||||||
|
const files2 = fs
|
||||||
|
.readdirSync('public/NovelAI Settings')
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(fs.statSync(`public/NovelAI Settings/${b}`).mtime) -
|
||||||
|
new Date(fs.statSync(`public/NovelAI Settings/${a}`).mtime)
|
||||||
|
);
|
||||||
|
|
||||||
|
files2.forEach(item => {
|
||||||
|
const file2 = fs.readFileSync(
|
||||||
|
`public/NovelAI Settings/${item}`,
|
||||||
|
'utf8',
|
||||||
|
(err, data) => {
|
||||||
|
if (err) return response.sendStatus(500);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
novelai_settings.push(file2);
|
||||||
|
novelai_setting_names.push(item.replace(/\.[^/.]+$/, ''));
|
||||||
|
});
|
||||||
|
|
||||||
|
response.send({
|
||||||
|
settings,
|
||||||
|
koboldai_settings,
|
||||||
|
koboldai_setting_names,
|
||||||
|
novelai_settings,
|
||||||
|
novelai_setting_names
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.post("/getsettings2", jsonParser, function(request, response){//Elder
|
||||||
var koboldai_settings = [];
|
var koboldai_settings = [];
|
||||||
var koboldai_setting_names = [];
|
var koboldai_setting_names = [];
|
||||||
fs.stat('public/settings.json', function(err, stat) {
|
fs.stat('public/settings.json', function(err, stat) {
|
||||||
@ -487,6 +558,109 @@ function getDirectories(path) {
|
|||||||
return new Date(fs.statSync(path + '/' + a).mtime) - new Date(fs.statSync(path + '/' + b).mtime);
|
return new Date(fs.statSync(path + '/' + a).mtime) - new Date(fs.statSync(path + '/' + b).mtime);
|
||||||
}).reverse();
|
}).reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***********Novel.ai API
|
||||||
|
|
||||||
|
app.post("/getstatus_novelai", jsonParser, function(request, response_getstatus_novel =response){
|
||||||
|
if(!request.body) return response_generate.sendStatus(400);
|
||||||
|
api_key_novel = request.body.key;
|
||||||
|
var data = {};
|
||||||
|
var args = {
|
||||||
|
data: data,
|
||||||
|
|
||||||
|
headers: { "Content-Type": "application/json", "Authorization": "Bearer "+api_key_novel}
|
||||||
|
};
|
||||||
|
client.get(api_novelai+"/user/subscription",args, function (data, response) {
|
||||||
|
if(response.statusCode == 200){
|
||||||
|
//console.log(data);
|
||||||
|
response_getstatus_novel.send(data);//data);
|
||||||
|
}
|
||||||
|
if(response.statusCode == 401){
|
||||||
|
console.log('Access Token is incorrect.');
|
||||||
|
response_getstatus_novel.send({error: true});
|
||||||
|
}
|
||||||
|
if(response.statusCode == 500 || response.statusCode == 501 || response.statusCode == 501 || response.statusCode == 503 || response.statusCode == 507){
|
||||||
|
console.log(data);
|
||||||
|
response_getstatus_novel.send({error: true});
|
||||||
|
}
|
||||||
|
}).on('error', function (err) {
|
||||||
|
//console.log('');
|
||||||
|
//console.log('something went wrong on the request', err.request.options);
|
||||||
|
response_getstatus_novel.send({error: true});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
app.post("/generate_novelai", jsonParser, function(request, response_generate_novel = response){
|
||||||
|
if(!request.body) return response_generate_novel.sendStatus(400);
|
||||||
|
|
||||||
|
console.log(request.body);
|
||||||
|
var data = {
|
||||||
|
"input": request.body.input,
|
||||||
|
"model": request.body.model,
|
||||||
|
"parameters": {
|
||||||
|
"use_string": request.body.use_string,
|
||||||
|
"temperature": request.body.temperature,
|
||||||
|
"max_length": request.body.max_length,
|
||||||
|
"min_length": request.body.min_length,
|
||||||
|
"tail_free_sampling": request.body.tail_free_sampling,
|
||||||
|
"repetition_penalty": request.body.repetition_penalty,
|
||||||
|
"repetition_penalty_range": request.body.repetition_penalty_range,
|
||||||
|
"repetition_penalty_frequency": request.body.repetition_penalty_frequency,
|
||||||
|
"repetition_penalty_presence": request.body.repetition_penalty_presence,
|
||||||
|
//"stop_sequences": {{187}},
|
||||||
|
//bad_words_ids = {{50256}, {0}, {1}};
|
||||||
|
//generate_until_sentence = true;
|
||||||
|
"use_cache": request.body.use_cache,
|
||||||
|
//use_string = true;
|
||||||
|
"return_full_text": request.body.return_full_text,
|
||||||
|
"prefix": request.body.prefix,
|
||||||
|
"order": request.body.order
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var args = {
|
||||||
|
data: data,
|
||||||
|
|
||||||
|
headers: { "Content-Type": "application/json", "Authorization": "Bearer "+api_key_novel}
|
||||||
|
};
|
||||||
|
client.post(api_novelai+"/ai/generate",args, function (data, response) {
|
||||||
|
if(response.statusCode == 201){
|
||||||
|
console.log(data);
|
||||||
|
response_generate_novel.send(data);
|
||||||
|
}
|
||||||
|
if(response.statusCode == 400){
|
||||||
|
console.log('Validation error');
|
||||||
|
response_generate_novel.send({error: true});
|
||||||
|
}
|
||||||
|
if(response.statusCode == 401){
|
||||||
|
console.log('Access Token is incorrect');
|
||||||
|
response_generate_novel.send({error: true});
|
||||||
|
}
|
||||||
|
if(response.statusCode == 402){
|
||||||
|
console.log('An active subscription is required to access this endpoint');
|
||||||
|
response_generate_novel.send({error: true});
|
||||||
|
}
|
||||||
|
if(response.statusCode == 500 || response.statusCode == 409){
|
||||||
|
console.log(data);
|
||||||
|
response_generate_novel.send({error: true});
|
||||||
|
}
|
||||||
|
}).on('error', function (err) {
|
||||||
|
//console.log('');
|
||||||
|
//console.log('something went wrong on the request', err.request.options);
|
||||||
|
response_getstatus.send({error: true});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.listen(server_port, function() {
|
app.listen(server_port, function() {
|
||||||
console.log('Server started: http://127.0.0.1:'+server_port);
|
console.log('Server started: http://127.0.0.1:'+server_port);
|
||||||
|
|
||||||
|