Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/13 - Keyboard Shortcuts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Keyboard Shortcuts

#### General

| Shortcut | Description |
|-------------------------|--------------------------------------------------|
| Esc | Stop generation |
| Tab | Switch between current tab and Parameters tab |

#### Chat tab

| Shortcut | Description |
|-------------------------|--------------------------------------------------|
| Ctrl + S | Show/hide chat controls |
| Ctrl + Enter | Regenerate |
| Alt + Enter | Continue |
| Ctrl + Shift + Backspace| Remove last |
| Ctrl + Shift + K | Copy last |
| Ctrl + Shift + L | Replace last |
| Ctrl + Shift + M | Impersonate |
4 changes: 2 additions & 2 deletions extensions/openai/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ def chat_completions_common(body: dict, is_legacy: bool = False, stream=False) -
# Chat character
character = body['character'] or shared.settings['character']
character = "Assistant" if character == "None" else character
name1 = body['name1'] or shared.settings['name1']
name1 = body['user_name'] or shared.settings['name1']
name1, name2, _, greeting, context = load_character_memoized(character, name1, '')
name2 = body['name2'] or name2
name2 = body['bot_name'] or name2
context = body['context'] or context
greeting = body['greeting'] or greeting

Expand Down
8 changes: 4 additions & 4 deletions extensions/openai/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ class ChatCompletionRequestParams(BaseModel):
instruction_template_str: str | None = Field(default=None, description="A Jinja2 instruction template. If set, will take precedence over everything else.")

character: str | None = Field(default=None, description="A character defined under text-generation-webui/characters. If not set, the default \"Assistant\" character will be used.")
name1: str | None = Field(default=None, description="Your name (the user). By default, it's \"You\".")
name2: str | None = Field(default=None, description="Overwrites the value set by character.")
context: str | None = Field(default=None, description="Overwrites the value set by character.")
greeting: str | None = Field(default=None, description="Overwrites the value set by character.")
user_name: str | None = Field(default=None, description="Your name (the user). By default, it's \"You\".", alias=['name1'])
bot_name: str | None = Field(default=None, description="Overwrites the value set by character field.", alias=['name2'])
context: str | None = Field(default=None, description="Overwrites the value set by character field.")
greeting: str | None = Field(default=None, description="Overwrites the value set by character field.")
chat_template_str: str | None = Field(default=None, description="Jinja2 template for chat.")

chat_instruct_command: str | None = None
Expand Down
31 changes: 27 additions & 4 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ document.addEventListener("keydown", function(event) {
}

// Switch between tabs on Tab
else if (!event.ctrlKey && !event.shiftKey && event.key === "Tab") {
else if (!event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey && event.key === "Tab") {
event.preventDefault();
var parametersButton = document.getElementById("parameters-button");
var parentContainer = parametersButton.parentNode;
var selectedChild = parentContainer.querySelector(".selected");

if (selectedChild.id == "parameters-button") {
document.getElementById(previousTabId).click();
} else {
Expand Down Expand Up @@ -318,7 +319,29 @@ document.getElementById("show-controls").parentNode.style.bottom = "0px";
//------------------------------------------------
// Focus on the chat input
//------------------------------------------------
document.querySelector("#chat-input textarea").focus();
const chatTextArea = document.getElementById("chat-input").querySelector("textarea");

function respondToChatInputVisibility(element, callback) {
var options = {
root: document.documentElement,
};

var observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
callback(entry.intersectionRatio > 0);
});
}, options);

observer.observe(element);
}

function handleChatInputVisibilityChange(isVisible) {
if (isVisible) {
chatTextArea.focus();
}
}

respondToChatInputVisibility(chatTextArea, handleChatInputVisibilityChange);

//------------------------------------------------
// Show enlarged character picture when the profile
Expand Down Expand Up @@ -403,7 +426,7 @@ window.addEventListener("resize", updateDocumentWidth);
//------------------------------------------------
const renameTextArea = document.getElementById("rename-row").querySelector("textarea");

function respondToVisibility(element, callback) {
function respondToRenameVisibility(element, callback) {
var options = {
root: document.documentElement,
};
Expand All @@ -424,4 +447,4 @@ function handleVisibilityChange(isVisible) {
}
}

respondToVisibility(renameTextArea, handleVisibilityChange);
respondToRenameVisibility(renameTextArea, handleVisibilityChange);
17 changes: 10 additions & 7 deletions modules/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ def apply_settings(extension, name):

for param in extension.params:
_id = f"{name}-{param}"
if _id not in shared.settings:
continue

extension.params[param] = shared.settings[_id]
shared.default_settings[_id] = extension.params[param]
if _id in shared.settings:
extension.params[param] = shared.settings[_id]


def load_extensions():
Expand All @@ -40,10 +39,14 @@ def load_extensions():
raise

extension = getattr(extensions, name).script
apply_settings(extension, name)
if extension not in setup_called and hasattr(extension, "setup"):

# Only run setup() and apply settings from settings.yaml once
if extension not in setup_called:
apply_settings(extension, name)
if hasattr(extension, "setup"):
extension.setup()

setup_called.add(extension)
extension.setup()

state[name] = [True, i]
except:
Expand Down
2 changes: 2 additions & 0 deletions modules/shared.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import copy
import os
import sys
from collections import OrderedDict
Expand Down Expand Up @@ -65,6 +66,7 @@
'default_extensions': ['gallery'],
}

default_settings = copy.deepcopy(settings)

# Parser copied from https://github.com/vladmandic/automatic
parser = argparse.ArgumentParser(description="Text generation web UI", conflict_handler='resolve', add_help=True, formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=55, indent_increment=2, width=200))
Expand Down
9 changes: 8 additions & 1 deletion modules/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ def save_settings(state, preset, extensions_list, show_controls, theme_state):
params = getattr(extension, 'params')
for param in params:
_id = f"{extension_name}-{param}"
output[_id] = params[param]
# Only save if different from default value
if param not in shared.default_settings or params[param] != shared.default_settings[param]:
output[_id] = params[param]

# Do not save unchanged settings
for key in list(output.keys()):
if key in shared.default_settings and output[key] == shared.default_settings[key]:
output.pop(key)

return yaml.dump(output, sort_keys=False, width=float("inf"))

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11; platform_system != "Darwin" and platform_machine != "x86_64"
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_amd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11; platform_system == "Windows" or python_version < "3.10" or python_version > "3.11" or platform_machine != "x86_64"
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_amd_noavx2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11; platform_system == "Windows" or python_version < "3.10" or python_version > "3.11" or platform_machine != "x86_64"
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_apple_intel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_apple_silicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_cpu_only.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_cpu_only_noavx2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_noavx2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11; platform_system != "Darwin" and platform_machine != "x86_64"
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down
1 change: 1 addition & 0 deletions requirements_nowheels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ einops
exllamav2==0.0.11
gradio==3.50.*
hqq==0.1.2
jinja2==3.1.2
lm_eval==0.3.0
markdown
numpy==1.24.*
Expand Down