Merge pull request #5253 from oobabooga/dev

Merge dev branch
This commit is contained in:
oobabooga 2024-01-13 21:49:32 -03:00 committed by GitHub
commit 61e4bfe305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 82 additions and 18 deletions

View File

@ -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 |

View File

@ -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

View File

@ -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

View File

@ -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 {
@ -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
@ -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,
};
@ -424,4 +447,4 @@ function handleVisibilityChange(isVisible) {
}
}
respondToVisibility(renameTextArea, handleVisibilityChange);
respondToRenameVisibility(renameTextArea, handleVisibilityChange);

View File

@ -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():
@ -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:

View File

@ -1,4 +1,5 @@
import argparse
import copy
import os
import sys
from collections import OrderedDict
@ -65,6 +66,7 @@ settings = {
'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))

View File

@ -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"))

View File

@ -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.*

View File

@ -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.*

View File

@ -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.*

View File

@ -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.*

View File

@ -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.*

View File

@ -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.*

View File

@ -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.*

View File

@ -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.*

View File

@ -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.*