Chat and Adventure mode Fix

This commit is contained in:
ebolam
2022-09-07 10:27:05 -04:00
parent 2c619895bb
commit b700d5e86e
6 changed files with 80 additions and 14 deletions

View File

@@ -345,13 +345,13 @@ gensettingstf = [
"uitype": "dropdown",
"unit": "text",
"label": "Story Mode",
"id": "actionmode",
"id": "storymode",
"default": 0,
"tooltip": "Choose the mode of KoboldAI.",
"menu_path": "Home",
"sub_path": "",
"classname": "story",
"name": "actionmode",
"name": "storymode",
'children': [{'text': 'Story', 'value': 0}, {'text':'Adventure','value':1}, {'text':'Chat', 'value':2}]
},
{

View File

@@ -431,7 +431,7 @@ class model_settings(settings):
self.badwordsids = []
self.fp32_model = False # Whether or not the most recently loaded HF model was in fp32 format
self.modeldim = -1 # Embedding dimension of your model (e.g. it's 4096 for GPT-J-6B and 2560 for GPT-Neo-2.7B)
self.sampler_order = [0, 1, 2, 3, 4, 5]
self.sampler_order = [6, 0, 1, 2, 3, 4, 5]
self.newlinemode = "n"
self.lazy_load = True # Whether or not to use torch_lazy_loader.py for transformers models in order to reduce CPU memory usage
self.revision = None
@@ -552,6 +552,7 @@ class story_settings(settings):
self.chatname = "You"
self.adventure = False
self.actionmode = 0
self.storymode = 0
self.dynamicscan = False
self.recentedit = False
self.notes = "" #Notes for the story. Does nothing but save
@@ -638,7 +639,7 @@ class story_settings(settings):
ignore = self.koboldai_vars.calc_ai_text()
#Because we have seperate variables for action types, this syncs them
elif name == 'actionmode':
elif name == 'storymode':
if value == 0:
self.adventure = False
self.chatmode = False
@@ -650,14 +651,14 @@ class story_settings(settings):
self.chatmode = True
elif name == 'adventure' and value == True:
self.chatmode = False
self.actionmode = 1
self.storymode = 1
elif name == 'adventure' and value == False and self.chatmode == False:
self.actionmode = 0
self.storymode = 0
elif name == 'chatmode' and value == True:
self.adventure = False
self.actionmode = 2
self.storymode = 2
elif name == 'chatmode' and value == False and self.adventure == False:
self.actionmode = 0
self.storymode = 0
class user_settings(settings):
local_only_variables = ['socketio', 'importjs']

View File

@@ -199,6 +199,10 @@ border-top-right-radius: var(--tabs_rounding);
margin: 2px;
}
.chat_mode[story_chatmode="false"] {
display: none;
}
#story_menu_author .setting_container {
display: grid;
grid-template-areas: "label value"
@@ -1305,6 +1309,17 @@ body {
gap: 1px;
}
.inputrow[story_storymode="1"] {
grid-template-areas: "adventure_mode textarea statusbar statusbar statusbar"
"adventure_mode textarea submit submit submit"
"adventure_mode textarea back redo retry";
grid-template-columns: 80px auto 30px 30px 30px;
grid-template-rows: 0px 60px 40px;
gap: 1px;
}
#random_game_prompt{
display: flex;
flex-direction: column;
@@ -1319,6 +1334,16 @@ body {
border-radius: var(--radius_inputbox);
}
#adventure_mode {
grid-area: adventure_mode
}
#adventure_mode[story_storymode]:not([story_storymode="1"]) {
display: none;
}
#input_text {
grid-area: textarea;
background-color: var(--input_background);

View File

@@ -511,6 +511,14 @@ function var_changed(data) {
//Special case for context viewer
} else if (data.classname == "story" && data.name == "context") {
update_context(data.value);
//special case for story_actionmode
} else if (data.classname == "story" && data.name == "actionmode") {
const button = document.getElementById('adventure_mode');
if (data.value == 1) {
button.childNodes[1].textContent = "Adventure";
} else {
button.childNodes[1].textContent = "Story";
}
//Basic Data Syncing
} else {
var elements_to_change = document.getElementsByClassName("var_sync_"+data.classname.replace(" ", "_")+"_"+data.name.replace(" ", "_"));
@@ -2012,6 +2020,25 @@ function load_tweaks(data) {
}
function toggle_adventure_mode(button) {
if (button.textContent == "Mode: Story") {
button.childNodes[1].textContent = "Adventure";
var actionmode = 1
} else {
button.childNodes[1].textContent = "Story";
var actionmode = 0
}
button.classList.add("pulse");
socket.emit("var_change", {"ID": "story_actionmode", "value": actionmode}, (response) => {
if ('status' in response) {
if (response['status'] == 'Saved') {
document.getElementById("adventure_mode").classList.remove("pulse");
}
}
});
}
//--------------------------------------------General UI Functions------------------------------------
function autoResize(element) {
element.style.height = 'auto';

View File

@@ -69,12 +69,13 @@
</div>
</div>
<!------------ Input Area--------------------->
<div class="inputrow" id="inputrow_container">
<div class="inputrow var_sync_alt_story_storymode" id="inputrow_container">
<div id="random_game_prompt" class="hidden">
<input type="text" autocomplete="off" id="themetext" placeholder="Theme for Random Story" oninput='if (this.value != "") {
document.getElementById("input_text").value = "";}'/>
<span class="help_text" style="margin:0px;margin-top:5px;">The AI can create a prompt for you! Optionally type in one or more themes above, or let the AI do it's thing.</span>
</div>
<button class="var_sync_alt_story_storymode action_button" id="adventure_mode" onclick="toggle_adventure_mode(this);"><span style="font-weight: bold;">Mode: </span><span>Story</span></button>
<textarea autocomplete="off" row=5 id="input_text" placeholder="Enter Prompt Here" oninput='if (this.value != "") {
document.getElementById("themetext").value = "";
}'

View File

@@ -76,8 +76,6 @@
<span class="material-icons-outlined cursor var_sync_alt_story_gamesaved" title="Save Story">save</span>
<span class="button_label">Save Story</span>
</button>
</div>
</div>
<hr/>
@@ -88,6 +86,20 @@
{% include 'settings item.html' %}
{% endwith %}
{% endwith %}
<div class="setting_container chat_mode var_sync_alt_story_chatmode">
<!---Top Row---->
<span class="setting_label">
<span style="white-space: pre-wrap;">Chat Name: </span>
<span class="helpicon material-icons-outlined" title="Your name for chat mode.">help_icon</span>
</span>
<!---Bottom Row---->
<span class="setting_item" style="height: 25px;">
<input autocomplete="off" id="var_sync_story_chatname" class="var_sync_story_chatname settings_select" onclick="sync_to_server(this);">
</span>
<!---Slider Labels--->
<span class="setting_minlabel"><span style="top: -4px; position: relative;"></span></span>
<span class="setting_maxlabel"><span style="top: -4px; position: relative;"></span></span>
</div>
</div>
<div id="probabilities">
@@ -112,6 +124,9 @@
</div>
<div class="setting_tile_area">
<span class="help_text">Change how the AI decides what to say.</span>
{% with sub_path='Sampling' %}
{% include 'settings item.html' %}
{% endwith %}
<div class="setting_container_single">
<!---Top Row---->
<span class="setting_label">
@@ -137,9 +152,6 @@
</div>
</span>
</div>
{% with sub_path='Sampling' %}
{% include 'settings item.html' %}
{% endwith %}
</div>
<div class="collapsable_header" onclick="toggle_setting_category(this);">