mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-05-28 09:44:29 +02:00
New icon for connection. Note page for OAI key. Fix swipes with OAI. OAI model selection.
This commit is contained in:
parent
7cce26bd22
commit
fd14855da9
1
public/img/plug-circle-exclamation-solid.svg
Normal file
1
public/img/plug-circle-exclamation-solid.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M96 0C78.3 0 64 14.3 64 32v96h64V32c0-17.7-14.3-32-32-32zM288 0c-17.7 0-32 14.3-32 32v96h64V32c0-17.7-14.3-32-32-32zM32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32v32c0 77.4 55 142 128 156.8V480c0 17.7 14.3 32 32 32s32-14.3 32-32V412.8c12.3-2.5 24.1-6.4 35.1-11.5c-2.1-10.8-3.1-21.9-3.1-33.3c0-80.3 53.8-148 127.3-169.2c.5-2.2 .7-4.5 .7-6.8c0-17.7-14.3-32-32-32H32zM432 512a144 144 0 1 0 0-288 144 144 0 1 0 0 288zm0-96a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm0-144c8.8 0 16 7.2 16 16v80c0 8.8-7.2 16-16 16s-16-7.2-16-16V288c0-8.8 7.2-16 16-16z"/></svg>
|
After Width: | Height: | Size: 783 B |
1
public/img/plug-solid.svg
Normal file
1
public/img/plug-solid.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Pro 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M96 0C78.3 0 64 14.3 64 32v96h64V32c0-17.7-14.3-32-32-32zM288 0c-17.7 0-32 14.3-32 32v96h64V32c0-17.7-14.3-32-32-32zM32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32v32c0 77.4 55 142 128 156.8V480c0 17.7 14.3 32 32 32s32-14.3 32-32V412.8C297 398 352 333.4 352 256V224c17.7 0 32-14.3 32-32s-14.3-32-32-32H32z"/></svg>
|
After Width: | Height: | Size: 549 B |
@ -122,7 +122,11 @@
|
|||||||
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||||
|
|
||||||
<h4>API key</h4>
|
<h4>API key</h4>
|
||||||
<h5>Where to get (<a href="/notes/6" target="_blank">?</a>)</h5>
|
<h5>Where to get
|
||||||
|
<a href="/notes/6" class="notes-link" target="_blank">
|
||||||
|
<span class="note-link-span">?</span>
|
||||||
|
</a>
|
||||||
|
</h5>
|
||||||
<input id="api_key_novel" name="api_key_novel" class="text_pole" maxlength="500" size="35" value="" autocomplete="off">
|
<input id="api_key_novel" name="api_key_novel" class="text_pole" maxlength="500" size="35" value="" autocomplete="off">
|
||||||
<input id="api_button_novel" class="menu_button" type="submit" value="Connect">
|
<input id="api_button_novel" class="menu_button" type="submit" value="Connect">
|
||||||
<img id="api_loading_novel" src="img/load.svg">
|
<img id="api_loading_novel" src="img/load.svg">
|
||||||
@ -186,6 +190,11 @@
|
|||||||
<div id="openai_api" style="display: none;position: relative;">
|
<div id="openai_api" style="display: none;position: relative;">
|
||||||
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||||
<h4>API key </h4>
|
<h4>API key </h4>
|
||||||
|
<h5>Where to get
|
||||||
|
<a href="/notes/oai_api_key" class="notes-link" target="_blank">
|
||||||
|
<span class="note-link-span">?</span>
|
||||||
|
</a>
|
||||||
|
</h5>
|
||||||
<input id="api_key_openai" name="api_key_openai" class="text_pole" maxlength="500" size="35" value=""
|
<input id="api_key_openai" name="api_key_openai" class="text_pole" maxlength="500" size="35" value=""
|
||||||
autocomplete="off">
|
autocomplete="off">
|
||||||
<input id="api_button_openai" class="menu_button" type="submit" value="Connect">
|
<input id="api_button_openai" class="menu_button" type="submit" value="Connect">
|
||||||
@ -196,10 +205,17 @@
|
|||||||
<div class="online_status_text4">No connection...</div>
|
<div class="online_status_text4">No connection...</div>
|
||||||
</div>
|
</div>
|
||||||
<h4>Preset settings</h4>
|
<h4>Preset settings</h4>
|
||||||
<h5>Selecting settings</h5>
|
<select id="settings_perset_openai">
|
||||||
<select id="settings_perset_openai" class="option_select_right_menu">
|
|
||||||
<option value="gui">Default</option>
|
<option value="gui">Default</option>
|
||||||
</select>
|
</select>
|
||||||
|
<h4>Model</h4>
|
||||||
|
<select id="model_openai_select">
|
||||||
|
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
|
||||||
|
<option value="gpt-3.5-turbo-0301">gpt-3.5-turbo-0301</option>
|
||||||
|
<option value="text-davinci-003">text-davinci-003</option>
|
||||||
|
<option value="text-davinci-002">text-davinci-002</option>
|
||||||
|
<option value="code-davinci-002">code-davinci-002</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
37
public/notes/oai_api_key.html
Normal file
37
public/notes/oai_api_key.html
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Advanced Settings</title>
|
||||||
|
<link rel="stylesheet" href="/css/notes.css">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
|
||||||
|
rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="main">
|
||||||
|
<div id="content">
|
||||||
|
<h2>OpenAI API key</h2>
|
||||||
|
<br>
|
||||||
|
<h3>How to get:</h3>
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
|
Go to <a href="https://platform.openai.com/" target="_blank">OpenAI</a> and sign in.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
Use "<a href="https://platform.openai.com/account/api-keys" target="_blank">View API keys</a>" option to create a new API key.
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<h3>Important!</h3>
|
||||||
|
<p>
|
||||||
|
<i>Lost API keys can't be restored! Make sure to keep it safe!</i>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -103,6 +103,7 @@ export {
|
|||||||
api_server,
|
api_server,
|
||||||
nai_settings,
|
nai_settings,
|
||||||
token,
|
token,
|
||||||
|
name1,
|
||||||
is_send_press,
|
is_send_press,
|
||||||
api_server_textgenerationwebui,
|
api_server_textgenerationwebui,
|
||||||
count_view_mes,
|
count_view_mes,
|
||||||
@ -1049,7 +1050,13 @@ async function Generate(type, automatic_trigger, force_name2) {//encode("dsfs").
|
|||||||
let mesExamplesArray = mesExamples.split(/<START>/gi).slice(1).map(block => `<START>\n${block.trim()}\n`);
|
let mesExamplesArray = mesExamples.split(/<START>/gi).slice(1).map(block => `<START>\n${block.trim()}\n`);
|
||||||
|
|
||||||
if (main_api === 'openai') {
|
if (main_api === 'openai') {
|
||||||
setOpenAIMessages(chat);
|
const oai_chat = [...chat];
|
||||||
|
|
||||||
|
if (type == 'swipe') {
|
||||||
|
oai_chat.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
setOpenAIMessages(oai_chat);
|
||||||
setOpenAIMessageExamples(mesExamplesArray);
|
setOpenAIMessageExamples(mesExamplesArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
checkOnlineStatus,
|
checkOnlineStatus,
|
||||||
setOnlineStatus,
|
setOnlineStatus,
|
||||||
token,
|
token,
|
||||||
|
name1,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -57,6 +58,7 @@ const oai_settings = {
|
|||||||
nsfw_first: false,
|
nsfw_first: false,
|
||||||
main_prompt: default_main_prompt,
|
main_prompt: default_main_prompt,
|
||||||
nsfw_prompt: default_nsfw_prompt,
|
nsfw_prompt: default_nsfw_prompt,
|
||||||
|
openai_model: 'gpt-3.5-turbo-0301',
|
||||||
};
|
};
|
||||||
|
|
||||||
let openai_setting_names;
|
let openai_setting_names;
|
||||||
@ -77,6 +79,16 @@ function setOpenAIMessages(chat) {
|
|||||||
}
|
}
|
||||||
let role = chat[j]['is_user'] ? 'user' : 'assistant';
|
let role = chat[j]['is_user'] ? 'user' : 'assistant';
|
||||||
let content = chat[j]['mes'];
|
let content = chat[j]['mes'];
|
||||||
|
|
||||||
|
// system messages produce no content
|
||||||
|
if (chat[j]['is_system']) {
|
||||||
|
role = 'system';
|
||||||
|
content = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// replace bias markup
|
||||||
|
content = (content ?? '').replace(/{([^}]+)}/g, '');
|
||||||
|
|
||||||
// Apply the "wrap in quotes" option
|
// Apply the "wrap in quotes" option
|
||||||
if (role == 'user' && oai_settings.wrap_in_quotes) content = `"${content}"`;
|
if (role == 'user' && oai_settings.wrap_in_quotes) content = `"${content}"`;
|
||||||
openai_msgs[i] = { "role": role, "content": content };
|
openai_msgs[i] = { "role": role, "content": content };
|
||||||
@ -293,8 +305,7 @@ function prepareOpenAIMessages(name2, storyString, worldInfoBefore, worldInfoAft
|
|||||||
async function sendOpenAIRequest(openai_msgs_tosend) {
|
async function sendOpenAIRequest(openai_msgs_tosend) {
|
||||||
const generate_data = {
|
const generate_data = {
|
||||||
"messages": openai_msgs_tosend,
|
"messages": openai_msgs_tosend,
|
||||||
// todo: add setting for le custom model
|
"model": oai_settings.openai_model,
|
||||||
"model": "gpt-3.5-turbo-0301",
|
|
||||||
"temperature": parseFloat(oai_settings.temp_openai),
|
"temperature": parseFloat(oai_settings.temp_openai),
|
||||||
"frequency_penalty": parseFloat(oai_settings.freq_pen_openai),
|
"frequency_penalty": parseFloat(oai_settings.freq_pen_openai),
|
||||||
"presence_penalty": parseFloat(oai_settings.pres_pen_openai),
|
"presence_penalty": parseFloat(oai_settings.pres_pen_openai),
|
||||||
@ -430,6 +441,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
if (settings.enhance_definitions !== undefined) oai_settings.enhance_definitions = !!settings.enhance_definitions;
|
if (settings.enhance_definitions !== undefined) oai_settings.enhance_definitions = !!settings.enhance_definitions;
|
||||||
if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;
|
if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;
|
||||||
if (settings.nsfw_first !== undefined) oai_settings.nsfw_first = !!settings.nsfw_first;
|
if (settings.nsfw_first !== undefined) oai_settings.nsfw_first = !!settings.nsfw_first;
|
||||||
|
if (settings.openai_model !== undefined) oai_settings.openai_model = settings.openai_model;
|
||||||
|
|
||||||
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
||||||
|
|
||||||
@ -437,6 +449,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
$('#openai_max_context_counter').html(`${oai_settings.openai_max_context} Tokens`);
|
$('#openai_max_context_counter').html(`${oai_settings.openai_max_context} Tokens`);
|
||||||
|
|
||||||
$('#openai_max_tokens').val(oai_settings.openai_max_tokens);
|
$('#openai_max_tokens').val(oai_settings.openai_max_tokens);
|
||||||
|
$(`#model_openai_select option[value="${oai_settings.openai_model}"`).attr('selected', true);
|
||||||
|
|
||||||
$('#nsfw_toggle').prop('checked', oai_settings.nsfw_toggle);
|
$('#nsfw_toggle').prop('checked', oai_settings.nsfw_toggle);
|
||||||
$('#keep_example_dialogue').prop('checked', oai_settings.keep_example_dialogue);
|
$('#keep_example_dialogue').prop('checked', oai_settings.keep_example_dialogue);
|
||||||
@ -526,6 +539,12 @@ $(document).ready(function () {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#model_openai_select").change(function() {
|
||||||
|
const value = $(this).val();
|
||||||
|
oai_settings.openai_model = value;
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$('#stream_toggle').change(function () {
|
$('#stream_toggle').change(function () {
|
||||||
oai_settings.stream_openai = !!$('#stream_toggle').prop('checked');
|
oai_settings.stream_openai = !!$('#stream_toggle').prop('checked');
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
|
@ -2716,7 +2716,10 @@ label[for="extensions_autoconnect"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.icon-connect{
|
.icon-connect{
|
||||||
background-image: url('img/wifi-solid.svg');
|
background-image: url('img/plug-solid.svg');
|
||||||
|
}
|
||||||
|
.icon-connect.redOverlayGlow {
|
||||||
|
background-image: url('img/plug-circle-exclamation-solid.svg');
|
||||||
}
|
}
|
||||||
.icon-sliders{
|
.icon-sliders{
|
||||||
background-image: url('img/sliders-solid.svg');
|
background-image: url('img/sliders-solid.svg');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user